@@ -116,9 +116,20 @@ def test_stream_repr():
116
116
dummy_out .label , dummy_out .node .short_hash
117
117
)
118
118
119
+
119
120
def 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
+ ]
122
133
123
134
124
135
def test__get_args__simple ():
@@ -332,8 +343,13 @@ def test_filter_asplit():
332
343
'-i' ,
333
344
TEST_INPUT_FILE1 ,
334
345
'-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
+ ),
337
353
'-map' ,
338
354
'[s5]' ,
339
355
TEST_OUTPUT_FILE1 ,
@@ -357,10 +373,14 @@ def test__output__video_size(video_size):
357
373
358
374
359
375
def 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
+ """
361
379
362
380
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
+ """
364
384
args = (
365
385
ffmpeg .input ('in' )
366
386
.drawtext ('test' , font = 'a{}b' .format (font ))
@@ -370,7 +390,9 @@ def _get_drawtext_font_repr(font):
370
390
assert args [:3 ] == ['-i' , 'in' , '-filter_complex' ]
371
391
assert args [4 :] == ['-map' , '[s0]' , 'out' ]
372
392
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 ,
374
396
)
375
397
assert match is not None , 'Invalid -filter_complex arg: {!r}' .format (args [3 ])
376
398
return match .group (1 )
@@ -394,10 +416,14 @@ def _get_drawtext_font_repr(font):
394
416
395
417
396
418
def 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
+ """
398
422
399
423
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
+ """
401
427
args = ffmpeg .input ('in' ).drawtext ('a{}b' .format (text )).output ('out' ).get_args ()
402
428
assert args [:3 ] == ['-i' , 'in' , '-filter_complex' ]
403
429
assert args [4 :] == ['-map' , '[s0]' , 'out' ]
@@ -447,8 +473,11 @@ def test__run_async(mocker, pipe_stdin, pipe_stdout, pipe_stderr, cwd):
447
473
popen__mock = mocker .patch .object (subprocess , 'Popen' , return_value = process__mock )
448
474
stream = _get_simple_example ()
449
475
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 ,
452
481
)
453
482
assert process is process__mock
454
483
@@ -458,8 +487,10 @@ def test__run_async(mocker, pipe_stdin, pipe_stdout, pipe_stderr, cwd):
458
487
(args ,), kwargs = popen__mock .call_args
459
488
assert args == ffmpeg .compile (stream )
460
489
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 ,
463
494
)
464
495
465
496
@@ -695,7 +726,10 @@ def test_pipe():
695
726
696
727
cmd = ['ffmpeg' ] + args
697
728
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 ,
699
733
)
700
734
701
735
in_data = bytes (
@@ -715,10 +749,10 @@ def test__probe():
715
749
assert data ['format' ]['duration' ] == '7.036000'
716
750
717
751
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' )
719
753
def test__probe_timeout ():
720
754
with pytest .raises (subprocess .TimeoutExpired ) as excinfo :
721
- data = ffmpeg .probe (TEST_INPUT_FILE1 , timeout = 0 )
755
+ ffmpeg .probe (TEST_INPUT_FILE1 , timeout = 0 )
722
756
assert 'timed out after 0 seconds' in str (excinfo .value )
723
757
724
758
@@ -751,24 +785,24 @@ def get_filter_complex_outputs(flt, name):
751
785
752
786
753
787
def 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'
760
794
761
795
762
796
def 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' ]
772
806
773
807
774
808
def test__multi_output_edge_label_order ():
0 commit comments