GOP

On this page 7

A GOP, short for group of pictures, is the sequence of compressed frames between two independently decodable I-frames in interframe video codecs such as MPEG-2, H.264, H.265 and AV1. It defines which frames are stored whole and which are stored only as differences from other frames, and therefore controls the balance between compression efficiency, seeking speed and error resilience.

A GOP is usually described by two numbers: its length N, the distance between I-frames, and M, the spacing of reference frames, which reveals how many B-frames sit between them. A structure written as IBBPBBP with N = 12 and M = 3 was typical of broadcast MPEG-2.

How a GOP is built from frame types

A GOP is built from three frame types that differ in what they reference. Interframe compression exploits the fact that consecutive frames are similar, so most frames are encoded as motion vectors and residual differences relative to a reference rather than as complete images.

Frame typeReferencesRelative sizeRole
I-frameNone, intra-codedLargestEntry point for decoding and seeking
P-frameEarlier framesMediumPredicts forward from past frames
B-frameEarlier and later framesSmallestBidirectional prediction, best compression
IDR frameNone, and clears reference buffersLargeHard reset point in H.264 and H.265
Frame types inside a group of pictures

Because B-frames reference future frames, the encoder must reorder frames so that references arrive first. The decode order differs from display order, which adds latency and memory use. Real-time conferencing encoders often disable B-frames for that reason.

The hierarchy of B-frames adds a further layer in modern codecs. H.264, H.265 and AV1 allow some B-frames to serve as references for others, forming a pyramid structure in which frames closer to the base receive more bits and frames at the top receive fewer. This arrangement improves efficiency noticeably on slow, stable footage, but it increases encoder delay and the number of frames held in memory.

Open and closed GOP structures

A closed GOP can be decoded completely without any frame from the previous GOP, while an open GOP allows its first B-frames to reference the last frames of the preceding group. Open GOPs compress slightly better, but they complicate cutting and splicing.

PropertyClosed GOPOpen GOP
Cross-GOP referencesNot allowedAllowed for leading B-frames
Compression efficiencySlightly lowerSlightly higher
Splicing and editingClean cut at every I-frameLeading frames may be undecodable after a cut
Adaptive streamingRequired for segment boundariesGenerally avoided
Typical useStreaming, broadcast splicingArchival or single-file delivery
Open versus closed GOP

Adaptive bitrate streaming formats segment video into chunks of a few seconds, and each segment must start with a closed GOP aligned across all renditions. Otherwise the player cannot switch quality cleanly at segment boundaries.

Choosing GOP length

GOP length is a trade-off between efficiency and accessibility. Longer GOPs spend fewer bits on large I-frames, so quality at a given bitrate improves, but random access becomes slower and an error persists longer before the next I-frame clears it. Typical lengths are expressed either in frames or in seconds.

ApplicationTypical GOP lengthReason
Broadcast MPEG-212 to 15 frames, about half a secondFast channel changes
Live streaming2 seconds, fixedAligns with short segments, low latency
On-demand streaming2 to 6 seconds, matched to segmentEfficiency with clean switching
Camera long-GOP recordingAbout half a second to one secondCompact files with acceptable editing
File archive or downloadUp to 10 seconds or moreMaximum efficiency
Video conferencingVery long, with I-frames on requestLow bitrate, refresh only after loss
Typical GOP lengths by application

Most modern encoders also use scene-cut detection, inserting an I-frame when the picture changes completely, because predicting a new scene from the old one wastes bits. With a fixed GOP required for streaming, scene-cut insertion is often restricted to keep segment alignment intact.

In practice, GOP length should be set in seconds and converted to frames for each frame rate. A two-second GOP is 48 frames at 24p, 50 frames at 25p and 120 frames at 60p, so copying a frame count from one project to another can silently change the keyframe interval.

Long-GOP versus intra-frame codecs

Codecs fall into two families according to GOP structure. Long-GOP codecs use I-, P- and B-frames for delivery and efficient recording, while intra-frame codecs such as ProRes and DNxHR encode every frame as an I-frame, which is equivalent to a GOP length of one.

AspectLong-GOPIntra-frame
Bitrate for similar qualityMuch lowerSeveral times higher
Editing responsivenessSlower scrubbing, more decoding workFast, every frame independent
Error resilienceError spreads until next I-frameError confined to one frame
Typical examplesH.264, H.265, AV1, VP9ProRes, DNxHR, intra-only H.264
Main roleDelivery and compact recordingEditing, grading, mastering
Long-GOP and intra-frame codecs compared

This is why editors often create proxy or mezzanine files in an intra-frame codec. Seeking to any frame in a long-GOP file requires decoding from the previous I-frame, which strains playback on timelines with many layers.

Common GOP problems and mistakes

Many visible artifacts in streamed and recorded video can be traced to a poorly chosen GOP structure. Diagnosing them begins with checking the I-frame interval and whether keyframes align with segments.

  • I-frame pulsing: a visible quality jump every few seconds when I-frames are coded at a different quality than surrounding frames.
  • Slow stream start: viewers wait for the next I-frame when the GOP is too long for live delivery.
  • Misaligned keyframes: renditions with different GOP boundaries cause stalls or glitches when the player switches quality.
  • Corrupted cuts: trimming an open-GOP file without re-encoding can leave undecodable frames at the edit point.
  • Confusing keyframe with GOP: the keyframe interval sets GOP length, but the GOP also includes the arrangement of P- and B-frames.

The simple explanation

Video files save space by not storing every picture in full. Every so often they store one complete picture. For the pictures that follow, they store only what has changed, such as a moving arm.

A GOP is one such run: a complete picture followed by a series of change notes. Longer runs save more space. The catch is recovery. If a note is damaged, or you jump into the middle of the video, the player must go back to the last complete picture first.

How it is used in practice

A sports streaming service delivers a live match at 50 frames per second in six quality levels, from mobile to 4K. Its engineers configure the encoder with a fixed GOP of 100 frames, exactly two seconds, with closed GOPs and B-frames enabled, and they align I-frames across all six renditions.

Each two-second segment therefore begins with an I-frame, so players can switch quality at every boundary when a viewer’s connection changes. Scene-cut insertion is limited so it cannot break alignment. The result is smooth quality switching and a delay of only a few seconds behind the live action, while bitrates stay far lower than an intra-frame stream would need.