Understanding Keyframes: A Comprehensive Guide to the Heart of Encoding
In the ever-evolving world of digital content, it is essential to understand the core elements behind your favorite videos. One of these critical elements is a 'keyframe.' This article aims to dive into the concept of a keyframe, its role in video processing, and the types of frames including I, P, B, and IDR frames.
What is a Keyframe?
A keyframe, in video technology, refers to a frame in a sequence of frames where a complete image is stored in the data stream. It serves as a reference point for other frames and is a fundamental component in both video compression and animation.
In video compression, a keyframe sets the stage for subsequent frames, defining the starting point for changes in the scene. The other frames, often comprising changes from the keyframe, require less data, hence compressing the size of the video.
In animation and computer graphics, a keyframe signifies a point of change. Here, the keyframe holds specific values that define the start and end points of any smooth transition.
Different Types of Frames: I, P, B, and IDR
Understanding the various types of frames, namely I-frames (Intra-coded), P-frames (Predicted), B-frames (Bidirectional), and IDR-frames (Instantaneous Decoder Refresh), is crucial to grasp how video compression and keyframes work together.
I-frames
An I-frame, or Intra-coded frame, is a self-contained frame that doesn't rely on any other frame for decoding. In simple terms, each I-frame is a keyframe containing all the necessary data to represent a complete image. Because they don't reference other frames, I-frames use more data but also serve as the starting points for sequences and recovery points if data is lost or corrupted.
P-frames
P-frames, or Predicted frames, follow I-frames in a sequence. A P-frame holds the differences between itself and the closest preceding I-frame or P-frame. They are more compressed than I-frames since they only contain changes from the reference frame, reducing the amount of data required.
B-frames
B-frames, or Bidirectional frames, are the most compressed frames. A B-frame carries only the differences between itself and both the preceding and following frames (either I or P). By referencing both past and future frames, B-frames can achieve higher compression rates.
IDR-frames
IDR-frames, or Instantaneous Decoder Refresh frames, are a special type of I-frame used in modern video codecs like H.264 and H.265 (HEVC). An IDR-frame signals the decoder to clear previously accumulated reference frames. It essentially resets the decoder, providing a fresh start for the new sequence of frames.
Article written by
Sylvain Corvaisier

Independent streaming and iOS engineer
Last modified: January 13th, 2025