Sub topic 3
How Adaptive Bitrate Playback Works
Assume you know HTTP, caching, object storage, message queues, and basic web architecture. This chapter focuses on how a completed video reaches the viewer.
Adaptive bitrate playback
Adaptive bitrate (ABR) playback lets a player switch among several versions of the same video. Each version, called a rendition, has a different resolution and bitrate. A manifest lists these renditions and their segment URLs.
The player measures download throughput and buffer health. It chooses a rendition that should download before the playback buffer runs out. It can switch at a segment boundary without restarting the video.
flowchart TD
A[Player downloads master manifest] --> B[Selects a rendition]
B --> C[Downloads video segment]
C --> D[Measures throughput and buffer]
D --> E{Network changed?}
E -->|No| C
E -->|Yes| BA simple selection rule uses a safety margin:
def pick(renditions, throughput_bps):
usable = throughput_bps * 0.8
choice = renditions[0]
for rendition in renditions:
if rendition["bandwidth"] <= usable:
choice = rendition
return choiceCatalog, search, and recommendations
A catalog service stores titles, descriptions, genres, ratings, artwork, playback status, and manifest locations. Search usually uses a separate index because full-text queries and ranking are different from transactional database operations. Recommendation systems can use viewing history, similar content, and popularity signals. They should return content identifiers, while authorization still happens when playback begins.
Measuring playback quality
Quality-of-experience (QoE) metrics show what viewers experience:
- Startup time
- Rebuffering duration and frequency
- Playback failures
- Average and selected bitrate
- Rendition switches
- Video quality by device, region, and network
Emit player events with a session identifier. Combine them with CDN logs and origin metrics. Alert on changes in rebuffering or startup failures, not only on server CPU.
Protecting content
A signed URL contains an expiring signature and limits access to an authorized object or manifest. Use short lifetimes and validate the signature at the CDN or origin. DRM encrypts media and uses a license service to control decryption on supported devices. DRM adds operational cost and device-specific integration work.
Live streaming
Live systems ingest a continuous feed, encode it into renditions, and publish short segments or low-latency parts. A sliding manifest removes old segments. Lower latency requires smaller buffers and leaves less time to recover from network variation.
Cost and design trade-offs
More renditions improve adaptation but increase transcoding, storage, and cache cost. Smaller segments reduce switching and latency but increase request overhead. A CDN reduces origin load and viewer latency, while cache misses still require sufficient origin capacity.
Exercise
Why can a player rebuffer even when the CDN is healthy?
Show answer
The viewer's available throughput may be below the selected rendition's bitrate, or the player may have too little buffered media to absorb temporary variation.