Skip to content Skip to sidebar Skip to footer

What Does Forcing Key Frames Mean?

What does forcing key frames mean? As per the doc -force_key_frames[:stream_specifier] expr:expr (output,per-stream) Force key frames at the specified timestamps, more precisely

Solution 1:

A typical video codec uses temporal compression i.e. most frames only store the difference with respect to earlier (and in some cases, future) frames. So, in order to decode these frames, earlier frames have to be referenced, in order to generate a full image. In short, keyframes are frames which don't rely on other frames for decoding, and which other frames rely on in order to get decoded.

If a video has to be cut or segmented, without transcoding (recompression), then the segmenting can only occur at keyframes, so that the first frame of a segment is a keyframe. If this were not the case, then the frames of a segment till the next keyframe could not be played.

A encoder like x264 typically generates keyframes only if it detects that a scene change has occurred*. This isn't conducive for segmentation, as the keyframes may be generated at irregular intervals. In order to ensure that segments of identical and predictable lengths can be made, the force_key_frames option can be used to ensure desired keyframe placement.

-force_key_frames expr:gte(t,n_forced*5) forces a keyframe at t=5,10,15 seconds...

The GOP size option g is another method to ensure keyframe placement, e.g. -g 50 forces a keyframe every 50 frames.

*subject to minimum and maximum keyframe distance parameters.


Post a Comment for "What Does Forcing Key Frames Mean?"