12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469 |
- import argparse
- import os.path
- from lvc.video import VideoFile
- from lvc import converter
- from lvc import settings
- import base
- import mock
- def make_ffmpeg_arg_parser():
- """Make an args.ArgumentParser for ffmpeg args that we use
- """
- parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)
- # command line options that require an argument after
- arguments = [
- "-ab",
- "-ac",
- "-acodec",
- "-aq",
- "-ar",
- "-b",
- "-b:v",
- "-bufsize",
- "-crf",
- "-cpu-used",
- "-deadline",
- "-f",
- '-g',
- "-i",
- "-lag-in-frames",
- "-level",
- "-map_metadata",
- "-maxrate",
- "-preset",
- "-profile:v",
- "-qscale:a",
- "-qscale:v",
- "-quality",
- "-r",
- "-s",
- "-slices",
- "-strict",
- "-threads",
- "-qmin",
- "-qmax",
- "-vb",
- "-vcodec",
- "-vprofile",
- ]
- # arguments that set flags
- flags = [
- '-vn',
- ]
- for name in arguments:
- parser.add_argument(name)
- for name in flags:
- parser.add_argument(name, action='store_const', const=True)
- parser.add_argument("output_file")
- return parser
- class TestConverterInfo(converter.ConverterInfo):
- media_type = 'video'
- extension = 'test'
- bitrate = 10000
- def get_executable(self):
- return '/bin/true'
- def get_arguments(self, video, output):
- return [video.filename, output]
- def process_status_line(self, line):
- return {'finished': True}
- TEST_CONVERTER = TestConverterInfo('Test Converter')
- class ConverterManagerTest(base.Test):
- def setUp(self):
- base.Test.setUp(self)
- self.manager = converter.ConverterManager()
- def test_startup(self):
- self.manager.startup()
- self.assertTrue(self.manager.converters)
- def test_add_converter(self):
- self.manager.add_converter(TEST_CONVERTER)
- self.assertEqual(len(self.manager.converters), 1)
- def test_list_converters(self):
- self.manager.add_converter(TEST_CONVERTER)
- self.assertEqual(list(self.manager.list_converters()),
- [TEST_CONVERTER])
- def test_get_by_id(self):
- self.manager.add_converter(TEST_CONVERTER)
- self.assertEqual(self.manager.get_by_id('testconverter'),
- TEST_CONVERTER)
- self.assertRaises(KeyError, self.manager.get_by_id,
- 'doesnotexist')
- class ConverterInfoTest(base.Test):
- def setUp(self):
- base.Test.setUp(self)
- self.converter_info = TEST_CONVERTER
- self.video = VideoFile(os.path.join(self.testdata_dir, 'mp4-0.mp4'))
- def test_identifer(self):
- self.assertEqual(self.converter_info.identifier,
- 'testconverter')
- def test_get_output_filename(self):
- self.assertEqual(self.converter_info.get_output_filename(self.video),
- 'mp4-0_testconverter.test')
- def test_get_output_size_guess(self):
- self.assertEqual(self.converter_info.get_output_size_guess(self.video),
- self.video.duration * self.converter_info.bitrate / 8)
- class ConverterInfoTestMixin(object):
- def setUp(self):
- self.video = VideoFile(os.path.join(self.testdata_dir, 'mp4-0.mp4'))
- def assertStatusLineOutput(self, line, **output):
- if not output:
- output = None
- self.assertEqual(self.converter_info.process_status_line(self.video,
- line),
- output)
- def test_get_executable(self):
- self.assertTrue(self.converter_info.get_executable())
- def test_get_arguments(self):
- output = os.path.join(self.testdata_dir, 'output.mp4')
- arguments = self.converter_info.get_arguments(self.video, output)
- self.assertTrue(arguments)
- self.assertTrue(self.video.filename in arguments)
- self.assertTrue(output in arguments)
- class FFmpegConverterInfoTest(ConverterInfoTestMixin, base.Test):
- def setUp(self):
- base.Test.setUp(self)
- ConverterInfoTestMixin.setUp(self)
- self.converter_info = converter.FFmpegConverterInfo('FFmpeg Test',
- 1024, 768)
- self.converter_info.parameters = '{ssize}'
- def run_get_target_size(self, (src_width, src_height),
- (dest_width, dest_height),
- dont_upsize=True):
- """Create a converter run get_target_size() on a video.
- """
- mock_video = mock.Mock(width=src_width, height=src_height)
- converter_info = converter.FFmpegConverterInfo(
- 'FFmpeg Test', dest_width, dest_height)
- converter_info.dont_upsize = dont_upsize
- return converter_info.get_target_size(mock_video)
- def test_get_target_size(self):
- self.assertEqual(self.run_get_target_size((1024, 768), (640, 480)),
- (640, 480))
- def test_get_target_size_rescale(self):
- # Test get_target_size() rescaling an image. It should ensure that
- # both dimensions fit inside the target image, and that the aspect
- # ratio is unchanged.
- self.assertEqual(self.run_get_target_size((1024, 768), (800, 500)),
- (666, 500))
- def test_get_target_size_dont_upsize(self):
- # Test that get_target_size only upsizes when dont_upsize is True
- self.assertEqual(self.run_get_target_size((640, 480), (800, 600)),
- (640, 480))
- self.assertEqual(self.run_get_target_size((640, 480), (800, 600),
- dont_upsize=False),
- (800, 600))
- def test_process_status_line_nothing(self):
- self.assertStatusLineOutput(
- ' built on Mar 31 2012 09:58:16 with gcc 4.6.3')
- def test_process_status_line_duration(self):
- self.assertStatusLineOutput(
- ' Duration: 00:00:01.07, start: 0.000000, bitrate: 128 kb/s',
- duration=1.07)
- def test_process_status_line_progress(self):
- self.assertStatusLineOutput(
- 'size= 2697kB time=00:02:52.59 bitrate= 128.0kbits/s ',
- progress=172.59)
- def test_process_status_line_progress_with_frame(self):
- self.assertStatusLineOutput(
- 'frame= 257 fps= 45 q=27.0 size= 1033kB time=00:00:08.70 '
- 'bitrate= 971.4kbits/s ',
- progress=8.7)
- def test_process_status_line_finished(self):
- self.assertStatusLineOutput(
- 'frame=16238 fps= 37 q=-1.0 Lsize= 110266kB time=00:11:16.50 '
- 'bitrate=1335.3kbits/s dup=16 drop=0',
- finished=True)
- def test_process_status_line_error(self):
- line = ('Error while opening encoder for output stream #0:1 - '
- 'maybe incorrect parameters such as bit_rate, rate, width or '
- 'height')
- self.assertStatusLineOutput(line,
- finished=True,
- error=line)
- def test_process_status_line_unknown(self):
- # XXX haven't actually seen this line
- line = 'Unknown error'
- self.assertStatusLineOutput(line,
- finished=True,
- error=line)
- def test_process_status_line_error_decoding(self):
- # XXX haven't actually seen this line
- line = 'Error while decoding stream: something'
- self.assertStatusLineOutput(line)
- class TestConverterDefinitions(base.Test):
- def setUp(self):
- base.Test.setUp(self)
- self.manager = converter.ConverterManager()
- self.manager.startup()
- self.input_path = os.path.join(self.testdata_dir, 'mp4-0.mp4')
- self.output_path = os.path.join(self.testdata_dir, 'output.mp4')
- def get_converter_arguments(self, converter_obj):
- """Given a converter, get the arguments to that converter
- :returns: dict of arguments that were set
- """
- output_path = self.output_path
- video_file = mock.Mock()
- # Note: we purposely use weird width/height values here to ensure that
- # they are different from the default size
- video_file.width = 542
- video_file.height = 320
- video_file.filename = self.input_path
- video_file.container = '#container_name#'
- video_file.audio_only = False
- cmdline_args = converter_obj.get_arguments(video_file, output_path)
- return vars(make_ffmpeg_arg_parser().parse_args(cmdline_args))
- parser = make_ffmpeg_arg_parser()
- args = vars(parser.parse_args(cmdline_args))
- return dict((k, args[k]) for k in args
- if args[k] != parser.get_default(k))
- def check_ffmpeg_arguments(self, converter_id, correct_arguments):
- """Check the arguments of a ffmpeg-based converter."""
- converter = self.manager.converters[converter_id]
- self.assertEquals(converter.get_executable(),
- settings.get_ffmpeg_executable_path())
- self.assertEquals(self.get_converter_arguments(converter),
- correct_arguments)
- def check_size(self, converter_id, width, height):
- converter = self.manager.converters[converter_id]
- self.assertEquals(converter.width, width)
- self.assertEquals(converter.height, height)
- self.assertEquals(converter.dont_upsize, True)
- self.assertEquals(converter.audio_only, False)
- def check_uses_input_size(self, converter_id):
- converter = self.manager.converters[converter_id]
- self.assertEquals(converter.width, None)
- self.assertEquals(converter.height, None)
- self.assertEquals(converter.dont_upsize, True)
- self.assertEquals(converter.audio_only, False)
- def check_audio_only(self, converter_id):
- converter = self.manager.converters[converter_id]
- self.assertEquals(converter.audio_only, True)
- def test_all_converters_checked(self):
- for converter_id in self.manager.converters.keys():
- if not hasattr(self, "test_%s" % converter_id):
- raise AssertionError("No test for converter: %s" %
- converter_id)
- def test_droid(self):
- self.check_ffmpeg_arguments('droid', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('droid', 854, 480)
- def test_proresingest720p(self):
- self.check_ffmpeg_arguments('proresingest720p', {
- 'acodec': 'pcm_s16be',
- 'ar': '48000',
- 'f': 'mov',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'profile:v': '2',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'prores',
- })
- self.check_size('proresingest720p', 1080, 720)
- def test_droidx2(self):
- self.check_ffmpeg_arguments('droidx2', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('droidx2', 1280, 720)
- def test_sensation(self):
- self.check_ffmpeg_arguments('sensation', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('sensation', 960, 540)
- def test_avcintra1080p(self):
- self.check_ffmpeg_arguments('avcintra1080p', {
- 'acodec': 'pcm_s16be',
- 'ar': '48000',
- 'f': 'mov',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'profile:v': '2',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'prores',
- })
- self.check_size('avcintra1080p', 1920, 1080)
- def test_mp4(self):
- self.check_ffmpeg_arguments('mp4', {
- 'ab': '128k',
- 'acodec': 'aac',
- 'crf': '22',
- 'f': 'mp4',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'preset': 'slow',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'libx264',
- 'map_metadata': '-1',
- })
- self.check_uses_input_size('mp4')
- def test_ipodtouch4(self):
- self.check_ffmpeg_arguments('ipodtouch4', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('ipodtouch4', 960, 640)
- def test_mp3(self):
- self.check_ffmpeg_arguments('mp3', {
- 'ac': '2',
- 'f': 'mp3',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'strict': 'experimental',
- })
- self.check_audio_only('mp3')
- def test_proresingest1080p(self):
- self.check_ffmpeg_arguments('proresingest1080p', {
- 'acodec': 'pcm_s16be',
- 'ar': '48000',
- 'f': 'mov',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'profile:v': '2',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'prores',
- })
- self.check_size('proresingest1080p', 1920, 1080)
- def test_galaxyinfuse(self):
- self.check_ffmpeg_arguments('galaxyinfuse', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxyinfuse', 1280, 800)
- def test_ipodnanoclassic(self):
- self.check_ffmpeg_arguments('ipodnanoclassic', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('ipodnanoclassic', 480, 320)
- def test_oggvorbis(self):
- self.check_ffmpeg_arguments('oggvorbis', {
- 'acodec': 'libvorbis',
- 'aq': '60',
- 'f': 'ogg',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'strict': 'experimental',
- 'vn': True,
- })
- self.check_audio_only('oggvorbis')
- def test_wildfire(self):
- self.check_ffmpeg_arguments('wildfire', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '320x188',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('wildfire', 320, 240)
- def test_ipad(self):
- self.check_ffmpeg_arguments('ipad', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('ipad', 1024, 768)
- def test_galaxyadmire(self):
- self.check_ffmpeg_arguments('galaxyadmire', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxyadmire', 480, 320)
- def test_droidincredible(self):
- self.check_ffmpeg_arguments('droidincredible', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('droidincredible', 800, 480)
- def test_sameformat(self):
- self.check_ffmpeg_arguments('sameformat', {
- 'acodec': 'copy',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'copy',
- 'f': '#container_name#',
- })
- self.check_uses_input_size('sameformat')
- def test_zio(self):
- self.check_ffmpeg_arguments('zio', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('zio', 800, 480)
- def test_galaxycharge(self):
- self.check_ffmpeg_arguments('galaxycharge', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxycharge', 800, 480)
- def test_large1080p(self):
- self.check_ffmpeg_arguments('large1080p', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('large1080p', 1920, 1080)
- def test_appletv(self):
- self.check_ffmpeg_arguments('appletv', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('appletv', 1280, 720)
- def test_playstationportable(self):
- self.check_ffmpeg_arguments('playstationportable', {
- 'ab': '64000',
- 'ar': '24000',
- 'b': '512000',
- 'f': 'psp',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'r': '29.97',
- 's': '320x188',
- 'strict': 'experimental',
- })
- self.check_size('playstationportable', 320, 240)
- def test_rezound(self):
- self.check_ffmpeg_arguments('rezound', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('rezound', 1280, 720)
- def test_large720p(self):
- self.check_ffmpeg_arguments('large720p', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('large720p', 1280, 720)
- def test_iphone(self):
- self.check_ffmpeg_arguments('iphone', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('iphone', 640, 480)
- def test_galaxyy(self):
- self.check_ffmpeg_arguments('galaxyy', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '320x188',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxyy', 320, 240)
- def test_galaxytab101(self):
- self.check_ffmpeg_arguments('galaxytab101', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxytab101', 1280, 800)
- def test_galaxynexus(self):
- self.check_ffmpeg_arguments('galaxynexus', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxynexus', 1280, 720)
- def test_galaxysiii(self):
- self.check_ffmpeg_arguments('galaxysiii', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxysiii', 1280, 720)
- def test_desire(self):
- self.check_ffmpeg_arguments('desire', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('desire', 800, 480)
- def test_galaxynoteii(self):
- self.check_ffmpeg_arguments('galaxynoteii', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxynoteii', 1920, 1080)
- def test_thunderbolt(self):
- self.check_ffmpeg_arguments('thunderbolt', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('thunderbolt', 800, 480)
- def test_xoom(self):
- self.check_ffmpeg_arguments('xoom', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('xoom', 1280, 800)
- def test_normal800x480(self):
- self.check_ffmpeg_arguments('normal800x480', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('normal800x480', 800, 480)
- def test_galaxyepic(self):
- self.check_ffmpeg_arguments('galaxyepic', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxyepic', 800, 480)
- def test_avcintra720p(self):
- self.check_ffmpeg_arguments('avcintra720p', {
- 'acodec': 'pcm_s16be',
- 'ar': '48000',
- 'f': 'mov',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'profile:v': '2',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'prores',
- })
- self.check_size('avcintra720p', 1080, 720)
- def test_dnxhd720p(self):
- self.check_ffmpeg_arguments('dnxhd720p', {
- 'acodec': 'pcm_s16be',
- 'ar': '48000',
- 'b:v': '175M',
- 'f': 'mov',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'r': '23.976',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'dnxhd',
- })
- self.check_size('dnxhd720p', 1080, 720)
- def test_iphone5(self):
- self.check_ffmpeg_arguments('iphone5', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('iphone5', 1920, 1080)
- def test_webmvp8(self):
- self.check_ffmpeg_arguments('webmvp8', {
- 'acodec': 'libvorbis',
- 'vcodec': 'libvpx',
- 'b:v': '0',
- 'g': '240',
- 'crf': '32',
- 'f': 'webm',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'quality': 'good',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '4',
- 'map_metadata': '-1',
- })
- self.check_uses_input_size('webmvp8')
- def test_webm1080pvp8(self):
- self.check_ffmpeg_arguments('webm1080pvp8', {
- 'ab': '128k',
- 'acodec': 'libvorbis',
- 'ar': '44100',
- 'b:v': '4M',
- 'cpu_used': '0',
- 'deadline': 'good',
- 'f': 'webm',
- 'g': '120',
- 'i': self.input_path,
- 'lag_in_frames': '23',
- 'map_metadata': '-1',
- 'output_file': self.output_path,
- 'qmax': '51',
- 'qmin': '11',
- 's': '542x320',
- 'slices': '4',
- 'strict': 'experimental',
- 'vcodec': 'libvpx',
- 'vprofile': '0'
- })
- self.check_size('webm1080pvp8', 1920, 1080)
- def test_webm720pvp8(self):
- self.check_ffmpeg_arguments('webm720pvp8', {
- 'ab': '112k',
- 'acodec': 'libvorbis',
- 'ar': '44100',
- 'b:v': '2M',
- 'cpu_used': '0',
- 'deadline': 'good',
- 'f': 'webm',
- 'g': '120',
- 'i': self.input_path,
- 'lag_in_frames': '16',
- 'output_file': self.output_path,
- 'qmax': '51',
- 'qmin': '11',
- 's': '542x320',
- 'slices': '4',
- 'strict': 'experimental',
- 'vcodec': 'libvpx',
- 'vprofile': '0',
- 'map_metadata': '-1',
- })
- self.check_size('webm720pvp8', 1080, 720)
- def test_webm480pvp8(self):
- self.check_ffmpeg_arguments('webm480pvp8', {
- 'ab': '112k',
- 'acodec': 'libvorbis',
- 'ar': '44100',
- 'b:v': '768k',
- 'cpu_used': '0',
- 'deadline': 'good',
- 'f': 'webm',
- 'g': '120',
- 'i': self.input_path,
- 'lag_in_frames': '16',
- 'output_file': self.output_path,
- 'qmax': '53',
- 'qmin': '0',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'libvpx',
- 'vprofile': '0',
- 'map_metadata': '-1',
- })
- self.check_size('webm480pvp8', 720, 480)
- def test_webmvp9(self):
- self.check_ffmpeg_arguments('webmvp9', {
- 'acodec': 'libopus',
- 'vcodec': 'libvpx-vp9',
- 'b:v': '0',
- 'g': '240',
- 'crf': '32',
- 'f': 'webm',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'quality': 'good',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '4',
- 'map_metadata': '-1',
- })
- self.check_uses_input_size('webmvp9')
- def test_webm1080pvp9(self):
- self.check_ffmpeg_arguments('webm1080pvp9', {
- 'ab': '128k',
- 'acodec': 'libopus',
- 'b:v': '4M',
- 'cpu_used': '0',
- 'deadline': 'good',
- 'f': 'webm',
- 'g': '120',
- 'i': self.input_path,
- 'lag_in_frames': '23',
- 'map_metadata': '-1',
- 'output_file': self.output_path,
- 'qmax': '51',
- 'qmin': '11',
- 's': '542x320',
- 'slices': '4',
- 'strict': 'experimental',
- 'vcodec': 'libvpx-vp9',
- 'vprofile': '0'
- })
- self.check_size('webm1080pvp9', 1920, 1080)
- def test_webm720pvp9(self):
- self.check_ffmpeg_arguments('webm720pvp9', {
- 'ab': '112k',
- 'acodec': 'libopus',
- 'b:v': '2M',
- 'cpu_used': '0',
- 'deadline': 'good',
- 'f': 'webm',
- 'g': '120',
- 'i': self.input_path,
- 'lag_in_frames': '16',
- 'output_file': self.output_path,
- 'qmax': '51',
- 'qmin': '11',
- 's': '542x320',
- 'slices': '4',
- 'strict': 'experimental',
- 'vcodec': 'libvpx-vp9',
- 'vprofile': '0',
- 'map_metadata': '-1',
- })
- self.check_size('webm720pvp9', 1080, 720)
- def test_webm480pvp9(self):
- self.check_ffmpeg_arguments('webm480pvp9', {
- 'ab': '112k',
- 'acodec': 'libopus',
- 'b:v': '768k',
- 'cpu_used': '0',
- 'deadline': 'good',
- 'f': 'webm',
- 'g': '120',
- 'i': self.input_path,
- 'lag_in_frames': '16',
- 'output_file': self.output_path,
- 'qmax': '53',
- 'qmin': '0',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'libvpx-vp9',
- 'vprofile': '0',
- 'map_metadata': '-1',
- })
- self.check_size('webm480pvp9', 720, 480)
- def test_galaxymini(self):
- self.check_ffmpeg_arguments('galaxymini', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '320x188',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxymini', 320, 240)
- def test_onex(self):
- self.check_ffmpeg_arguments('onex', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('onex', 1280, 720)
- def test_oggtheora(self):
- self.check_ffmpeg_arguments('oggtheora', {
- 'acodec': 'libvorbis',
- 'f': 'ogg',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'libtheora',
- 'qscale:v': '7',
- 'qscale:a': '5',
- 'map_metadata': '-1',
- })
- self.check_uses_input_size('oggtheora')
- def test_ipad3(self):
- self.check_ffmpeg_arguments('ipad3', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('ipad3', 1920, 1080)
- def test_galaxyssiisplus(self):
- self.check_ffmpeg_arguments('galaxyssiisplus', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxyssiisplus', 800, 480)
- def test_kindlefire(self):
- self.check_ffmpeg_arguments('kindlefire', {
- 'ab': '96k',
- 'acodec': 'aac',
- 'crf': '22',
- 'f': 'mp4',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'preset': 'slow',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'libx264',
- })
- self.check_size('kindlefire', 1224, 600)
- def test_galaxyace(self):
- self.check_ffmpeg_arguments('galaxyace', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxyace', 480, 320)
- def test_dnxhd1080p(self):
- self.check_ffmpeg_arguments('dnxhd1080p', {
- 'acodec': 'pcm_s16be',
- 'ar': '48000',
- 'b:v': '175M',
- 'f': 'mov',
- 'i': self.input_path,
- 'output_file': self.output_path,
- 'r': '23.976',
- 's': '542x320',
- 'strict': 'experimental',
- 'vcodec': 'dnxhd',
- })
- self.check_size('dnxhd1080p', 1920, 1080)
- def test_small480x320(self):
- self.check_ffmpeg_arguments('small480x320', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('small480x320', 480, 320)
- def test_iphone4(self):
- self.check_ffmpeg_arguments('iphone4', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('iphone4', 960, 640)
- def test_razr(self):
- self.check_ffmpeg_arguments('razr', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('razr', 960, 540)
- def test_ipodtouch(self):
- self.check_ffmpeg_arguments('ipodtouch', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('ipodtouch', 640, 480)
- def test_galaxytab(self):
- self.check_ffmpeg_arguments('galaxytab', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('galaxytab', 1024, 600)
- def test_appleuniversal(self):
- self.check_ffmpeg_arguments('appleuniversal', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vb': '1200k',
- 'vcodec': 'libx264',
- })
- self.check_size('appleuniversal', 1280, 720)
- def test_evo4g(self):
- self.check_ffmpeg_arguments('evo4g', {
- 'ab': '160k',
- 'ac': '2',
- 'acodec': 'aac',
- 'bufsize': '10000000',
- 'f': 'mp4',
- 'i': self.input_path,
- 'level': '30',
- 'maxrate': '10000000',
- 'output_file': self.output_path,
- 'preset': 'slow',
- 'profile:v': 'baseline',
- 's': '542x320',
- 'strict': 'experimental',
- 'threads': '0',
- 'vcodec': 'libx264',
- })
- self.check_size('evo4g', 800, 480)
|