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

Michael Niedermayer michael at niedermayer.cc
Mon Jul 21 21:39:38 EEST 2025


Hi

On Sun, Jul 20, 2025 at 09:54:09PM +0000, basj at gget.it wrote:
> Hi,
> 
> Out of curiosity, has there been any progress since 1 year about this topic?
> 
> Really, millions of CPU-hours are probably wasted to reencode already-perfectly-encoded content, just for cutting purposes. For example, is there a way to cut a AVI or MKV H264 video with a specific starting point and specific length, with minimal re-encoding?
> 
> When using: "ffmpeg -ss 120 -t 60 -i input.mp4 -c copy output.mp4",

> the result is often choppy or non-smooth in the first seconds,

clean patch welcome


> because the cut point doesn't necessarily coincide with a keyframe, at least on some players.
> 
> We could reencode just the beginning until the next keyframe, and then use copy codec for the rest of the video, and then concatenate, but nobody does this, it's unnecessarily complex (and I'm not even sure it works).

theres some recent talk about edit lists, maybe what you describe is
another use case of proper edit list rendering


> 
> 20 Aug 2024, 22:34, michael at niedermayer.cc wrote:
> 
> > Such signalling can be added to existing containers with little effort.
> > Iam also happy to help to add it to nut
> 
> Can you explain with a little bit more details how it would work? Thanks in advance!

Its a year since that mail you reply to, but
IIRC that just refered to that any data you want to attach you can attach in
nut. To frames, to streams, to any timespans and so on.

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250721/a0971ef3/attachment.sig>


More information about the ffmpeg-devel mailing list