[FFmpeg-user] Cutting out part of a video does not work

Peter White peter.white at posteo.net
Sat Mar 27 03:50:13 EET 2021


On Fri, Mar 26, 2021 at 04:40:26PM +0100, Bo Berglund wrote:
> On Fri, 26 Mar 2021 10:59:23 +0100, Peter White <peter.white at posteo.net> wrote:
> 
> >You can use ffprobe to find the keyframe timestamps:
> >
> >ffprobe -select_streams V:0 -show_frames -skip_frame nokey -show_entries frame=best_effort_timestamp_time 2021-03-25ToastmastersClubAvond.mp4
> >
> 
> I tested your command ona typical video file and found thta the output looks
> basically like this:
> 
> [FRAME]
> best_effort_timestamp_time=3900.000000
> [/FRAME]
> [FRAME]
> best_effort_timestamp_time=3905.000000
> [/FRAME]
> [FRAME]
> best_effort_timestamp_time=3910.000000
> [/FRAME]
> [FRAME]
> best_effort_timestamp_time=3915.000000
> [/FRAME]
> 
> It seems like there are "frames" at every 5 seconds.

Not to be picky, but there are certainly very many more frames. The
distinction is between *keyframes* and everything else called a frame.

> So on such videos is it impossible to cut say from time 2603 to 3401 and get a
> video of length 798 seconds?

Extrapolating from your above example, yes and no. If there is a
keyframe every five seconds, there is none at 2603, so you would need to
either start at 2600 or 2605. You can, however, make the video 768
seconds long, because the last frame need not be a keyframe. Or you
could cut the end short at 3401 seconds, no problem.

> What does ffmpeg do?
> Does it skip to the closest frame border or does it include both the starting
> and ending frame so giving a video time of 805 seconds?

It will find the last keyframe prior to the timestamp specified by -ss.
See the documentation or try it yourself.

> Switching from the copy handler to something else makes ffmpeg work a lot harder
> and processing time goes from 5 seconds to 30 minutes or so....

That is normal since now your CPU needs to actually encode the frames
and not just copy packets.


Cheers,
Peter


More information about the ffmpeg-user mailing list