By Dan Molenhouse, Solutions Engineer
Overview
Modern video compression algorithms (video codecs) utilize two primary techniques, intraframe and interframe compression, to achieve file size reduction.
Intraframe compression (also called spatial compression) reduces the size of each individual frame independently by reducing redundant information within the frame, similar to how JPEG compression works for still images. This compression technique reduces file size while maintaining high image quality.
Interframe compression (also called temporal compression) reduces file size across multiple frames by creating a starting point and then only saving the changes in subsequent frames. By using this compression technique, only the changes between frames are saved resulting in drastically reduced file sizes.
Modern video codecs, like H.264 and H.265, combine these two techniques to reduce file sizes while maintaining acceptable video quality and significantly improve the efficiency of sharing and streaming large media files.
Video Codec Background
Video codecs (short for “coder-decoder”) were implemented as a critical technology in the digital media landscape primarily to address the challenges of managing and transmitting large media files. The substantial size of uncompressed video data made it impractical to store and transmit these files over limited bandwidth networks. Video codecs are used to both compress (encode) and decompress (decode) video files, making streaming and storing large volumes of media possible. The video streaming services popular today would not be possible without video codecs.
Intraframe (Spatial) Compression
This technique compresses each frame individually by eliminating redundant information within a single frame. This is achieved by analyzing segments of the image and identifying regions with minimal variation and representing them more efficiently.
For example, the clear blue sky in the image below has very little variation between pixels, so those regions can be represented by a larger block of uniform color and texture. This reduces the amount of information that needs to be retained and will not drastically affect the final image quality.
In contrast, the areas with more complexity and color variation cannot be compressed to the same degree and more information needs to be retained in these regions. Spatial compression thus reduces file size while maintaining a high-quality image by retaining information in complex and highly detailed regions while reducing information in simple and less important areas.
Interframe (Temporal) Compression
Interframe, or temporal, compression reduces file sizes by eliminating redundant information between multiple frames of video. This is achieved by identifying and encoding only the changes between successive frames and eliminating areas that remain identical between them.
For example, the background of an image may remain unchanged while the subject of the video moves throughout the video. Instead of retaining the unchanging background in every frame, it can be retained in the first frame and used for all subsequent frames.
The process begins with selecting a keyframe (also called an I-frame) which is a fully intact frame and will serve as the reference for subsequent frames. Following the keyframe are P-frames and B-frames which will not be retained in full. Instead, only the changes relative to the keyframe are saved. P-frames (Predictive frames) store changes based on the preceding frames. B-frames (Bi-directional frames) retain information from both previous and subsequent frames in order to determine the minimal changes needed to represent the original video. This drastically reduces the amount of information saved in each video frame and subsequently significantly reduces file size. While it is efficient in file size reduction, it can affect image quality and introduce artifacts in situations with fast-moving and unpredictable elements.
Do intraframe and interframe compression techniques affect video quality?
Both interframe and intraframe compression techniques can be used in lossless or lossy compression algorithms. Lossless means the original video quality is retained, and lossy means there will be some level of quality reduction. The most common video codecs like H.264 and H.265 are lossy which means the compressed video will not match the original file and some quality reduction will occur. Lossy compression techniques are most ubiquitous because of the significant efficiency advantages in reducing file sizes.