[FFmpeg-user] What is the correct way to cut the video with ffmpeg?

Cley Faye cleyfaye at gmail.com
Tue Jun 21 18:05:19 CEST 2016


2016-06-21 17:44 GMT+02:00 桃源老師 <xanadu6291 at dream.jp>:

> Still curious about cutting video on non key frame is correct or not...


​Depends on your definition of correct, but for my definition (which is, I
need an output file that play fine in most players) I'd say "no".
It varies between codecs of course, but "usually", if you don't reencode,
cutting anywhere else than a key frame will result in a garbled stream up
until the next key frame.
>From this page: https://trac.ffmpeg.org/wiki/Seeking the behavior of ffmpeg
when seeking and *not* transcoding is to seek to an i-frame (key frame) and
adjust the stream timestamp accordingly, which might be why some players
are confused.

If you want accurate seeking outside of keyframes without some sort of
timestamp adjustment, you'll have to transcode the video/audio. You can
either transcode the whole segment, or just transcode up to the next
keyframe then copy from there but as far as I know you'll have to do it "by
hand".


More information about the ffmpeg-user mailing list