B-frames, short for Bi-directional Predictive frames, are the most advanced type of predictive
frame used in video compression. They offer the highest compression efficiency by leveraging
information from both preceding and succeeding I-frames or P-frames.
Here's a deeper look at B-frames:
How B-frames Work:
● Bidirectional Prediction: Unlike P-frames that only look at past reference frames,
B-frames can use motion estimation to find similar blocks in both the previous and the
next reference frames.
● Interpolation: The encoder can then create a prediction for a block in the B-frame by
interpolating between the corresponding blocks found in the past and future reference
frames. This can often lead to a more accurate prediction than using only forward
prediction (like in P-frames), especially for complex motion or when objects are
temporarily obscured.
● Motion Vectors: B-frames can have one motion vector referencing a past frame, one
referencing a future frame, or even two motion vectors (one for past and one for future),
which are then combined (interpolated) to predict the current block.
● Residual Data: Similar to P-frames, B-frames also store residual data representing the
difference between the predicted block and the actual block in the current frame.
Advantages of Using B-frames:
● Highest Compression Efficiency: By utilizing information from both past and future
frames, B-frames can often achieve a more accurate prediction, resulting in smaller
residual data and thus higher compression ratios compared to I and P frames. This
means smaller file sizes for the same visual quality.
● Improved Quality for Complex Motion: B-frames can handle more complex types of
motion and scene changes more effectively than P-frames, potentially leading to better
visual quality at lower bitrates.
● No Dependence for Future Prediction: Importantly, B-frames are not used as
reference frames for predicting subsequent P-frames or other B-frames. This means that
errors in a B-frame will not propagate to future frames.
Disadvantages of Using B-frames:
● Increased Encoding Complexity: The process of bidirectional motion estimation and
interpolation is more computationally intensive for the encoder.
● Increased Decoding Complexity: Decoders also require more processing power and
memory to handle B-frames because they might need to store future reference frames
before decoding the current B-frame.
● Introduced Delay (Latency): Because a B-frame might refer to a future frame, the
encoder and decoder need to reorder the frames. The future reference frame needs to be
encoded/decoded before the B-frame that refers to it. This introduces a slight delay, which
can be a concern for real-time applications like video conferencing.
Frame Display Order vs. Decoding Order:
Due to the bidirectional prediction, the order in which B-frames are displayed is often different
from the order in which they are decoded. For example, a short sequence might have a
decoding order of I-P-B-B-P, but the display order would be I-B-B-P-P. The decoder reorders the
frames for correct playback using presentation timestamps.
Common Usage:
B-frames are widely used in modern video codecs like MPEG-4, H.264 (AVC), H.265 (HEVC),
VP9, and AV1 to achieve high compression efficiency for various applications like streaming,
Blu-ray discs, and digital storage. However, for low-latency applications, the use of B-frames
might be limited or avoided altogether.
In summary, B-frames are a powerful tool in video compression that significantly
improves efficiency by using bidirectional prediction. While they introduce some
complexity and potential delay, their ability to reduce file size without significant quality
loss makes them a cornerstone of modern video coding.