[FFmpeg-user] Clipping inputs -t position with concat video filter

Gyan ffmpeg at gyani.pro
Wed Feb 6 07:44:31 EET 2019



On 06-02-2019 12:57 AM, Christian Johannesen wrote:
> It's my understanding that the -t option can be used before or after the
> input file. I've found that its more accurate with some input files if I
> place the option after the input file. However, this impacts the ability to
> use the concat video filter to combine multiple clips. When I set the -t
> duration after the input last input clip does not appear in the output file
> after using the concat video filter. If move the -t duration before the
> input, the concat video filter outputs both clips.
>
> Thanks,
> Chris
>
> -t before input:
>
>> ffmpeg -y -ss 86.086 -t 4.004 -i countdownclock_720p2398_21min.mp4 -ss
> 1257.256 -t 4.004 -i countdownclock_720p2398_21min.mp4 -filter_complex
> "[0:v:0][1:v:0]concat=n=2:v=1:a=0[concat_v]" -map "[concat_v]" -pix_fmt
> yuv420p t_after_input.mp4

-ss and -t when used as output options, take effect *after* filtering, 
so you're actually trimming the output from the concat filter.

Use the trim filters instead.

     ffmpeg -y  -i countdownclock_720p2398_21min.mp4 -filter_complex \
          "[0]split=2[v1][v2]; 
[v1]trim=st=86.086:d=4.004,setpts=PTS-STARTPTS[v1]; 
[v2]trim=st=1257.256:d=4.004,setpts=PTS-STARTPTS[v2]; \
            [v1][v2]concat=n=2:v=1:a=0,format=yuv420p" t_after_input.mp4

In this case, you can also use the select filter since you're working on 
one input.

     ffmpeg -y  -i countdownclock_720p2398_21min.mp4 -vf 
"select='between(t,86.086,86.086+4.004)+between(t,1257.256,1257.256+4.004)',setpts=PTS-STARTPTS 
,format=yuv420p" t_after_input.mp4

Note that both these methods will be slower than input ss/t.

Gyan


More information about the ffmpeg-user mailing list