[FFmpeg-user] Inaccurate trimming with re-encoding
cmharwoo at umich.edu
Tue Aug 6 20:05:13 CEST 2013
> In H.264, or any other codecs, there is a compression technique called
> inter-frame compression. Because of inter-frame compression, typically you
> cannot cut H.264 video stream based on frame numbers without round-off
> error. You’re right, round-off error ‘usually’ resulted in inaccurate
> trimming; instead of cutting at exactly the frame number you specified,
> what you got was usually with round-off error. In fact, that’s exactly
> what happened if you use mkvtoolnix directly to cut the video into pieces.
> However, the method I described in the slideshow did not have such issue.
> The round-off error problem was put away because of the constant frame
> rate of 1 FPS. No, it would not get to the nearest key frame; it would get
> to exactly the frame or ‘time’ you specified. If you think about it, it’s
> pretty much like how to extract all frames (no matter whether or not they
> are key frames) to individual images; to be in more details, it actually
> involves both decoding and encoding process.
> The typical lossy encoding process would result in the loss of quality.
> Strictly speaking, it’s not possible for absolutely accurate trimming to
> happen without re-encoding process for the source with inter-frame
> compression. However, what really happens here is can be thought to be
> “lossless encoding”; but it’s not to create a video file of “lossless
> compression” but just cut a portion of video out. As you may already know
> -codec “copy” is to instruct the encoder the copy the stream without
> re-encoding. But you can also say re-encoding is also happening; it’s just
> that no change of information would occur in direct stream copying. To be
> more specific, you just copy a single frame from the H.264 source; if that
> happens to be non-key frame from the source, it would be the key frame for
> the output file; but this is strictly stream-copying process, thus no
> mathematical loss of information would occur in this process; it’s copying
> data from multiple frames from the source to be a single key frame in the
> output file.
I stand corrected. Thanks a ton for taking the time to explain that. I'm
definitely going to try this out. It looks like mkvtoolnix has a command
line execution, so I should be able to execute everything programmatically.
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Inaccurate-trimming-with-re-encoding-tp4660437p4660528.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
More information about the ffmpeg-user