test_converter.py 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  1. import argparse
  2. import os.path
  3. from lvc.video import VideoFile
  4. from lvc import converter
  5. from lvc import settings
  6. import base
  7. import mock
  8. def make_ffmpeg_arg_parser():
  9. """Make an args.ArgumentParser for ffmpeg args that we use
  10. """
  11. parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)
  12. # command line options that require an argument after
  13. arguments = [
  14. "-ab",
  15. "-ac",
  16. "-acodec",
  17. "-aq",
  18. "-ar",
  19. "-b",
  20. "-b:v",
  21. "-bufsize",
  22. "-crf",
  23. "-cpu-used",
  24. "-deadline",
  25. "-f",
  26. '-g',
  27. "-i",
  28. "-lag-in-frames",
  29. "-level",
  30. "-map_metadata",
  31. "-maxrate",
  32. "-preset",
  33. "-profile:v",
  34. "-qscale:a",
  35. "-qscale:v",
  36. "-quality",
  37. "-r",
  38. "-s",
  39. "-slices",
  40. "-strict",
  41. "-threads",
  42. "-qmin",
  43. "-qmax",
  44. "-vb",
  45. "-vcodec",
  46. "-vprofile",
  47. ]
  48. # arguments that set flags
  49. flags = [
  50. '-vn',
  51. ]
  52. for name in arguments:
  53. parser.add_argument(name)
  54. for name in flags:
  55. parser.add_argument(name, action='store_const', const=True)
  56. parser.add_argument("output_file")
  57. return parser
  58. class TestConverterInfo(converter.ConverterInfo):
  59. media_type = 'video'
  60. extension = 'test'
  61. bitrate = 10000
  62. def get_executable(self):
  63. return '/bin/true'
  64. def get_arguments(self, video, output):
  65. return [video.filename, output]
  66. def process_status_line(self, line):
  67. return {'finished': True}
  68. TEST_CONVERTER = TestConverterInfo('Test Converter')
  69. class ConverterManagerTest(base.Test):
  70. def setUp(self):
  71. base.Test.setUp(self)
  72. self.manager = converter.ConverterManager()
  73. def test_startup(self):
  74. self.manager.startup()
  75. self.assertTrue(self.manager.converters)
  76. def test_add_converter(self):
  77. self.manager.add_converter(TEST_CONVERTER)
  78. self.assertEqual(len(self.manager.converters), 1)
  79. def test_list_converters(self):
  80. self.manager.add_converter(TEST_CONVERTER)
  81. self.assertEqual(list(self.manager.list_converters()),
  82. [TEST_CONVERTER])
  83. def test_get_by_id(self):
  84. self.manager.add_converter(TEST_CONVERTER)
  85. self.assertEqual(self.manager.get_by_id('testconverter'),
  86. TEST_CONVERTER)
  87. self.assertRaises(KeyError, self.manager.get_by_id,
  88. 'doesnotexist')
  89. class ConverterInfoTest(base.Test):
  90. def setUp(self):
  91. base.Test.setUp(self)
  92. self.converter_info = TEST_CONVERTER
  93. self.video = VideoFile(os.path.join(self.testdata_dir, 'mp4-0.mp4'))
  94. def test_identifer(self):
  95. self.assertEqual(self.converter_info.identifier,
  96. 'testconverter')
  97. def test_get_output_filename(self):
  98. self.assertEqual(self.converter_info.get_output_filename(self.video),
  99. 'mp4-0_testconverter.test')
  100. def test_get_output_size_guess(self):
  101. self.assertEqual(self.converter_info.get_output_size_guess(self.video),
  102. self.video.duration * self.converter_info.bitrate / 8)
  103. class ConverterInfoTestMixin(object):
  104. def setUp(self):
  105. self.video = VideoFile(os.path.join(self.testdata_dir, 'mp4-0.mp4'))
  106. def assertStatusLineOutput(self, line, **output):
  107. if not output:
  108. output = None
  109. self.assertEqual(self.converter_info.process_status_line(self.video,
  110. line),
  111. output)
  112. def test_get_executable(self):
  113. self.assertTrue(self.converter_info.get_executable())
  114. def test_get_arguments(self):
  115. output = os.path.join(self.testdata_dir, 'output.mp4')
  116. arguments = self.converter_info.get_arguments(self.video, output)
  117. self.assertTrue(arguments)
  118. self.assertTrue(self.video.filename in arguments)
  119. self.assertTrue(output in arguments)
  120. class FFmpegConverterInfoTest(ConverterInfoTestMixin, base.Test):
  121. def setUp(self):
  122. base.Test.setUp(self)
  123. ConverterInfoTestMixin.setUp(self)
  124. self.converter_info = converter.FFmpegConverterInfo('FFmpeg Test',
  125. 1024, 768)
  126. self.converter_info.parameters = '{ssize}'
  127. def run_get_target_size(self, (src_width, src_height),
  128. (dest_width, dest_height),
  129. dont_upsize=True):
  130. """Create a converter run get_target_size() on a video.
  131. """
  132. mock_video = mock.Mock(width=src_width, height=src_height)
  133. converter_info = converter.FFmpegConverterInfo(
  134. 'FFmpeg Test', dest_width, dest_height)
  135. converter_info.dont_upsize = dont_upsize
  136. return converter_info.get_target_size(mock_video)
  137. def test_get_target_size(self):
  138. self.assertEqual(self.run_get_target_size((1024, 768), (640, 480)),
  139. (640, 480))
  140. def test_get_target_size_rescale(self):
  141. # Test get_target_size() rescaling an image. It should ensure that
  142. # both dimensions fit inside the target image, and that the aspect
  143. # ratio is unchanged.
  144. self.assertEqual(self.run_get_target_size((1024, 768), (800, 500)),
  145. (666, 500))
  146. def test_get_target_size_dont_upsize(self):
  147. # Test that get_target_size only upsizes when dont_upsize is True
  148. self.assertEqual(self.run_get_target_size((640, 480), (800, 600)),
  149. (640, 480))
  150. self.assertEqual(self.run_get_target_size((640, 480), (800, 600),
  151. dont_upsize=False),
  152. (800, 600))
  153. def test_process_status_line_nothing(self):
  154. self.assertStatusLineOutput(
  155. ' built on Mar 31 2012 09:58:16 with gcc 4.6.3')
  156. def test_process_status_line_duration(self):
  157. self.assertStatusLineOutput(
  158. ' Duration: 00:00:01.07, start: 0.000000, bitrate: 128 kb/s',
  159. duration=1.07)
  160. def test_process_status_line_progress(self):
  161. self.assertStatusLineOutput(
  162. 'size= 2697kB time=00:02:52.59 bitrate= 128.0kbits/s ',
  163. progress=172.59)
  164. def test_process_status_line_progress_with_frame(self):
  165. self.assertStatusLineOutput(
  166. 'frame= 257 fps= 45 q=27.0 size= 1033kB time=00:00:08.70 '
  167. 'bitrate= 971.4kbits/s ',
  168. progress=8.7)
  169. def test_process_status_line_finished(self):
  170. self.assertStatusLineOutput(
  171. 'frame=16238 fps= 37 q=-1.0 Lsize= 110266kB time=00:11:16.50 '
  172. 'bitrate=1335.3kbits/s dup=16 drop=0',
  173. finished=True)
  174. def test_process_status_line_error(self):
  175. line = ('Error while opening encoder for output stream #0:1 - '
  176. 'maybe incorrect parameters such as bit_rate, rate, width or '
  177. 'height')
  178. self.assertStatusLineOutput(line,
  179. finished=True,
  180. error=line)
  181. def test_process_status_line_unknown(self):
  182. # XXX haven't actually seen this line
  183. line = 'Unknown error'
  184. self.assertStatusLineOutput(line,
  185. finished=True,
  186. error=line)
  187. def test_process_status_line_error_decoding(self):
  188. # XXX haven't actually seen this line
  189. line = 'Error while decoding stream: something'
  190. self.assertStatusLineOutput(line)
  191. class TestConverterDefinitions(base.Test):
  192. def setUp(self):
  193. base.Test.setUp(self)
  194. self.manager = converter.ConverterManager()
  195. self.manager.startup()
  196. self.input_path = os.path.join(self.testdata_dir, 'mp4-0.mp4')
  197. self.output_path = os.path.join(self.testdata_dir, 'output.mp4')
  198. def get_converter_arguments(self, converter_obj):
  199. """Given a converter, get the arguments to that converter
  200. :returns: dict of arguments that were set
  201. """
  202. output_path = self.output_path
  203. video_file = mock.Mock()
  204. # Note: we purposely use weird width/height values here to ensure that
  205. # they are different from the default size
  206. video_file.width = 542
  207. video_file.height = 320
  208. video_file.filename = self.input_path
  209. video_file.container = '#container_name#'
  210. video_file.audio_only = False
  211. cmdline_args = converter_obj.get_arguments(video_file, output_path)
  212. return vars(make_ffmpeg_arg_parser().parse_args(cmdline_args))
  213. parser = make_ffmpeg_arg_parser()
  214. args = vars(parser.parse_args(cmdline_args))
  215. return dict((k, args[k]) for k in args
  216. if args[k] != parser.get_default(k))
  217. def check_ffmpeg_arguments(self, converter_id, correct_arguments):
  218. """Check the arguments of a ffmpeg-based converter."""
  219. converter = self.manager.converters[converter_id]
  220. self.assertEquals(converter.get_executable(),
  221. settings.get_ffmpeg_executable_path())
  222. self.assertEquals(self.get_converter_arguments(converter),
  223. correct_arguments)
  224. def check_size(self, converter_id, width, height):
  225. converter = self.manager.converters[converter_id]
  226. self.assertEquals(converter.width, width)
  227. self.assertEquals(converter.height, height)
  228. self.assertEquals(converter.dont_upsize, True)
  229. self.assertEquals(converter.audio_only, False)
  230. def check_uses_input_size(self, converter_id):
  231. converter = self.manager.converters[converter_id]
  232. self.assertEquals(converter.width, None)
  233. self.assertEquals(converter.height, None)
  234. self.assertEquals(converter.dont_upsize, True)
  235. self.assertEquals(converter.audio_only, False)
  236. def check_audio_only(self, converter_id):
  237. converter = self.manager.converters[converter_id]
  238. self.assertEquals(converter.audio_only, True)
  239. def test_all_converters_checked(self):
  240. for converter_id in self.manager.converters.keys():
  241. if not hasattr(self, "test_%s" % converter_id):
  242. raise AssertionError("No test for converter: %s" %
  243. converter_id)
  244. def test_droid(self):
  245. self.check_ffmpeg_arguments('droid', {
  246. 'ab': '160k',
  247. 'ac': '2',
  248. 'acodec': 'aac',
  249. 'bufsize': '10000000',
  250. 'f': 'mp4',
  251. 'i': self.input_path,
  252. 'level': '30',
  253. 'maxrate': '10000000',
  254. 'output_file': self.output_path,
  255. 'preset': 'slow',
  256. 'profile:v': 'baseline',
  257. 's': '542x320',
  258. 'strict': 'experimental',
  259. 'threads': '0',
  260. 'vcodec': 'libx264',
  261. })
  262. self.check_size('droid', 854, 480)
  263. def test_proresingest720p(self):
  264. self.check_ffmpeg_arguments('proresingest720p', {
  265. 'acodec': 'pcm_s16be',
  266. 'ar': '48000',
  267. 'f': 'mov',
  268. 'i': self.input_path,
  269. 'output_file': self.output_path,
  270. 'profile:v': '2',
  271. 's': '542x320',
  272. 'strict': 'experimental',
  273. 'vcodec': 'prores',
  274. })
  275. self.check_size('proresingest720p', 1080, 720)
  276. def test_droidx2(self):
  277. self.check_ffmpeg_arguments('droidx2', {
  278. 'ab': '160k',
  279. 'ac': '2',
  280. 'acodec': 'aac',
  281. 'bufsize': '10000000',
  282. 'f': 'mp4',
  283. 'i': self.input_path,
  284. 'level': '30',
  285. 'maxrate': '10000000',
  286. 'output_file': self.output_path,
  287. 'preset': 'slow',
  288. 'profile:v': 'baseline',
  289. 's': '542x320',
  290. 'strict': 'experimental',
  291. 'threads': '0',
  292. 'vcodec': 'libx264',
  293. })
  294. self.check_size('droidx2', 1280, 720)
  295. def test_sensation(self):
  296. self.check_ffmpeg_arguments('sensation', {
  297. 'ab': '160k',
  298. 'ac': '2',
  299. 'acodec': 'aac',
  300. 'bufsize': '10000000',
  301. 'f': 'mp4',
  302. 'i': self.input_path,
  303. 'level': '30',
  304. 'maxrate': '10000000',
  305. 'output_file': self.output_path,
  306. 'preset': 'slow',
  307. 'profile:v': 'baseline',
  308. 's': '542x320',
  309. 'strict': 'experimental',
  310. 'threads': '0',
  311. 'vcodec': 'libx264',
  312. })
  313. self.check_size('sensation', 960, 540)
  314. def test_avcintra1080p(self):
  315. self.check_ffmpeg_arguments('avcintra1080p', {
  316. 'acodec': 'pcm_s16be',
  317. 'ar': '48000',
  318. 'f': 'mov',
  319. 'i': self.input_path,
  320. 'output_file': self.output_path,
  321. 'profile:v': '2',
  322. 's': '542x320',
  323. 'strict': 'experimental',
  324. 'vcodec': 'prores',
  325. })
  326. self.check_size('avcintra1080p', 1920, 1080)
  327. def test_mp4(self):
  328. self.check_ffmpeg_arguments('mp4', {
  329. 'ab': '128k',
  330. 'acodec': 'aac',
  331. 'crf': '22',
  332. 'f': 'mp4',
  333. 'i': self.input_path,
  334. 'output_file': self.output_path,
  335. 'preset': 'slow',
  336. 's': '542x320',
  337. 'strict': 'experimental',
  338. 'vcodec': 'libx264',
  339. 'map_metadata': '-1',
  340. })
  341. self.check_uses_input_size('mp4')
  342. def test_ipodtouch4(self):
  343. self.check_ffmpeg_arguments('ipodtouch4', {
  344. 'ab': '160k',
  345. 'ac': '2',
  346. 'acodec': 'aac',
  347. 'bufsize': '10000000',
  348. 'f': 'mp4',
  349. 'i': self.input_path,
  350. 'level': '30',
  351. 'maxrate': '10000000',
  352. 'output_file': self.output_path,
  353. 'preset': 'slow',
  354. 'profile:v': 'baseline',
  355. 's': '542x320',
  356. 'strict': 'experimental',
  357. 'threads': '0',
  358. 'vb': '1200k',
  359. 'vcodec': 'libx264',
  360. })
  361. self.check_size('ipodtouch4', 960, 640)
  362. def test_mp3(self):
  363. self.check_ffmpeg_arguments('mp3', {
  364. 'ac': '2',
  365. 'f': 'mp3',
  366. 'i': self.input_path,
  367. 'output_file': self.output_path,
  368. 'strict': 'experimental',
  369. })
  370. self.check_audio_only('mp3')
  371. def test_proresingest1080p(self):
  372. self.check_ffmpeg_arguments('proresingest1080p', {
  373. 'acodec': 'pcm_s16be',
  374. 'ar': '48000',
  375. 'f': 'mov',
  376. 'i': self.input_path,
  377. 'output_file': self.output_path,
  378. 'profile:v': '2',
  379. 's': '542x320',
  380. 'strict': 'experimental',
  381. 'vcodec': 'prores',
  382. })
  383. self.check_size('proresingest1080p', 1920, 1080)
  384. def test_galaxyinfuse(self):
  385. self.check_ffmpeg_arguments('galaxyinfuse', {
  386. 'ab': '160k',
  387. 'ac': '2',
  388. 'acodec': 'aac',
  389. 'bufsize': '10000000',
  390. 'f': 'mp4',
  391. 'i': self.input_path,
  392. 'level': '30',
  393. 'maxrate': '10000000',
  394. 'output_file': self.output_path,
  395. 'preset': 'slow',
  396. 'profile:v': 'baseline',
  397. 's': '542x320',
  398. 'strict': 'experimental',
  399. 'threads': '0',
  400. 'vcodec': 'libx264',
  401. })
  402. self.check_size('galaxyinfuse', 1280, 800)
  403. def test_ipodnanoclassic(self):
  404. self.check_ffmpeg_arguments('ipodnanoclassic', {
  405. 'ab': '160k',
  406. 'ac': '2',
  407. 'acodec': 'aac',
  408. 'bufsize': '10000000',
  409. 'f': 'mp4',
  410. 'i': self.input_path,
  411. 'level': '30',
  412. 'maxrate': '10000000',
  413. 'output_file': self.output_path,
  414. 'preset': 'slow',
  415. 'profile:v': 'baseline',
  416. 's': '542x320',
  417. 'strict': 'experimental',
  418. 'threads': '0',
  419. 'vb': '1200k',
  420. 'vcodec': 'libx264',
  421. })
  422. self.check_size('ipodnanoclassic', 480, 320)
  423. def test_oggvorbis(self):
  424. self.check_ffmpeg_arguments('oggvorbis', {
  425. 'acodec': 'libvorbis',
  426. 'aq': '60',
  427. 'f': 'ogg',
  428. 'i': self.input_path,
  429. 'output_file': self.output_path,
  430. 'strict': 'experimental',
  431. 'vn': True,
  432. })
  433. self.check_audio_only('oggvorbis')
  434. def test_wildfire(self):
  435. self.check_ffmpeg_arguments('wildfire', {
  436. 'ab': '160k',
  437. 'ac': '2',
  438. 'acodec': 'aac',
  439. 'bufsize': '10000000',
  440. 'f': 'mp4',
  441. 'i': self.input_path,
  442. 'level': '30',
  443. 'maxrate': '10000000',
  444. 'output_file': self.output_path,
  445. 'preset': 'slow',
  446. 'profile:v': 'baseline',
  447. 's': '320x188',
  448. 'strict': 'experimental',
  449. 'threads': '0',
  450. 'vcodec': 'libx264',
  451. })
  452. self.check_size('wildfire', 320, 240)
  453. def test_ipad(self):
  454. self.check_ffmpeg_arguments('ipad', {
  455. 'ab': '160k',
  456. 'ac': '2',
  457. 'acodec': 'aac',
  458. 'bufsize': '10000000',
  459. 'f': 'mp4',
  460. 'i': self.input_path,
  461. 'level': '30',
  462. 'maxrate': '10000000',
  463. 'output_file': self.output_path,
  464. 'preset': 'slow',
  465. 'profile:v': 'baseline',
  466. 's': '542x320',
  467. 'strict': 'experimental',
  468. 'threads': '0',
  469. 'vb': '1200k',
  470. 'vcodec': 'libx264',
  471. })
  472. self.check_size('ipad', 1024, 768)
  473. def test_galaxyadmire(self):
  474. self.check_ffmpeg_arguments('galaxyadmire', {
  475. 'ab': '160k',
  476. 'ac': '2',
  477. 'acodec': 'aac',
  478. 'bufsize': '10000000',
  479. 'f': 'mp4',
  480. 'i': self.input_path,
  481. 'level': '30',
  482. 'maxrate': '10000000',
  483. 'output_file': self.output_path,
  484. 'preset': 'slow',
  485. 'profile:v': 'baseline',
  486. 's': '542x320',
  487. 'strict': 'experimental',
  488. 'threads': '0',
  489. 'vcodec': 'libx264',
  490. })
  491. self.check_size('galaxyadmire', 480, 320)
  492. def test_droidincredible(self):
  493. self.check_ffmpeg_arguments('droidincredible', {
  494. 'ab': '160k',
  495. 'ac': '2',
  496. 'acodec': 'aac',
  497. 'bufsize': '10000000',
  498. 'f': 'mp4',
  499. 'i': self.input_path,
  500. 'level': '30',
  501. 'maxrate': '10000000',
  502. 'output_file': self.output_path,
  503. 'preset': 'slow',
  504. 'profile:v': 'baseline',
  505. 's': '542x320',
  506. 'strict': 'experimental',
  507. 'threads': '0',
  508. 'vcodec': 'libx264',
  509. })
  510. self.check_size('droidincredible', 800, 480)
  511. def test_sameformat(self):
  512. self.check_ffmpeg_arguments('sameformat', {
  513. 'acodec': 'copy',
  514. 'i': self.input_path,
  515. 'output_file': self.output_path,
  516. 's': '542x320',
  517. 'strict': 'experimental',
  518. 'vcodec': 'copy',
  519. 'f': '#container_name#',
  520. })
  521. self.check_uses_input_size('sameformat')
  522. def test_zio(self):
  523. self.check_ffmpeg_arguments('zio', {
  524. 'ab': '160k',
  525. 'ac': '2',
  526. 'acodec': 'aac',
  527. 'bufsize': '10000000',
  528. 'f': 'mp4',
  529. 'i': self.input_path,
  530. 'level': '30',
  531. 'maxrate': '10000000',
  532. 'output_file': self.output_path,
  533. 'preset': 'slow',
  534. 'profile:v': 'baseline',
  535. 's': '542x320',
  536. 'strict': 'experimental',
  537. 'threads': '0',
  538. 'vcodec': 'libx264',
  539. })
  540. self.check_size('zio', 800, 480)
  541. def test_galaxycharge(self):
  542. self.check_ffmpeg_arguments('galaxycharge', {
  543. 'ab': '160k',
  544. 'ac': '2',
  545. 'acodec': 'aac',
  546. 'bufsize': '10000000',
  547. 'f': 'mp4',
  548. 'i': self.input_path,
  549. 'level': '30',
  550. 'maxrate': '10000000',
  551. 'output_file': self.output_path,
  552. 'preset': 'slow',
  553. 'profile:v': 'baseline',
  554. 's': '542x320',
  555. 'strict': 'experimental',
  556. 'threads': '0',
  557. 'vcodec': 'libx264',
  558. })
  559. self.check_size('galaxycharge', 800, 480)
  560. def test_large1080p(self):
  561. self.check_ffmpeg_arguments('large1080p', {
  562. 'ab': '160k',
  563. 'ac': '2',
  564. 'acodec': 'aac',
  565. 'bufsize': '10000000',
  566. 'f': 'mp4',
  567. 'i': self.input_path,
  568. 'level': '30',
  569. 'maxrate': '10000000',
  570. 'output_file': self.output_path,
  571. 'preset': 'slow',
  572. 'profile:v': 'baseline',
  573. 's': '542x320',
  574. 'strict': 'experimental',
  575. 'threads': '0',
  576. 'vcodec': 'libx264',
  577. })
  578. self.check_size('large1080p', 1920, 1080)
  579. def test_appletv(self):
  580. self.check_ffmpeg_arguments('appletv', {
  581. 'ab': '160k',
  582. 'ac': '2',
  583. 'acodec': 'aac',
  584. 'bufsize': '10000000',
  585. 'f': 'mp4',
  586. 'i': self.input_path,
  587. 'level': '30',
  588. 'maxrate': '10000000',
  589. 'output_file': self.output_path,
  590. 'preset': 'slow',
  591. 'profile:v': 'baseline',
  592. 's': '542x320',
  593. 'strict': 'experimental',
  594. 'threads': '0',
  595. 'vb': '1200k',
  596. 'vcodec': 'libx264',
  597. })
  598. self.check_size('appletv', 1280, 720)
  599. def test_playstationportable(self):
  600. self.check_ffmpeg_arguments('playstationportable', {
  601. 'ab': '64000',
  602. 'ar': '24000',
  603. 'b': '512000',
  604. 'f': 'psp',
  605. 'i': self.input_path,
  606. 'output_file': self.output_path,
  607. 'r': '29.97',
  608. 's': '320x188',
  609. 'strict': 'experimental',
  610. })
  611. self.check_size('playstationportable', 320, 240)
  612. def test_rezound(self):
  613. self.check_ffmpeg_arguments('rezound', {
  614. 'ab': '160k',
  615. 'ac': '2',
  616. 'acodec': 'aac',
  617. 'bufsize': '10000000',
  618. 'f': 'mp4',
  619. 'i': self.input_path,
  620. 'level': '30',
  621. 'maxrate': '10000000',
  622. 'output_file': self.output_path,
  623. 'preset': 'slow',
  624. 'profile:v': 'baseline',
  625. 's': '542x320',
  626. 'strict': 'experimental',
  627. 'threads': '0',
  628. 'vcodec': 'libx264',
  629. })
  630. self.check_size('rezound', 1280, 720)
  631. def test_large720p(self):
  632. self.check_ffmpeg_arguments('large720p', {
  633. 'ab': '160k',
  634. 'ac': '2',
  635. 'acodec': 'aac',
  636. 'bufsize': '10000000',
  637. 'f': 'mp4',
  638. 'i': self.input_path,
  639. 'level': '30',
  640. 'maxrate': '10000000',
  641. 'output_file': self.output_path,
  642. 'preset': 'slow',
  643. 'profile:v': 'baseline',
  644. 's': '542x320',
  645. 'strict': 'experimental',
  646. 'threads': '0',
  647. 'vcodec': 'libx264',
  648. })
  649. self.check_size('large720p', 1280, 720)
  650. def test_iphone(self):
  651. self.check_ffmpeg_arguments('iphone', {
  652. 'ab': '160k',
  653. 'ac': '2',
  654. 'acodec': 'aac',
  655. 'bufsize': '10000000',
  656. 'f': 'mp4',
  657. 'i': self.input_path,
  658. 'level': '30',
  659. 'maxrate': '10000000',
  660. 'output_file': self.output_path,
  661. 'preset': 'slow',
  662. 'profile:v': 'baseline',
  663. 's': '542x320',
  664. 'strict': 'experimental',
  665. 'threads': '0',
  666. 'vb': '1200k',
  667. 'vcodec': 'libx264',
  668. })
  669. self.check_size('iphone', 640, 480)
  670. def test_galaxyy(self):
  671. self.check_ffmpeg_arguments('galaxyy', {
  672. 'ab': '160k',
  673. 'ac': '2',
  674. 'acodec': 'aac',
  675. 'bufsize': '10000000',
  676. 'f': 'mp4',
  677. 'i': self.input_path,
  678. 'level': '30',
  679. 'maxrate': '10000000',
  680. 'output_file': self.output_path,
  681. 'preset': 'slow',
  682. 'profile:v': 'baseline',
  683. 's': '320x188',
  684. 'strict': 'experimental',
  685. 'threads': '0',
  686. 'vcodec': 'libx264',
  687. })
  688. self.check_size('galaxyy', 320, 240)
  689. def test_galaxytab101(self):
  690. self.check_ffmpeg_arguments('galaxytab101', {
  691. 'ab': '160k',
  692. 'ac': '2',
  693. 'acodec': 'aac',
  694. 'bufsize': '10000000',
  695. 'f': 'mp4',
  696. 'i': self.input_path,
  697. 'level': '30',
  698. 'maxrate': '10000000',
  699. 'output_file': self.output_path,
  700. 'preset': 'slow',
  701. 'profile:v': 'baseline',
  702. 's': '542x320',
  703. 'strict': 'experimental',
  704. 'threads': '0',
  705. 'vcodec': 'libx264',
  706. })
  707. self.check_size('galaxytab101', 1280, 800)
  708. def test_galaxynexus(self):
  709. self.check_ffmpeg_arguments('galaxynexus', {
  710. 'ab': '160k',
  711. 'ac': '2',
  712. 'acodec': 'aac',
  713. 'bufsize': '10000000',
  714. 'f': 'mp4',
  715. 'i': self.input_path,
  716. 'level': '30',
  717. 'maxrate': '10000000',
  718. 'output_file': self.output_path,
  719. 'preset': 'slow',
  720. 'profile:v': 'baseline',
  721. 's': '542x320',
  722. 'strict': 'experimental',
  723. 'threads': '0',
  724. 'vcodec': 'libx264',
  725. })
  726. self.check_size('galaxynexus', 1280, 720)
  727. def test_galaxysiii(self):
  728. self.check_ffmpeg_arguments('galaxysiii', {
  729. 'ab': '160k',
  730. 'ac': '2',
  731. 'acodec': 'aac',
  732. 'bufsize': '10000000',
  733. 'f': 'mp4',
  734. 'i': self.input_path,
  735. 'level': '30',
  736. 'maxrate': '10000000',
  737. 'output_file': self.output_path,
  738. 'preset': 'slow',
  739. 'profile:v': 'baseline',
  740. 's': '542x320',
  741. 'strict': 'experimental',
  742. 'threads': '0',
  743. 'vcodec': 'libx264',
  744. })
  745. self.check_size('galaxysiii', 1280, 720)
  746. def test_desire(self):
  747. self.check_ffmpeg_arguments('desire', {
  748. 'ab': '160k',
  749. 'ac': '2',
  750. 'acodec': 'aac',
  751. 'bufsize': '10000000',
  752. 'f': 'mp4',
  753. 'i': self.input_path,
  754. 'level': '30',
  755. 'maxrate': '10000000',
  756. 'output_file': self.output_path,
  757. 'preset': 'slow',
  758. 'profile:v': 'baseline',
  759. 's': '542x320',
  760. 'strict': 'experimental',
  761. 'threads': '0',
  762. 'vcodec': 'libx264',
  763. })
  764. self.check_size('desire', 800, 480)
  765. def test_galaxynoteii(self):
  766. self.check_ffmpeg_arguments('galaxynoteii', {
  767. 'ab': '160k',
  768. 'ac': '2',
  769. 'acodec': 'aac',
  770. 'bufsize': '10000000',
  771. 'f': 'mp4',
  772. 'i': self.input_path,
  773. 'level': '30',
  774. 'maxrate': '10000000',
  775. 'output_file': self.output_path,
  776. 'preset': 'slow',
  777. 'profile:v': 'baseline',
  778. 's': '542x320',
  779. 'strict': 'experimental',
  780. 'threads': '0',
  781. 'vcodec': 'libx264',
  782. })
  783. self.check_size('galaxynoteii', 1920, 1080)
  784. def test_thunderbolt(self):
  785. self.check_ffmpeg_arguments('thunderbolt', {
  786. 'ab': '160k',
  787. 'ac': '2',
  788. 'acodec': 'aac',
  789. 'bufsize': '10000000',
  790. 'f': 'mp4',
  791. 'i': self.input_path,
  792. 'level': '30',
  793. 'maxrate': '10000000',
  794. 'output_file': self.output_path,
  795. 'preset': 'slow',
  796. 'profile:v': 'baseline',
  797. 's': '542x320',
  798. 'strict': 'experimental',
  799. 'threads': '0',
  800. 'vcodec': 'libx264',
  801. })
  802. self.check_size('thunderbolt', 800, 480)
  803. def test_xoom(self):
  804. self.check_ffmpeg_arguments('xoom', {
  805. 'ab': '160k',
  806. 'ac': '2',
  807. 'acodec': 'aac',
  808. 'bufsize': '10000000',
  809. 'f': 'mp4',
  810. 'i': self.input_path,
  811. 'level': '30',
  812. 'maxrate': '10000000',
  813. 'output_file': self.output_path,
  814. 'preset': 'slow',
  815. 'profile:v': 'baseline',
  816. 's': '542x320',
  817. 'strict': 'experimental',
  818. 'threads': '0',
  819. 'vcodec': 'libx264',
  820. })
  821. self.check_size('xoom', 1280, 800)
  822. def test_normal800x480(self):
  823. self.check_ffmpeg_arguments('normal800x480', {
  824. 'ab': '160k',
  825. 'ac': '2',
  826. 'acodec': 'aac',
  827. 'bufsize': '10000000',
  828. 'f': 'mp4',
  829. 'i': self.input_path,
  830. 'level': '30',
  831. 'maxrate': '10000000',
  832. 'output_file': self.output_path,
  833. 'preset': 'slow',
  834. 'profile:v': 'baseline',
  835. 's': '542x320',
  836. 'strict': 'experimental',
  837. 'threads': '0',
  838. 'vcodec': 'libx264',
  839. })
  840. self.check_size('normal800x480', 800, 480)
  841. def test_galaxyepic(self):
  842. self.check_ffmpeg_arguments('galaxyepic', {
  843. 'ab': '160k',
  844. 'ac': '2',
  845. 'acodec': 'aac',
  846. 'bufsize': '10000000',
  847. 'f': 'mp4',
  848. 'i': self.input_path,
  849. 'level': '30',
  850. 'maxrate': '10000000',
  851. 'output_file': self.output_path,
  852. 'preset': 'slow',
  853. 'profile:v': 'baseline',
  854. 's': '542x320',
  855. 'strict': 'experimental',
  856. 'threads': '0',
  857. 'vcodec': 'libx264',
  858. })
  859. self.check_size('galaxyepic', 800, 480)
  860. def test_avcintra720p(self):
  861. self.check_ffmpeg_arguments('avcintra720p', {
  862. 'acodec': 'pcm_s16be',
  863. 'ar': '48000',
  864. 'f': 'mov',
  865. 'i': self.input_path,
  866. 'output_file': self.output_path,
  867. 'profile:v': '2',
  868. 's': '542x320',
  869. 'strict': 'experimental',
  870. 'vcodec': 'prores',
  871. })
  872. self.check_size('avcintra720p', 1080, 720)
  873. def test_dnxhd720p(self):
  874. self.check_ffmpeg_arguments('dnxhd720p', {
  875. 'acodec': 'pcm_s16be',
  876. 'ar': '48000',
  877. 'b:v': '175M',
  878. 'f': 'mov',
  879. 'i': self.input_path,
  880. 'output_file': self.output_path,
  881. 'r': '23.976',
  882. 's': '542x320',
  883. 'strict': 'experimental',
  884. 'vcodec': 'dnxhd',
  885. })
  886. self.check_size('dnxhd720p', 1080, 720)
  887. def test_iphone5(self):
  888. self.check_ffmpeg_arguments('iphone5', {
  889. 'ab': '160k',
  890. 'ac': '2',
  891. 'acodec': 'aac',
  892. 'bufsize': '10000000',
  893. 'f': 'mp4',
  894. 'i': self.input_path,
  895. 'level': '30',
  896. 'maxrate': '10000000',
  897. 'output_file': self.output_path,
  898. 'preset': 'slow',
  899. 'profile:v': 'baseline',
  900. 's': '542x320',
  901. 'strict': 'experimental',
  902. 'threads': '0',
  903. 'vb': '1200k',
  904. 'vcodec': 'libx264',
  905. })
  906. self.check_size('iphone5', 1920, 1080)
  907. def test_webmvp8(self):
  908. self.check_ffmpeg_arguments('webmvp8', {
  909. 'acodec': 'libvorbis',
  910. 'vcodec': 'libvpx',
  911. 'b:v': '0',
  912. 'g': '240',
  913. 'crf': '32',
  914. 'f': 'webm',
  915. 'i': self.input_path,
  916. 'output_file': self.output_path,
  917. 'quality': 'good',
  918. 's': '542x320',
  919. 'strict': 'experimental',
  920. 'threads': '4',
  921. 'map_metadata': '-1',
  922. })
  923. self.check_uses_input_size('webmvp8')
  924. def test_webm1080pvp8(self):
  925. self.check_ffmpeg_arguments('webm1080pvp8', {
  926. 'ab': '128k',
  927. 'acodec': 'libvorbis',
  928. 'ar': '44100',
  929. 'b:v': '4M',
  930. 'cpu_used': '0',
  931. 'deadline': 'good',
  932. 'f': 'webm',
  933. 'g': '120',
  934. 'i': self.input_path,
  935. 'lag_in_frames': '23',
  936. 'map_metadata': '-1',
  937. 'output_file': self.output_path,
  938. 'qmax': '51',
  939. 'qmin': '11',
  940. 's': '542x320',
  941. 'slices': '4',
  942. 'strict': 'experimental',
  943. 'vcodec': 'libvpx',
  944. 'vprofile': '0'
  945. })
  946. self.check_size('webm1080pvp8', 1920, 1080)
  947. def test_webm720pvp8(self):
  948. self.check_ffmpeg_arguments('webm720pvp8', {
  949. 'ab': '112k',
  950. 'acodec': 'libvorbis',
  951. 'ar': '44100',
  952. 'b:v': '2M',
  953. 'cpu_used': '0',
  954. 'deadline': 'good',
  955. 'f': 'webm',
  956. 'g': '120',
  957. 'i': self.input_path,
  958. 'lag_in_frames': '16',
  959. 'output_file': self.output_path,
  960. 'qmax': '51',
  961. 'qmin': '11',
  962. 's': '542x320',
  963. 'slices': '4',
  964. 'strict': 'experimental',
  965. 'vcodec': 'libvpx',
  966. 'vprofile': '0',
  967. 'map_metadata': '-1',
  968. })
  969. self.check_size('webm720pvp8', 1080, 720)
  970. def test_webm480pvp8(self):
  971. self.check_ffmpeg_arguments('webm480pvp8', {
  972. 'ab': '112k',
  973. 'acodec': 'libvorbis',
  974. 'ar': '44100',
  975. 'b:v': '768k',
  976. 'cpu_used': '0',
  977. 'deadline': 'good',
  978. 'f': 'webm',
  979. 'g': '120',
  980. 'i': self.input_path,
  981. 'lag_in_frames': '16',
  982. 'output_file': self.output_path,
  983. 'qmax': '53',
  984. 'qmin': '0',
  985. 's': '542x320',
  986. 'strict': 'experimental',
  987. 'vcodec': 'libvpx',
  988. 'vprofile': '0',
  989. 'map_metadata': '-1',
  990. })
  991. self.check_size('webm480pvp8', 720, 480)
  992. def test_webmvp9(self):
  993. self.check_ffmpeg_arguments('webmvp9', {
  994. 'acodec': 'libopus',
  995. 'vcodec': 'libvpx-vp9',
  996. 'b:v': '0',
  997. 'g': '240',
  998. 'crf': '32',
  999. 'f': 'webm',
  1000. 'i': self.input_path,
  1001. 'output_file': self.output_path,
  1002. 'quality': 'good',
  1003. 's': '542x320',
  1004. 'strict': 'experimental',
  1005. 'threads': '4',
  1006. 'map_metadata': '-1',
  1007. })
  1008. self.check_uses_input_size('webmvp9')
  1009. def test_webm1080pvp9(self):
  1010. self.check_ffmpeg_arguments('webm1080pvp9', {
  1011. 'ab': '128k',
  1012. 'acodec': 'libopus',
  1013. 'b:v': '4M',
  1014. 'cpu_used': '0',
  1015. 'deadline': 'good',
  1016. 'f': 'webm',
  1017. 'g': '120',
  1018. 'i': self.input_path,
  1019. 'lag_in_frames': '23',
  1020. 'map_metadata': '-1',
  1021. 'output_file': self.output_path,
  1022. 'qmax': '51',
  1023. 'qmin': '11',
  1024. 's': '542x320',
  1025. 'slices': '4',
  1026. 'strict': 'experimental',
  1027. 'vcodec': 'libvpx-vp9',
  1028. 'vprofile': '0'
  1029. })
  1030. self.check_size('webm1080pvp9', 1920, 1080)
  1031. def test_webm720pvp9(self):
  1032. self.check_ffmpeg_arguments('webm720pvp9', {
  1033. 'ab': '112k',
  1034. 'acodec': 'libopus',
  1035. 'b:v': '2M',
  1036. 'cpu_used': '0',
  1037. 'deadline': 'good',
  1038. 'f': 'webm',
  1039. 'g': '120',
  1040. 'i': self.input_path,
  1041. 'lag_in_frames': '16',
  1042. 'output_file': self.output_path,
  1043. 'qmax': '51',
  1044. 'qmin': '11',
  1045. 's': '542x320',
  1046. 'slices': '4',
  1047. 'strict': 'experimental',
  1048. 'vcodec': 'libvpx-vp9',
  1049. 'vprofile': '0',
  1050. 'map_metadata': '-1',
  1051. })
  1052. self.check_size('webm720pvp9', 1080, 720)
  1053. def test_webm480pvp9(self):
  1054. self.check_ffmpeg_arguments('webm480pvp9', {
  1055. 'ab': '112k',
  1056. 'acodec': 'libopus',
  1057. 'b:v': '768k',
  1058. 'cpu_used': '0',
  1059. 'deadline': 'good',
  1060. 'f': 'webm',
  1061. 'g': '120',
  1062. 'i': self.input_path,
  1063. 'lag_in_frames': '16',
  1064. 'output_file': self.output_path,
  1065. 'qmax': '53',
  1066. 'qmin': '0',
  1067. 's': '542x320',
  1068. 'strict': 'experimental',
  1069. 'vcodec': 'libvpx-vp9',
  1070. 'vprofile': '0',
  1071. 'map_metadata': '-1',
  1072. })
  1073. self.check_size('webm480pvp9', 720, 480)
  1074. def test_galaxymini(self):
  1075. self.check_ffmpeg_arguments('galaxymini', {
  1076. 'ab': '160k',
  1077. 'ac': '2',
  1078. 'acodec': 'aac',
  1079. 'bufsize': '10000000',
  1080. 'f': 'mp4',
  1081. 'i': self.input_path,
  1082. 'level': '30',
  1083. 'maxrate': '10000000',
  1084. 'output_file': self.output_path,
  1085. 'preset': 'slow',
  1086. 'profile:v': 'baseline',
  1087. 's': '320x188',
  1088. 'strict': 'experimental',
  1089. 'threads': '0',
  1090. 'vcodec': 'libx264',
  1091. })
  1092. self.check_size('galaxymini', 320, 240)
  1093. def test_onex(self):
  1094. self.check_ffmpeg_arguments('onex', {
  1095. 'ab': '160k',
  1096. 'ac': '2',
  1097. 'acodec': 'aac',
  1098. 'bufsize': '10000000',
  1099. 'f': 'mp4',
  1100. 'i': self.input_path,
  1101. 'level': '30',
  1102. 'maxrate': '10000000',
  1103. 'output_file': self.output_path,
  1104. 'preset': 'slow',
  1105. 'profile:v': 'baseline',
  1106. 's': '542x320',
  1107. 'strict': 'experimental',
  1108. 'threads': '0',
  1109. 'vcodec': 'libx264',
  1110. })
  1111. self.check_size('onex', 1280, 720)
  1112. def test_oggtheora(self):
  1113. self.check_ffmpeg_arguments('oggtheora', {
  1114. 'acodec': 'libvorbis',
  1115. 'f': 'ogg',
  1116. 'i': self.input_path,
  1117. 'output_file': self.output_path,
  1118. 's': '542x320',
  1119. 'strict': 'experimental',
  1120. 'vcodec': 'libtheora',
  1121. 'qscale:v': '7',
  1122. 'qscale:a': '5',
  1123. 'map_metadata': '-1',
  1124. })
  1125. self.check_uses_input_size('oggtheora')
  1126. def test_ipad3(self):
  1127. self.check_ffmpeg_arguments('ipad3', {
  1128. 'ab': '160k',
  1129. 'ac': '2',
  1130. 'acodec': 'aac',
  1131. 'bufsize': '10000000',
  1132. 'f': 'mp4',
  1133. 'i': self.input_path,
  1134. 'level': '30',
  1135. 'maxrate': '10000000',
  1136. 'output_file': self.output_path,
  1137. 'preset': 'slow',
  1138. 'profile:v': 'baseline',
  1139. 's': '542x320',
  1140. 'strict': 'experimental',
  1141. 'threads': '0',
  1142. 'vb': '1200k',
  1143. 'vcodec': 'libx264',
  1144. })
  1145. self.check_size('ipad3', 1920, 1080)
  1146. def test_galaxyssiisplus(self):
  1147. self.check_ffmpeg_arguments('galaxyssiisplus', {
  1148. 'ab': '160k',
  1149. 'ac': '2',
  1150. 'acodec': 'aac',
  1151. 'bufsize': '10000000',
  1152. 'f': 'mp4',
  1153. 'i': self.input_path,
  1154. 'level': '30',
  1155. 'maxrate': '10000000',
  1156. 'output_file': self.output_path,
  1157. 'preset': 'slow',
  1158. 'profile:v': 'baseline',
  1159. 's': '542x320',
  1160. 'strict': 'experimental',
  1161. 'threads': '0',
  1162. 'vcodec': 'libx264',
  1163. })
  1164. self.check_size('galaxyssiisplus', 800, 480)
  1165. def test_kindlefire(self):
  1166. self.check_ffmpeg_arguments('kindlefire', {
  1167. 'ab': '96k',
  1168. 'acodec': 'aac',
  1169. 'crf': '22',
  1170. 'f': 'mp4',
  1171. 'i': self.input_path,
  1172. 'output_file': self.output_path,
  1173. 'preset': 'slow',
  1174. 's': '542x320',
  1175. 'strict': 'experimental',
  1176. 'vcodec': 'libx264',
  1177. })
  1178. self.check_size('kindlefire', 1224, 600)
  1179. def test_galaxyace(self):
  1180. self.check_ffmpeg_arguments('galaxyace', {
  1181. 'ab': '160k',
  1182. 'ac': '2',
  1183. 'acodec': 'aac',
  1184. 'bufsize': '10000000',
  1185. 'f': 'mp4',
  1186. 'i': self.input_path,
  1187. 'level': '30',
  1188. 'maxrate': '10000000',
  1189. 'output_file': self.output_path,
  1190. 'preset': 'slow',
  1191. 'profile:v': 'baseline',
  1192. 's': '542x320',
  1193. 'strict': 'experimental',
  1194. 'threads': '0',
  1195. 'vcodec': 'libx264',
  1196. })
  1197. self.check_size('galaxyace', 480, 320)
  1198. def test_dnxhd1080p(self):
  1199. self.check_ffmpeg_arguments('dnxhd1080p', {
  1200. 'acodec': 'pcm_s16be',
  1201. 'ar': '48000',
  1202. 'b:v': '175M',
  1203. 'f': 'mov',
  1204. 'i': self.input_path,
  1205. 'output_file': self.output_path,
  1206. 'r': '23.976',
  1207. 's': '542x320',
  1208. 'strict': 'experimental',
  1209. 'vcodec': 'dnxhd',
  1210. })
  1211. self.check_size('dnxhd1080p', 1920, 1080)
  1212. def test_small480x320(self):
  1213. self.check_ffmpeg_arguments('small480x320', {
  1214. 'ab': '160k',
  1215. 'ac': '2',
  1216. 'acodec': 'aac',
  1217. 'bufsize': '10000000',
  1218. 'f': 'mp4',
  1219. 'i': self.input_path,
  1220. 'level': '30',
  1221. 'maxrate': '10000000',
  1222. 'output_file': self.output_path,
  1223. 'preset': 'slow',
  1224. 'profile:v': 'baseline',
  1225. 's': '542x320',
  1226. 'strict': 'experimental',
  1227. 'threads': '0',
  1228. 'vcodec': 'libx264',
  1229. })
  1230. self.check_size('small480x320', 480, 320)
  1231. def test_iphone4(self):
  1232. self.check_ffmpeg_arguments('iphone4', {
  1233. 'ab': '160k',
  1234. 'ac': '2',
  1235. 'acodec': 'aac',
  1236. 'bufsize': '10000000',
  1237. 'f': 'mp4',
  1238. 'i': self.input_path,
  1239. 'level': '30',
  1240. 'maxrate': '10000000',
  1241. 'output_file': self.output_path,
  1242. 'preset': 'slow',
  1243. 'profile:v': 'baseline',
  1244. 's': '542x320',
  1245. 'strict': 'experimental',
  1246. 'threads': '0',
  1247. 'vb': '1200k',
  1248. 'vcodec': 'libx264',
  1249. })
  1250. self.check_size('iphone4', 960, 640)
  1251. def test_razr(self):
  1252. self.check_ffmpeg_arguments('razr', {
  1253. 'ab': '160k',
  1254. 'ac': '2',
  1255. 'acodec': 'aac',
  1256. 'bufsize': '10000000',
  1257. 'f': 'mp4',
  1258. 'i': self.input_path,
  1259. 'level': '30',
  1260. 'maxrate': '10000000',
  1261. 'output_file': self.output_path,
  1262. 'preset': 'slow',
  1263. 'profile:v': 'baseline',
  1264. 's': '542x320',
  1265. 'strict': 'experimental',
  1266. 'threads': '0',
  1267. 'vcodec': 'libx264',
  1268. })
  1269. self.check_size('razr', 960, 540)
  1270. def test_ipodtouch(self):
  1271. self.check_ffmpeg_arguments('ipodtouch', {
  1272. 'ab': '160k',
  1273. 'ac': '2',
  1274. 'acodec': 'aac',
  1275. 'bufsize': '10000000',
  1276. 'f': 'mp4',
  1277. 'i': self.input_path,
  1278. 'level': '30',
  1279. 'maxrate': '10000000',
  1280. 'output_file': self.output_path,
  1281. 'preset': 'slow',
  1282. 'profile:v': 'baseline',
  1283. 's': '542x320',
  1284. 'strict': 'experimental',
  1285. 'threads': '0',
  1286. 'vb': '1200k',
  1287. 'vcodec': 'libx264',
  1288. })
  1289. self.check_size('ipodtouch', 640, 480)
  1290. def test_galaxytab(self):
  1291. self.check_ffmpeg_arguments('galaxytab', {
  1292. 'ab': '160k',
  1293. 'ac': '2',
  1294. 'acodec': 'aac',
  1295. 'bufsize': '10000000',
  1296. 'f': 'mp4',
  1297. 'i': self.input_path,
  1298. 'level': '30',
  1299. 'maxrate': '10000000',
  1300. 'output_file': self.output_path,
  1301. 'preset': 'slow',
  1302. 'profile:v': 'baseline',
  1303. 's': '542x320',
  1304. 'strict': 'experimental',
  1305. 'threads': '0',
  1306. 'vcodec': 'libx264',
  1307. })
  1308. self.check_size('galaxytab', 1024, 600)
  1309. def test_appleuniversal(self):
  1310. self.check_ffmpeg_arguments('appleuniversal', {
  1311. 'ab': '160k',
  1312. 'ac': '2',
  1313. 'acodec': 'aac',
  1314. 'bufsize': '10000000',
  1315. 'f': 'mp4',
  1316. 'i': self.input_path,
  1317. 'level': '30',
  1318. 'maxrate': '10000000',
  1319. 'output_file': self.output_path,
  1320. 'preset': 'slow',
  1321. 'profile:v': 'baseline',
  1322. 's': '542x320',
  1323. 'strict': 'experimental',
  1324. 'threads': '0',
  1325. 'vb': '1200k',
  1326. 'vcodec': 'libx264',
  1327. })
  1328. self.check_size('appleuniversal', 1280, 720)
  1329. def test_evo4g(self):
  1330. self.check_ffmpeg_arguments('evo4g', {
  1331. 'ab': '160k',
  1332. 'ac': '2',
  1333. 'acodec': 'aac',
  1334. 'bufsize': '10000000',
  1335. 'f': 'mp4',
  1336. 'i': self.input_path,
  1337. 'level': '30',
  1338. 'maxrate': '10000000',
  1339. 'output_file': self.output_path,
  1340. 'preset': 'slow',
  1341. 'profile:v': 'baseline',
  1342. 's': '542x320',
  1343. 'strict': 'experimental',
  1344. 'threads': '0',
  1345. 'vcodec': 'libx264',
  1346. })
  1347. self.check_size('evo4g', 800, 480)