Keyframe

On this page 7

A keyframe in video codecs is a frame that is compressed entirely on its own, without reference to any other frame, so a decoder can reconstruct it from its own data alone. In codecs such as H.264, H.265, VP9 and AV1, keyframes are usually intra-coded frames (I-frames), and they mark the points where decoding, seeking and stream switching can begin.

Keyframes are the anchors of inter-frame compression. The frames between them store only the differences from earlier or later pictures, which saves enormous amounts of data, so the keyframe interval becomes one of the most important encoder settings for quality, file size, latency and editability.

How keyframes anchor inter-frame compression

Modern codecs exploit the fact that consecutive frames are highly similar. Instead of storing every frame completely, the encoder stores one full picture and then describes later pictures through motion vectors and residual differences relative to that reference.

This chain of dependencies is organized into a group of pictures (GOP). Each GOP begins with a keyframe, followed by predicted frames that refer back to it directly or indirectly, so a decoder that starts in the middle of a GOP cannot reconstruct the predicted frames until it reaches the next keyframe.

The table below compares the three classic frame types used in long-GOP compression.

Frame typeReferences usedRelative sizeRole
I-frame (keyframe)None, intra-coded onlyLargestRandom access and refresh point
P-frameEarlier framesMediumForward prediction
B-frameEarlier and later framesSmallestBidirectional prediction
Frame types in long-GOP compression

An I-frame typically needs several times more bits than a P-frame or B-frame of similar quality. The exact ratio depends on the content: static scenes compress predicted frames very efficiently, while fast motion and camera shake reduce the advantage.

IDR frames, open GOPs and closed GOPs

Not every I-frame is a full random access point. In H.264 and H.265, an IDR frame (instantaneous decoder refresh) clears the decoder’s reference buffer, guaranteeing that no later frame refers to anything before it.

A regular I-frame in an open GOP may still be followed by B-frames that refer to the previous GOP. Open GOPs compress slightly better, while closed GOPs start cleanly and are preferred for streaming segments, broadcast splicing and editing.

VariantCodec contextRandom accessTypical use
IDR frameH.264, H.265Clean, buffer is resetStreaming segments, chapter points
CRA frameH.265Possible, with skipped leading framesOpen-GOP efficiency with seeking
Non-IDR I-frameH.264, H.265Limited in open GOPsMid-GOP quality refresh
Key frameVP9, AV1Clean decoding startWeb streaming and seeking
Intra-only frameAV1, VP9Partial, keeps some stateError recovery
Keyframe variants in common codecs

For practical purposes, players and editors treat IDR frames and equivalent key frames as true keyframes. When a platform requests a keyframe every two seconds, it means a clean random access point, not merely any intra-coded picture.

Choosing the keyframe interval

The keyframe interval, often called GOP length, sets the maximum distance between keyframes, expressed in frames or seconds. A short interval improves seeking, error recovery and stream switching, while a long interval improves compression efficiency because fewer large frames are stored.

Most encoders also insert keyframes automatically at scene changes, because predicting a completely new picture from the previous scene wastes bits. This scene-cut detection means the actual distance between keyframes is often shorter than the configured maximum.

ApplicationTypical intervalReason
Adaptive streaming (HLS, DASH)About 2 seconds, fixedAligns segments across bitrate renditions
Live streaming to platformsAbout 2 secondsFast joining and stable ingest
Video on demand filesAbout 2 to 10 secondsBalance of seeking and efficiency
Broadcast transmissionAbout 0.5 to 1 secondQuick channel changes
Video conferencingLong, with on-demand refreshLow bitrate, recovery after loss
Editing intermediatesEvery frameFrame-accurate cutting
Typical keyframe intervals by application

Keyframes in editing and playback

Keyframes explain why long-GOP footage feels sluggish in editing software. To display a frame in the middle of a GOP, the editor must decode the keyframe and every dependent frame up to the requested position, which costs processing time on every scrub and cut.

This is the main reason editors use intra-frame codecs such as ProRes or DNxHR, in which every frame is effectively a keyframe. Files grow many times larger, but each frame decodes independently, so timelines play back smoothly and cuts land on exact frames.

Keyframes also limit lossless trimming. Tools that cut a file without re-encoding can only start a clip at a keyframe, so a cut placed between keyframes is either moved to the nearest one or requires re-encoding of the affected GOP, sometimes called smart rendering.

In playback, a keyframe is where a player can resume after a seek or recover after a transmission error. Corrupted predicted frames spread visible artifacts until the next keyframe arrives, which is why lossy networks favor regular refresh points.

Poorly configured keyframes cause recognizable artifacts and workflow failures. The following table links common symptoms to their likely causes and practical fixes.

SymptomLikely causeFix
Periodic quality pulsingKeyframes much sharper than predicted framesTune rate control, use longer lookahead
Slow seekingVery long keyframe intervalShorten the maximum GOP length
Adaptive streaming errorsKeyframes not aligned across renditionsFix interval, disable scene-cut insertion
Smearing after packet lossNo refresh point for long periodsEnable periodic intra refresh
Inaccurate cuts without re-encodingCut points between keyframesRe-encode or cut at keyframes
Keyframe problems, causes and fixes

Note that keyframe in video codecs differs from keyframing in animation. In motion graphics, a keyframe stores a parameter value at a point in time for interpolation, which is an entirely separate concept that shares only the name.

The short version

Video files save space by storing most frames as changes from earlier frames rather than as full pictures. A keyframe is a complete picture that does not depend on anything else.

Think of a flip book in which only a few pages are fully drawn and the rest show only what moved. You can start reading only at a fully drawn page. That is why keyframes decide how quickly you can jump to a point in a video and how large the file becomes.

Where it makes a difference

A streaming engineer prepares a live sports channel in five bitrate renditions for adaptive streaming at 50 frames per second. She sets a fixed keyframe interval of 100 frames, exactly two seconds, uses closed GOPs and disables extra scene-cut keyframes so that every rendition starts its segments on the same frame.

Viewers’ players can now switch between renditions at each two-second segment boundary without glitches. New viewers join within seconds, and the slight efficiency loss compared with a longer interval is a deliberate trade-off for reliability during the live event.