@@ -221,6 +221,83 @@ def _get_complex_filter_asplit_example():
221221    )
222222
223223
224+ def  test_filter_concat__video_only ():
225+     in1  =  ffmpeg .input ('in1.mp4' )
226+     in2  =  ffmpeg .input ('in2.mp4' )
227+     args  =  (
228+         ffmpeg 
229+         .concat (in1 , in2 )
230+         .output ('out.mp4' )
231+         .get_args ()
232+     )
233+     assert  args  ==  [
234+         '-i' ,
235+         'in1.mp4' ,
236+         '-i' ,
237+         'in2.mp4' ,
238+         '-filter_complex' ,
239+         '[0][1]concat=n=2[s0]' ,
240+         '-map' ,
241+         '[s0]' ,
242+         'out.mp4' ,
243+     ]
244+ 
245+ 
246+ def  test_filter_concat__audio_only ():
247+     in1  =  ffmpeg .input ('in1.mp4' )
248+     in2  =  ffmpeg .input ('in2.mp4' )
249+     args  =  (
250+         ffmpeg 
251+         .concat (in1 , in2 , v = 0 , a = 1 )
252+         .output ('out.mp4' )
253+         .get_args ()
254+     )
255+     assert  args  ==  [
256+         '-i' ,
257+         'in1.mp4' ,
258+         '-i' ,
259+         'in2.mp4' ,
260+         '-filter_complex' ,
261+         '[0][1]concat=a=1:n=2:v=0[s0]' ,
262+         '-map' ,
263+         '[s0]' ,
264+         'out.mp4' 
265+     ]
266+ 
267+ 
268+ def  test_filter_concat__audio_video ():
269+     in1  =  ffmpeg .input ('in1.mp4' )
270+     in2  =  ffmpeg .input ('in2.mp4' )
271+     joined  =  ffmpeg .concat (in1 ['v' ], in1 ['a' ], in2 .hflip (), in2 ['a' ], v = 1 , a = 1 ).node 
272+     args  =  (
273+         ffmpeg 
274+         .output (joined [0 ], joined [1 ], 'out.mp4' )
275+         .get_args ()
276+     )
277+     assert  args  ==  [
278+         '-i' ,
279+         'in1.mp4' ,
280+         '-i' ,
281+         'in2.mp4' ,
282+         '-filter_complex' ,
283+         '[1]hflip[s0];[0:v][0:a][s0][1:a]concat=a=1:n=2:v=1[s1][s2]' ,
284+         '-map' ,
285+         '[s1]' ,
286+         '-map' ,
287+         '[s2]' ,
288+         'out.mp4' ,
289+     ]
290+ 
291+ 
292+ def  test_filter_concat__wrong_stream_count ():
293+     in1  =  ffmpeg .input ('in1.mp4' )
294+     in2  =  ffmpeg .input ('in2.mp4' )
295+     with  pytest .raises (ValueError ) as  excinfo :
296+         ffmpeg .concat (in1 ['v' ], in1 ['a' ], in2 .hflip (), v = 1 , a = 1 ).node 
297+     assert  str (excinfo .value ) ==  \
298+         'Expected concat input streams to have length multiple of 2 (v=1, a=1); got 3' 
299+ 
300+ 
224301def  test_filter_asplit ():
225302    out  =  _get_complex_filter_asplit_example ()
226303    args  =  out .get_args ()
0 commit comments