22from pprint import pprint
33
44from ffmpegio import configure
5+ from ffmpegio import filtergraph as fgb
6+ from ffmpegio .utils import analyze_complex_filtergraphs
57
68vid_url = "tests/assets/testvideo-1m.mp4"
79img_url = "tests/assets/ffmpeg-logo.png"
@@ -180,39 +182,39 @@ def test_process_url_inputs(url, opts, defopts, ret):
180182 ("inputs" , "input_info" , "filters_complex" , "ret" ),
181183 [
182184 (
183- [(mul_url , None )],
185+ [(mul_url , {} )],
184186 [{"src_type" : "url" }],
185187 None ,
186188 {
187- f"0:{ i } " : {
189+ f"0:{ mtype [ 0 ] } : { j } " : {
188190 "media_type" : mtype ,
189191 "input_file_id" : 0 ,
190192 "input_stream_id" : i ,
191193 }
192- for i , mtype in mul_streams
194+ for ( i , mtype ), j in zip ( mul_streams , [ 0 , 0 , 1 , 1 ])
193195 },
194196 ),
195197 (
196198 [(vid_url , None ), (aud_url , {})],
197199 [{"src_type" : "url" }, {"src_type" : "url" }],
198200 None ,
199201 {
200- "0:0" : {
202+ "0:v: 0" : {
201203 "media_type" : "video" ,
202204 "input_file_id" : 0 ,
203205 "input_stream_id" : 0 ,
204206 },
205- "1:0" : {
207+ "1:a: 0" : {
206208 "media_type" : "audio" ,
207209 "input_file_id" : 1 ,
208210 "input_stream_id" : 0 ,
209211 },
210212 },
211213 ),
212214 (
213- [(mul_url , None )],
215+ [(mul_url , {} )],
214216 [{"src_type" : "url" }],
215- ["split=n =2" ],
217+ ["split=outputs =2" ],
216218 {"[out0]" : {"media_type" : "video" }, "[out1]" : {"media_type" : "video" }},
217219 ),
218220 ],
@@ -221,8 +223,11 @@ def test_auto_map(inputs, input_info, filters_complex, ret):
221223 args = configure .empty ()
222224 args ["inputs" ].extend (inputs )
223225 if filters_complex is not None :
226+ filters_complex , fg_info = analyze_complex_filtergraphs (
227+ fgb .as_filtergraph (filters_complex ), args ["inputs" ], input_info
228+ )
224229 args ["global_options" ] = {"filter_complex" : filters_complex }
225- out = configure .auto_map (args , input_info )
230+ out = configure .auto_map (args , input_info , filters_complex and fg_info )
226231 assert out == {
227232 spec : {"dst_type" : "pipe" , "user_map" : None , ** info }
228233 for spec , info in ret .items ()
@@ -259,7 +264,7 @@ def ffmpeg_url_inputs_vid_aud():
259264 [
260265 ("ffmpeg_url_inputs_mul" , None , ["v" ]),
261266 ("ffmpeg_url_inputs_vid_aud" , None , ["0:v:0" , "1:a:0" ]),
262- ("ffmpeg_url_inputs_mul" , ["split=n= 2" ], ["[out0]" , "[out1]" , "a:0" ]),
267+ ("ffmpeg_url_inputs_mul" , ["split=2" ], ["[out0]" , "[out1]" , "a:0" ]),
263268 ],
264269)
265270def test_resolve_raw_output_streams (
@@ -268,7 +273,12 @@ def test_resolve_raw_output_streams(
268273
269274 args , input_info = request .getfixturevalue (ffmpeg_url_inputs )
270275
271- if filters_complex is not None :
276+ if filters_complex is None :
277+ fg_info = None
278+ else :
279+ filters_complex , fg_info = analyze_complex_filtergraphs (
280+ fgb .as_filtergraph (filters_complex ), args ["inputs" ], input_info
281+ )
272282 args ["global_options" ] = {"filter_complex" : filters_complex }
273- out = configure .resolve_raw_output_streams (args , input_info , streams )
283+ out = configure .resolve_raw_output_streams (args , input_info , fg_info , streams )
274284 pprint (out )
0 commit comments