[FFmpeg-devel] Feature to cut a video (-ss) with timings non aligned on keyframes, with minimal re-encoding

basj at gget.it basj at gget.it
Thu Aug 1 19:50:37 EEST 2024


Hi,

Before trying to develop a new feature, and diving in the code base, I wanted to know if it currently exists, or is already in a work-in-progress:

When cutting a video with no re-encoding:

    ffmpeg -ss 120 -t 60 -i input.mp4 -c copy output.mp4

the result is often choppy or non-smooth in the first seconds, because the cut point doesn't necessarily coincide with a keyframe, at least on some players (such as Media Player Classic, etc.).

Some more complex solutions involve reencoding just the beginning until the next keyframe, and then use copy codec for the rest of the video, and then concatenating, all of this requiring multiple calls of ffmpeg.

Is there a feature already in development that would allow to do this in one single pass of ffmpeg, without multiple calls and concatenation?

Something like:

    ffmpeg -ss 120 -t 60 -i input.mp4 -c copy -reencodebeforekeyframe output.mp4

Thanks,
Basj


More information about the ffmpeg-devel mailing list