[FFmpeg-user] Removing part of a video

Ferdi Scholten ferdi at sttc-nlp.nl
Sat Nov 13 13:08:27 EET 2021

Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> writes:
>> I need to cut a part out of a video. (A certain speaker does not want
>> to be published.)
>> Searching on the internet I found this:
>>      Following is a snippet we used to remove a few seconds from a video using ffmpeg
>>      ffmpeg -i 'input.mkv' -filter_complex \
>>        "[0:v]trim=end=553,setpts=N/FRAME_RATE/TB[v0]; \
>>         [0:a]atrim=end=553,asetpts=N/SR/TB[a0]; \
>>         [0:v]trim=start=559,setpts=N/FRAME_RATE/TB[v1]; \
>>         [0:a]atrim=start=559,asetpts=N/SR/TB[a1]; \
>>         [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" \
>>        -map "[v]" -map "[a]" 'output.mkv'
>>      Specifically, we removed the seconds 09:13 (second 553) to 09:19 (second 559).
>> Is this the correct way to do it (after setting the correct
>> timestamps), or is there a better way?
> It works, but there are a few problems. :'-(
> I cut 1:50 from a video of 18:51 to get a video to get a video of
> 17:01.
> The video goes from 402.4 MB to 341.8 MB.
> But the problem is that ffmpeg takes all my CPU and the speed is
> 0.359. It would be nice if there would be a more efficient option.
> What is also not nice is that the chapter info is not updated.
> But that is preventable: I could do first the cut and afterwards
> create the chapters. I would prefer the other way around, but I can
> life with that.
The problem is that when you do not cut on keyframes, the entire video 
needs to be reencoded. You will need to set the correct encoding 
parameters to make sure all streams and metadata are preserved. Better 
to post details about the proces (output of the ffmpeg command you have 
used. That way a better answer to your question might be given.

More information about the ffmpeg-user mailing list