Video Compression - System Design
Machine-readable: Markdown · JSON API · Site index
Описание видео
Video compression is the process of reducing the file size of a video so it can be streamed easily over the internet.
Raw video files are massive because they contain up to sixty full-color images for every single second of footage.
To shrink this data compression algorithms exploit two types of redundancy known as spatial and temporal.
Spatial compression looks for redundancy within a single individual frame of the video.
If a frame shows a clear blue sky the algorithm does not save the color data for every single pixel.
Instead it groups those pixels together and records a single instruction to fill that entire area with blue.
This process is highly efficient for static backgrounds and works similarly to how a JPEG image is compressed.
Temporal compression looks for redundancy across multiple sequential frames over a period of time.
In most video scenes very little actually changes from one frame to the next millisecond.
If a person is walking in front of a house the house stays completely still while only the person moves.
Instead of saving a whole new picture for the next frame the algorithm only records the differences or changes.
It saves the moving parts as motion vectors and instructs the player to reuse the static background from the previous frame.
The algorithm organizes these frames into a structure called a Group of Pictures which includes I-frames P-frames and B-frames.
I-frames are full images that contain all the spatial data needed to render a complete picture without any outside context.
P-frames and B-frames are smaller predictive frames that only contain the temporal data of what changed since the last frame.
Combining spatial and temporal compression allows platforms to shrink video file sizes by over ninety-five percent without a noticeable loss in quality.