Lesson 6.8 · 25 min
Video streaming
Watch fixed 1080p freeze in a train tunnel while adaptive players keep going, find the cheapest number of videos to keep on the CDN, and cut a 300-minute encode to 3 by chunking.
The idea in plain words
A video site takes one uploaded file, turns it into many versions for different screens and speeds, and sends small pieces to millions of viewers. The player keeps switching quality so the video doesn’t stop to buffer.
The problem it solves
One uploaded video must play smoothly on a slow phone and a 4K TV, for millions of viewers, without huge delivery bills.
How it works
- The upload goes straight to object storage.
- It is split into chunks and transcoded in parallel into a ladder of qualities (240p up to 4K).
- Each quality is cut into short segments of a few seconds.
- The player downloads segments one at a time and picks the quality of the next one based on current speed (adaptive bitrate).
- Popular videos are served from CDN servers near viewers.
Example
On a train, your speed drops from 10 Mbit/s to 2 Mbit/s. The player notices and fetches the next 4-second segment in 480p instead of 1080p. The picture gets softer for a moment, but the video never stops to buffer.
Key terms
- Transcoding
- Converting a video into other formats, sizes and bitrates.
- Bitrate ladder
- The set of qualities made for each video, such as 240p to 4K.
- Segment
- A few seconds of video; players download one at a time.
- Adaptive bitrate (ABR)
- The player picks the quality of each next segment based on your current speed.
- Egress
- Data sent out to viewers; usually the biggest cost.
In this lesson you'll learn
- How to size a video platform: storage per hour, egress, CDN bill and encoding compute.
- How adaptive bitrate streaming keeps playback smooth on a changing connection.
- How CDN placement, the long tail and chunked transcoding control cost and speed, and how to defend the design.
Sections
- Requirements and numbers
- API and data
- Architecture
- Deep dive: adaptive bitrate
- Deep dive: cost and speed
- Design review
Cheat sheet
| 1 Mbps × 1 hour | 450 MB |
|---|---|
| Upload | resumable, straight to storage |
| Transcode | chunk × rendition DAG on a queue |
| Playback | HLS/DASH segments + ABR |
| Delivery | CDN head, cheaper long tail |
The interactive simulations and the scored design review load with JavaScript.