# Video Compression - System Design

## Метаданные

- **Канал:** Greg Hogg
- **YouTube:** https://www.youtube.com/watch?v=BLIq3NLmEQw
- **Дата:** 25.05.2026
- **Длительность:** 1:32
- **Просмотры:** 23,867

## Описание

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.

## Содержание

### [0:00](https://www.youtube.com/watch?v=BLIq3NLmEQw) Segment 1 (00:00 - 01:00)

If you don't know this, you suck at system design. A 4K video is going to take you four times as many pixels as 1080p. If you're watching it at just 30 FPS, that means you need a whopping 6 gigabits per second bit rate to support that stream. Now, the average internet in America is like 200 megabits per second. So, how could you support a stream that big? As you likely know, the answer is compression, and we do it in two different ways. The first way is spatial compression, which is per frame, and the other one is temporal compression, which goes across frames. State-of-the-art video compression will likely use stuff like a Fourier transform, and that gets pretty complicated. But, a simple idea is the idea of say run-length encoding. If you have five A's in a row, and then six B's after that, why would you write them all out when you could just write five A and then six B? You save half the data and say exactly the same thing. Now, the other one is temporal compression, which is across frames. The main idea is just only say what changes. So, if you have a background, pretty much every pixel is the same thing. But, you typically have one object throughout the frame, probably you, that's moving around. Therefore, you just actually write down what pixels change. And if nothing even changed, then don't bother storing anything. And as you probably know, there's two main types of compression. Lossy will actually remove unnecessary data, and lossless will just restructure the file and keep it at perfect quality. I teach this stuff every day and growing really fast, so follow along to learn more.

---
*Источник: https://ekstraktznaniy.ru/video/52837*