B-frame

Also known as: bidirectional predicted frame

On this page 7

A B-frame, or bidirectional predicted frame, is a compressed picture that is reconstructed by predicting from both a past and a future reference frame. In video codecs such as MPEG-2, H.264, H.265 and AV1, B-frames are usually the smallest frames in the stream, because they can borrow the best-matching blocks from either direction and encode only the residual difference.

B-frames are one of the three classic frame types in video compression, alongside the self-contained I-frame and the forward-predicted P-frame. They deliver significant bitrate savings at equal quality, but they force the encoder and decoder to process frames out of display order, which adds delay and complexity.

How a B-frame predicts from two directions

A B-frame divides the picture into blocks, and for each block the encoder searches one or two reference frames for a similar region. It can use forward prediction from an earlier frame, backward prediction from a later frame, or bi-prediction, which averages two predictions to reduce noise and handle uncovered areas.

The encoder then transmits motion vectors that point to the reference regions and a quantized residual that corrects the remaining error. Because averaging two references often produces a very close match, the residual is small, and the frame needs far fewer bits than an I-frame or a P-frame of the same content.

The following table compares the three main frame types in a typical stream.

Frame typeReferencesRelative sizeRole
I-frameNone, intra-coded onlyLargestRandom access and error recovery
P-frameEarlier framesMediumForward prediction chain
B-frameEarlier and later framesSmallestMaximum compression between anchors
Frame types in inter-frame compression

Decode order, display order and the GOP

B-frames require decode order to differ from display order. A B-frame cannot be decoded until its future reference has arrived, so the encoder sends that later anchor first. A display sequence of I B B P is therefore transmitted as I P B B, and the decoder reorders the frames using presentation timestamps.

This reordering is defined inside the GOP (group of pictures) structure. A common broadcast pattern uses two B-frames between anchors, while modern encoders often place three to eight consecutive B-frames when content is static. Each extra B-frame between anchors adds roughly one frame of reordering delay.

PositionDisplay orderDecode order
1I0I0
2B1P3
3B2B1
4P3B2
5B4P6
Example of display and decode order

In MPEG-2 and early H.264 profiles, B-frames could not serve as references. Later codecs allow reference B-frames, which leads to hierarchical B-pyramids in which some B-frames predict others, improving efficiency further.

In a hierarchical B-pyramid, the middle B-frame of a run is encoded first at a slightly lower quantizer and then serves as a reference for the frames on either side. Higher layers of the pyramid receive coarser quantization, because errors in them do not propagate. This layered allocation of bits is a major reason why modern encoders outperform the fixed IBBP patterns of earlier broadcast systems.

Container formats must carry both orders correctly. Each frame has a decode timestamp and a presentation timestamp, and muxers in MP4 or MPEG-TS use a composition time offset to express the difference. When these values are wrong, players show stutter, frozen frames or audio drift, even though the compressed video itself is valid.

B-frames across codec generations

Support for B-frames has grown more flexible with each codec generation. Modern standards give the encoder freedom to choose references and weighting, which is why B-frames contribute a growing share of the compression gain in H.264, H.265, H.266 and AV1.

CodecB-frame supportNotable feature
MPEG-2Yes, non-reference onlyFixed patterns such as IBBP
H.264Yes, including reference B-framesB-pyramid and weighted prediction
H.265Yes, generalized B slicesHierarchical random-access configurations
VP9No classic B-framesAlternate reference frames and hidden frames
AV1Bidirectional compound predictionMultiple forward and backward references
ProRes and DNxHRNoneIntra-frame codec for editing
B-frame capabilities by codec

Intra-frame codecs such as ProRes, DNxHR and Motion JPEG avoid B-frames entirely. They sacrifice compression efficiency to keep every frame independently decodable, which makes scrubbing and frame-accurate editing faster.

Choosing B-frame settings in an encoder

Encoder settings for B-frames balance compression, latency and decoder compatibility. Tools such as x264, x265 and hardware encoders such as NVENC expose the maximum number of consecutive B-frames, adaptive placement and whether B-frames may serve as references.

Adaptive B-frame decision lets the encoder insert fewer B-frames during fast motion or scene changes and more during static shots. When combined with a constant rate factor, this usually yields the best quality per bit without manual tuning.

ApplicationB-frame settingReason
On-demand streaming3 to 8, adaptive, B-pyramid onEfficiency matters more than delay
Broadcast contribution2 to 3, fixed patternPredictable bitrate and compatibility
Live low-latency streaming0 to 1Each B-frame adds reordering delay
Video conferencing0Interactive latency must stay minimal
Editing intermediatesNone, intra-onlyFast seeking and frame-accurate cuts
Recommended B-frame use by application

Limitations and misconceptions about B-frames

The most important limitation is added latency. Because a B-frame waits for a future anchor, a stream with three consecutive B-frames introduces at least three frames of delay at the encoder, which is unacceptable for real-time communication.

B-frames also increase encoder computation and decoder memory, since more reference pictures must be buffered. Older or low-power devices may support only Baseline or constrained profiles that exclude B-frames, so compatibility targets can rule them out.

  • B-frames do not lower image quality by themselves; at the same bitrate they usually raise quality.
  • B-frames are not keyframes; a decoder cannot start playback from one.
  • More B-frames are not always better; during fast motion the prediction weakens and gains disappear.
  • Editing long-GOP footage with many B-frames is slower because frames depend on later data.

In everyday language

A video is a fast series of pictures, and most pictures look almost the same as the ones before and after them. A B-frame takes advantage of that. Instead of storing a whole new picture, it says build me from the frame before and the frame after, plus a few small corrections.

This is like describing a middle step in a flip-book by pointing to the pages on both sides. The file becomes much smaller, but the player has to look ahead a little, so there is a short delay that matters only for live, interactive video.

Seen in the real world

A streaming platform encodes a 90-minute film in H.265 for on-demand viewers. The engineers allow up to five adaptive B-frames with a B-pyramid and keep a two-second GOP. Compared with a test encode that disabled B-frames, the final files reach the same visual quality score at roughly a quarter less bitrate, which reduces delivery costs and buffering on slower connections.

The same team runs a separate live channel for interactive sports commentary. There they set B-frames to zero, accepting a higher bitrate in exchange for the lowest possible delay between the camera and the viewer, and the result is a stream with sub-second encoding latency.