[FFmpeg-user] optimal exact segmentation without re-encoding

David Bernat david.bernat at gmail.com
Thu Jul 6 01:29:17 EEST 2023

Hello: new users, common use-case. Please be polite. Ten hours of
experimentation so far.
Premise: segment a mov file into about one second segments without
re-encoding; yet preserving concatenation; such that the segmentation is
embarrassingly parallel, for high-speed segmenting.
File: one minute mov file with variable fps; keyframes every approximately
one second.

What I have tried: ffprobe provide timestamps of keyframes. Using ffmpeg to
copy with -ss seeking from one keyframe to the next keyframe successfully
creates ~one second segments. As most of you know, these segments will
contain negative timestamps and extra frames, depending on what processing
each keyframe uses. Concatenation keeps these extra frames, which is not

Using ffmpeg trim on each of these segments successfully re-encodes the
segments to be from exactly the timestamp of one keyframe to another (by
recalculating internal keyframes); but this process is very slow (0.25x).
Worst case is that this trim operation is embarrassingly parallel.

My hunch is that there ought to be a way to drop those undesired frames
directly from the segments creates using -ss. Or, that the worse case
scenario is to create new keyframes in the original one minute file that is
better used for -ss copying.

A new notes:
1. the segments do not need to be exactly one second
2. the only constraint is that segment creation is fast and concat
reconstructs the original.

I have compiled great notes with speed benchmarks. Happy to publish after I
solve this.

Thank you so deeply.

David Bernat, Ph. D.
text: 917-825-7193 / LinkedIn <https://www.linkedin.com/in/david-bernat/>
All content should be considered proprietary to Starlight LLC and
Confidential or higher

More information about the ffmpeg-user mailing list