What is a keyframe?
In video streaming, a keyframe, also known as an "I-frame" (intra-frame), is a complete and self-contained frame that does not depend on any other frames for its display. Keyframes serve as reference points for decoding and displaying subsequent frames in a video stream.
Keyframes consume the most data and bandwidth among all frame types in video streaming. They are encoded as full-resolution frames, containing all the necessary pixel data to represent a complete frame without reference to other frames. As a result, keyframes generally have larger file sizes compared to other frame types such as P-frames (predictive frames) or B-frames (bi-directional frames).
While keyframes consume more data, they play a crucial role in video compression. Video compression algorithms, such as H.264 (AVC) or H.265 (HEVC), utilize keyframes in combination with other frame types to reduce the amount of data required to transmit or store a video. P-frames and B-frames, unlike keyframes, only store changes or differences from a reference frame, which can be a keyframe or another P-frame. By encoding these changes, the size of P-frames and B-frames can be significantly smaller, resulting in more efficient compression.
Keyframes are inserted at regular intervals throughout a video stream, with the exact frequency determined by the encoding settings or streaming protocol being used. This balance is essential as too many keyframes can increase the data size and bandwidth requirements, while too few keyframes can affect seeking or error recovery efficiency.
Moreover, within the category of keyframes, there is a specific type called IDR frames (Instantaneous Decoder Refresh frames). IDR frames serve as both keyframes and reset points for the decoder. When an IDR frame is encountered during decoding, the decoder discards any previously stored reference frames and starts decoding from that point onwards. This ensures that any decoding errors or artifacts that may have accumulated in the reference frames are eliminated, preventing error propagation throughout the video stream. IDR frames provide a clean slate for the decoder, improving error resilience and enabling efficient random access within the video stream.
In summary, keyframes, including IDR frames, are frames in video streaming that consume the most data and bandwidth. They are complete and self-contained frames that serve as reference points for subsequent frames. Keyframes are necessary for maintaining video quality and enabling random access. While they have larger file sizes compared to other frame types, the inclusion of keyframes, including IDR frames, in the video stream allows for efficient compression and optimal error resilience.