ENPTES Free trial

I-frames, P-frames, B-frames and the GOP

The three kinds of frame inside H.264 and HEVC video, and the group they form.

Short answer

Codecs such as H.264 and HEVC store video as three kinds of frame. An I-frame is a complete picture that can be decoded on its own. A P-frame stores only what changed in relation to earlier frames. A B-frame stores what changed in relation to frames before and after it. A GOP, or group of pictures, is the sequence that starts at one I-frame and runs until the next.

The main screen of NWK Live Production with Preview, Program and the status bar at the bottom
The main screen of NWK Live Production with Preview, Program and the status bar at the bottom
On this page
  1. The three kinds of frame
  2. What the GOP is
  3. What this changes in a live stream
  4. What this changes in recording and editing
  5. Common confusions
  6. Related questions

The three kinds of frame

FrameWhat it containsDepends onSize
I (intra)The whole pictureNothingLargest
P (predicted)The differences from earlier framesFrames before itMuch smaller
B (bidirectional)The differences from earlier and later framesFrames before and after itUsually the smallest

Most of a normal video repeats from one frame to the next: the wall behind a presenter does not change. P-frames and B-frames exploit that repetition, and that is where most of the compression of H.264 and HEVC comes from.

What the GOP is

A GOP is one I-frame followed by the P-frames and B-frames that depend on it, directly or through each other. A typical pattern looks like I B B P B B P and so on, until the next I-frame starts a new group.

GOP length is counted in frames. The keyframe interval that streaming settings ask for is the same thing counted in seconds: at 30 frames per second, an interval of 2 seconds is a GOP of 60 frames. The page on the keyframe interval covers what to set for a live stream.

What this changes in a live stream

  • Joining. A player can only start showing video at an I-frame. A long GOP makes a viewer wait longer for the first picture.
  • Errors. When data is lost on the way, the damage can spread to every frame that depends on the damaged one. The picture cleans up at the next I-frame.
  • Data rate. I-frames are large. A short GOP spends more of the bitrate on I-frames and leaves less for the frames between them, so quality drops at the same bitrate.
  • Delay. To build a B-frame, the encoder has to wait for a later frame. B-frames improve quality at a given bitrate and add a little delay, which is why low-latency settings often turn them off.

What this changes in recording and editing

Video built from long GOPs is called long-GOP video. Recordings in H.264 and HEVC are long-GOP: small files, and more work for the editing program, which has to decode several frames to show one. Codecs made for editing, such as ProRes, use only I-frames: every frame stands alone, the files are much larger and the timeline responds faster.

Common confusions

  • Keyframe and I-frame. In streaming settings, the two words are used for the same thing. Strictly, a keyframe is an I-frame after which no frame refers to anything earlier; H.264 calls that an IDR frame.
  • Keyframe in animation. In an editing or motion program, a keyframe marks a point where a property changes. That keyframe has nothing to do with compression.

Related questions

What is a good GOP length for live streaming?

Follow the keyframe interval that the platform publishes. A common value is 2 seconds, which is 60 frames at 30 frames per second and 120 frames at 60 frames per second. Keep the interval fixed, not automatic.

Should I use B-frames when streaming?

B-frames give better quality at the same bitrate and add a little delay. For a normal stream to a platform, a small number of B-frames is fine when the platform accepts them. When the goal is the lowest possible delay, turn B-frames off.

Why does the picture break up and then fix itself?

Some data was lost or arrived damaged, and the frames that depended on that data were decoded wrong. The next I-frame does not depend on any other frame, so the picture comes back clean when that I-frame arrives.

In the NWK help center

Written and reviewed by the NWK Live Production team (Setor 360 Tecnologia e Eventos Ltda). Published .

NWK sets resolution, frames and bitrate for each destination and records the Program in H.264 or HEVC.

Try NWK free for 7 days