Hai bài toán: ingest + transcode (chuẩn bị video) và delivery (phát mượt ở mọi mạng).
Pipeline upload → sẵn sàng phát:
1. Upload raw video vào blob storage (S3).
2. Transcoding (xử lý nền, song song theo từng chunk): mã hóa ra nhiều độ phân giải/bitrate (240p…1080p…4K) và nhiều codec.
3. Segmentation: cắt mỗi phiên bản thành các segment ~2–10s + sinh manifest (.m3u8 cho HLS) liệt kê các segment theo từng mức chất lượng.
Adaptive Bitrate (ABR) với HLS:
- Player tải manifest, rồi tự chọn mức bitrate theo băng thông đo được. Mạng yếu → chuyển segment 240p; mạng khỏe → nhảy lên 1080p — chuyển giữa các segment nên không gián đoạn.
- Đây là client-driven: server chỉ phục vụ file tĩnh (segment + manifest), player quyết định.
Vai trò CDN:
- Segment là file tĩnh → đẩy ra CDN edge gần người xem → giảm latency, giảm tải origin, chịu được lượng xem khổng lồ.
- 80/20: cache nội dung phổ biến ở edge; video ít xem (long tail) fetch từ origin lúc cần.
Hình dung: một bộ phim được đóng thành nhiều "hộp" chất lượng khác nhau; người xem tự đổi hộp theo tốc độ mạng ngay giữa các cảnh, lấy hộp từ kho gần nhất (CDN).
Lưu ý: transcoding rất nặng → hàng đợi job + autoscale; dùng DASH thay HLS cũng cùng nguyên lý; thêm DRM/token cho nội dung trả phí.
Two problems: ingest + transcode (prepare the video) and delivery (smooth playback on any network).
Upload → ready-to-play pipeline:
1. Upload raw video to blob storage (S3).
2. Transcoding (background, parallel per chunk): encode into multiple resolutions/bitrates (240p…1080p…4K) and codecs.
3. Segmentation: split each version into ~2–10s segments + generate a manifest (.m3u8 for HLS) listing segments per quality level.
Adaptive Bitrate (ABR) with HLS:
- The player fetches the manifest, then picks a bitrate based on measured bandwidth. Weak network → switch to 240p segments; strong → jump to 1080p — switching between segments so playback never stalls.
- It's client-driven: the server only serves static files (segments + manifest); the player decides.
CDN role:
- Segments are static files → push them to CDN edges near viewers → lower latency, less origin load, massive concurrency.
- 80/20: cache popular content at the edge; rarely-watched long-tail videos fetch from origin on demand.
Picture: a film packed into multiple quality "boxes"; the viewer swaps boxes by network speed mid-scene, grabbing each from the nearest warehouse (CDN).
Note: transcoding is heavy → job queue + autoscale; DASH instead of HLS follows the same principle; add DRM/tokens for paid content.