[FFmpeg-user] the trim filter

Reino Wijnsma rwijnsma at xs4all.nl
Wed Jul 17 02:34:46 EEST 2024


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. Your filtergraph is just one single filterchain.
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"

-- 
Reino



More information about the ffmpeg-user mailing list