[FFmpeg-user] the trim filter

Mark Filipak markfilipak.imdb at gmail.com
Fri Jul 5 22:41:46 EEST 2024


On 05/07/2024 14.34, Jim DeLaHunt wrote:
> On 2024-07-04 15:50, Mark Filipak wrote:
> 
>> ...Here's the interesting terminal output (slightly beautified):
>>
>> [Parsed_trim_1 @ 0000000000620040]
>>  Media type mismatch between the 'Parsed_trim_1' filter output pad 0 (video) and the 
>> 'Parsed_atrim_2' filter input pad 0 (audio)
>>
>> [AVFilterGraph @ 000000000061c7c0] Error linking filters
>>
>> Failed to set value
>>  'split=2[i5][i6],
>>  [i5]trim=start_frame=481:end_frame=134047, atrim=start_sample=962962:end_sample=268360092[o5],
>>  [i6]trim=start_frame=138745:end_frame=246719[o6],
>>  [o5][o6]concat=n=2'
>> for option 'filter_complex': Invalid argument
>> Error parsing global options: Invalid argument
> 
> I think there is a clue in the previous part of the output:
> 
>> [Parsed_trim_1 @ 0000000000620040] Media type mismatch between the 'Parsed_trim_1' filter output 
>> pad 0 (video) and the 'Parsed_atrim_2' filter input pad 0 (audio)
> I see "media type mismatch", so what is not matched?  I see a mention of "filter output pad 0 
> (video)" and "filter input pad 0 (audio)". I can imagine that media "video" does not match media 
> "audio".
> 
>> ...Here's my trim commands for the first segment:
>>
>> trim=start_frame=481:end_frame=134047,atrim=start_sample=962962:end_sample=268360093
> 
> Consulting the filtergraph syntax documentation 
> <https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-syntax-1>,
> 
>> A filterchain consists of a sequence of connected filters, each one connected to the previous one 
>> in the sequence. A filterchain is represented by a list of ","-separated filter descriptions. 
> It looks like your trim commands for the first segment consist of a `trim` filter which reads video 
> media from input pad [i5] and writes video media to an implicit output pad, connected to an `atrim` 
> filter which wants reads audio media from an implicit input pad. But the implicit output pad is 
> giving video media to a filter which wants audio media.
> 
> That looks like a type mismatch to me.

I agree. I expected that
[i5]trim=start_frame=481:end_frame=134047, atrim=start_sample=962962:end_sample=268360092[o5]
was a stream and that atrim would operate only on the audio part of that stream. But it appears that 
I may have to split the video and audio streams into two discrete streams (or maybe more if there 
were more than one video stream and/or more than one audio stream). This is an architectural 
shortcoming of FFmpeg and is something OFFmpeg does not suffer.

When I find the time, I'll explore this further and I'll try some of your good ideas.

Thanks, Jim.
--Mark.




More information about the ffmpeg-user mailing list