@@ -116,9 +116,20 @@ def test_stream_repr():
116116 dummy_out .label , dummy_out .node .short_hash
117117 )
118118
119+
119120def test_repeated_args ():
120- out_file = ffmpeg .input ('dummy.mp4' ).output ('dummy2.mp4' , streamid = ['0:0x101' , '1:0x102' ])
121- assert out_file .get_args () == ['-i' , 'dummy.mp4' , '-streamid' , '0:0x101' , '-streamid' , '1:0x102' , 'dummy2.mp4' ]
121+ out_file = ffmpeg .input ('dummy.mp4' ).output (
122+ 'dummy2.mp4' , streamid = ['0:0x101' , '1:0x102' ]
123+ )
124+ assert out_file .get_args () == [
125+ '-i' ,
126+ 'dummy.mp4' ,
127+ '-streamid' ,
128+ '0:0x101' ,
129+ '-streamid' ,
130+ '1:0x102' ,
131+ 'dummy2.mp4' ,
132+ ]
122133
123134
124135def test__get_args__simple ():
@@ -332,8 +343,13 @@ def test_filter_asplit():
332343 '-i' ,
333344 TEST_INPUT_FILE1 ,
334345 '-filter_complex' ,
335- '[0]vflip[s0];[s0]asplit=2[s1][s2];[s1]atrim=end=20:start=10[s3];[s2]atrim=end=40:start=30[s4];[s3]'
336- '[s4]concat=n=2[s5]' ,
346+ (
347+ '[0]vflip[s0];'
348+ '[s0]asplit=2[s1][s2];'
349+ '[s1]atrim=end=20:start=10[s3];'
350+ '[s2]atrim=end=40:start=30[s4];'
351+ '[s3][s4]concat=n=2[s5]'
352+ ),
337353 '-map' ,
338354 '[s5]' ,
339355 TEST_OUTPUT_FILE1 ,
@@ -357,10 +373,14 @@ def test__output__video_size(video_size):
357373
358374
359375def test_filter_normal_arg_escape ():
360- """Test string escaping of normal filter args (e.g. ``font`` param of ``drawtext`` filter)."""
376+ """Test string escaping of normal filter args (e.g. ``font`` param of ``drawtext``
377+ filter).
378+ """
361379
362380 def _get_drawtext_font_repr (font ):
363- """Build a command-line arg using drawtext ``font`` param and extract the ``-filter_complex`` arg."""
381+ """Build a command-line arg using drawtext ``font`` param and extract the
382+ ``-filter_complex`` arg.
383+ """
364384 args = (
365385 ffmpeg .input ('in' )
366386 .drawtext ('test' , font = 'a{}b' .format (font ))
@@ -370,7 +390,9 @@ def _get_drawtext_font_repr(font):
370390 assert args [:3 ] == ['-i' , 'in' , '-filter_complex' ]
371391 assert args [4 :] == ['-map' , '[s0]' , 'out' ]
372392 match = re .match (
373- r'\[0\]drawtext=font=a((.|\n)*)b:text=test\[s0\]' , args [3 ], re .MULTILINE
393+ r'\[0\]drawtext=font=a((.|\n)*)b:text=test\[s0\]' ,
394+ args [3 ],
395+ re .MULTILINE ,
374396 )
375397 assert match is not None , 'Invalid -filter_complex arg: {!r}' .format (args [3 ])
376398 return match .group (1 )
@@ -394,10 +416,14 @@ def _get_drawtext_font_repr(font):
394416
395417
396418def test_filter_text_arg_str_escape ():
397- """Test string escaping of normal filter args (e.g. ``text`` param of ``drawtext`` filter)."""
419+ """Test string escaping of normal filter args (e.g. ``text`` param of ``drawtext``
420+ filter).
421+ """
398422
399423 def _get_drawtext_text_repr (text ):
400- """Build a command-line arg using drawtext ``text`` param and extract the ``-filter_complex`` arg."""
424+ """Build a command-line arg using drawtext ``text`` param and extract the
425+ ``-filter_complex`` arg.
426+ """
401427 args = ffmpeg .input ('in' ).drawtext ('a{}b' .format (text )).output ('out' ).get_args ()
402428 assert args [:3 ] == ['-i' , 'in' , '-filter_complex' ]
403429 assert args [4 :] == ['-map' , '[s0]' , 'out' ]
@@ -447,8 +473,11 @@ def test__run_async(mocker, pipe_stdin, pipe_stdout, pipe_stderr, cwd):
447473 popen__mock = mocker .patch .object (subprocess , 'Popen' , return_value = process__mock )
448474 stream = _get_simple_example ()
449475 process = ffmpeg .run_async (
450- stream , pipe_stdin = pipe_stdin , pipe_stdout = pipe_stdout ,
451- pipe_stderr = pipe_stderr , cwd = cwd
476+ stream ,
477+ pipe_stdin = pipe_stdin ,
478+ pipe_stdout = pipe_stdout ,
479+ pipe_stderr = pipe_stderr ,
480+ cwd = cwd ,
452481 )
453482 assert process is process__mock
454483
@@ -458,8 +487,10 @@ def test__run_async(mocker, pipe_stdin, pipe_stdout, pipe_stderr, cwd):
458487 (args ,), kwargs = popen__mock .call_args
459488 assert args == ffmpeg .compile (stream )
460489 assert kwargs == dict (
461- stdin = expected_stdin , stdout = expected_stdout , stderr = expected_stderr ,
462- cwd = cwd
490+ stdin = expected_stdin ,
491+ stdout = expected_stdout ,
492+ stderr = expected_stderr ,
493+ cwd = cwd ,
463494 )
464495
465496
@@ -695,7 +726,10 @@ def test_pipe():
695726
696727 cmd = ['ffmpeg' ] + args
697728 p = subprocess .Popen (
698- cmd , stdin = subprocess .PIPE , stdout = subprocess .PIPE , stderr = subprocess .PIPE
729+ cmd ,
730+ stdin = subprocess .PIPE ,
731+ stdout = subprocess .PIPE ,
732+ stderr = subprocess .PIPE ,
699733 )
700734
701735 in_data = bytes (
@@ -715,10 +749,10 @@ def test__probe():
715749 assert data ['format' ]['duration' ] == '7.036000'
716750
717751
718- @pytest .mark .skipif (sys .version_info < (3 , 3 ), reason = " requires python3.3 or higher" )
752+ @pytest .mark .skipif (sys .version_info < (3 , 3 ), reason = ' requires python3.3 or higher' )
719753def test__probe_timeout ():
720754 with pytest .raises (subprocess .TimeoutExpired ) as excinfo :
721- data = ffmpeg .probe (TEST_INPUT_FILE1 , timeout = 0 )
755+ ffmpeg .probe (TEST_INPUT_FILE1 , timeout = 0 )
722756 assert 'timed out after 0 seconds' in str (excinfo .value )
723757
724758
@@ -751,24 +785,24 @@ def get_filter_complex_outputs(flt, name):
751785
752786
753787def test__get_filter_complex_input ():
754- assert get_filter_complex_input ("" , " scale" ) is None
755- assert get_filter_complex_input (" scale" , " scale" ) is None
756- assert get_filter_complex_input (" scale[s3][s4];etc" , " scale" ) is None
757- assert get_filter_complex_input (" [s2]scale" , " scale" ) == "s2"
758- assert get_filter_complex_input (" [s2]scale;etc" , " scale" ) == "s2"
759- assert get_filter_complex_input (" [s2]scale[s3][s4];etc" , " scale" ) == "s2"
788+ assert get_filter_complex_input ('' , ' scale' ) is None
789+ assert get_filter_complex_input (' scale' , ' scale' ) is None
790+ assert get_filter_complex_input (' scale[s3][s4];etc' , ' scale' ) is None
791+ assert get_filter_complex_input (' [s2]scale' , ' scale' ) == 's2'
792+ assert get_filter_complex_input (' [s2]scale;etc' , ' scale' ) == 's2'
793+ assert get_filter_complex_input (' [s2]scale[s3][s4];etc' , ' scale' ) == 's2'
760794
761795
762796def test__get_filter_complex_outputs ():
763- assert get_filter_complex_outputs ("" , " scale" ) is None
764- assert get_filter_complex_outputs (" scale" , " scale" ) is None
765- assert get_filter_complex_outputs (" scalex[s0][s1]" , " scale" ) is None
766- assert get_filter_complex_outputs (" scale[s0][s1]" , " scale" ) == ['s0' , 's1' ]
767- assert get_filter_complex_outputs (" [s5]scale[s0][s1]" , " scale" ) == ['s0' , 's1' ]
768- assert get_filter_complex_outputs (" [s5]scale[s1][s0]" , " scale" ) == ['s1' , 's0' ]
769- assert get_filter_complex_outputs (" [s5]scale[s1]" , " scale" ) == ['s1' ]
770- assert get_filter_complex_outputs (" [s5]scale[s1];x" , " scale" ) == ['s1' ]
771- assert get_filter_complex_outputs (" y;[s5]scale[s1];x" , " scale" ) == ['s1' ]
797+ assert get_filter_complex_outputs ('' , ' scale' ) is None
798+ assert get_filter_complex_outputs (' scale' , ' scale' ) is None
799+ assert get_filter_complex_outputs (' scalex[s0][s1]' , ' scale' ) is None
800+ assert get_filter_complex_outputs (' scale[s0][s1]' , ' scale' ) == ['s0' , 's1' ]
801+ assert get_filter_complex_outputs (' [s5]scale[s0][s1]' , ' scale' ) == ['s0' , 's1' ]
802+ assert get_filter_complex_outputs (' [s5]scale[s1][s0]' , ' scale' ) == ['s1' , 's0' ]
803+ assert get_filter_complex_outputs (' [s5]scale[s1]' , ' scale' ) == ['s1' ]
804+ assert get_filter_complex_outputs (' [s5]scale[s1];x' , ' scale' ) == ['s1' ]
805+ assert get_filter_complex_outputs (' y;[s5]scale[s1];x' , ' scale' ) == ['s1' ]
772806
773807
774808def test__multi_output_edge_label_order ():
0 commit comments