[FFmpeg-user] the trim filter

Mark Filipak markfilipak.imdb at gmail.com
Wed Jul 17 02:55:56 EEST 2024


On 16/07/2024 19.34, Reino Wijnsma wrote:

Thank you, Reino. I didn't realize I could suppress <CR><LF> like that. That's wonderful! I will use 
that, I'll use it a lot.

> On 2024-07-06T03:18:31+0200, Mark Filipak <markfilipak.imdb at gmail.com> wrote:
>> THE SCRIPT:
>> [...]
> Please don't. Eventhough I'm a Windows user and I understand your Batch-script, it's recommended to enter direct and full FFmpeg commands instead.
> 
>> G:\>ffmpeg -i g:\00305+00306+00307+00308.m2ts -filter_complex "split=8[i5v][i5a][i6v][i6a][i7v][i7a][i8v][i8a], [i5v]trim=start_frame=481:end_frame=134047[o5v], [i5a]atrim=start=20.062:end=5590.835[o5a], [o5v][o5a]interleave[o5], [i6v]trim=start_frame=138745:end_frame=246719[o6v], [i6a]atrim=start=5786.823:end=10290.197[o6a], [o6v][o6a]interleave[o6], [i7v]trim=start_frame=251486:end_frame=333310[o7v], [i7a]atrim=start=10489.062:end=13901.805[o7a], [o7v][o7a]interleave[o7], [i8v]trim=start_frame=338018[o8v], [i8a]atrim=start=14098.167[o8a], [o8v][o8a]interleave[o8],[o5][o6][o7][o8]concat=n=4[o]" -map "[o]" -c:v libx265 -x265-params crf=16 -c:a dts -strict -2 -sn -start_at_zero e:\00305+00306+00307+00308.mp4
>>
>> [...]
>>
>> Well, I separated video & audio into separate streams but got the same result:
> No you haven't.

Actually, I did: -filter_complex:v ... -filter_complex:a ..., I just didn't list the details.

The rest is moot. The AVC slice references all got broken. At the time, I didn't know that AVC was 
so very different from MPEG-2. I hope you didn't spend a lot of time on your answer. But it was kind 
of you to give me your response. -- Mark.

> Please read https://ffmpeg.org/ffmpeg-all.html#Filtergraph-syntax-1, and in particular:
>> 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.
>>
>> A filtergraph consists of a sequence of filterchains. *A sequence of filterchains is represented by a list of ";"-separated filterchain descriptions*.
> So your filtergraph (and prettified Windows FFmpeg command, including escape-characters) should probably look like this:
> 
> ffmpeg -i "g:\00305+00306+00307+00308.m2ts" -filter_complex ^"^
>    split=8[i5v][i5a][i6v][i6a][i7v][i7a][i8v][i8a];^
>    [i5v]trim=start_frame=481:end_frame=134047[o5v];^
>    [i5a]atrim=start=20.062:end=5590.835[o5a]^
>    [o5v][o5a]interleave[o5];^
>    [i6v]trim=start_frame=138745:end_frame=246719[o6v];^
>    [i6a]atrim=start=5786.823:end=10290.197[o6a];^
>    [o6v][o6a]interleave[o6];^
>    [i7v]trim=start_frame=251486:end_frame=333310[o7v];^
>    [i7a]atrim=start=10489.062:end=13901.805[o7a];^
>    [o7v][o7a]interleave[o7];^
>    [i8v]trim=start_frame=338018[o8v];^
>    [i8a]atrim=start=14098.167[o8a];^
>    [o8v][o8a]interleave[o8];^
>    [o5][o6][o7][o8]concat=n=4[o]^
> " -map [o] -c:v libx265 -x265-params crf=16 -c:a dts -strict -2 -sn -start_at_zero "e:\00305+00306+00307+00308.mp4"
> 



More information about the ffmpeg-user mailing list