How HLS Works · Jaz's Blog
HLS video streaming is just plaintext playlist files pointing at tiny video chunks—which means you can build view tracking, dynamic subtitles, and video trailers by manipulating the playlists without touching the actual video files or getting locked into a CDN vendor.
Read Original Summary used for search
TLDR
• HLS uses two playlist types: Master Playlists (list quality variants) and Media Playlists (list 4-second .ts video segments)—both are human-readable text files you can inspect and modify
• Track views by injecting session IDs into playlist URLs as query params—each segment request reveals what the user actually watched without needing cookies or instrumented players
• Add dynamic subtitles by defining them as variants in the Master Playlist pointing to WebVTT files—no video re-encoding needed
• Append branded trailers using EXT-X-DISCONTINUITY headers to seamlessly stitch different video sources together in the playlist
• You control the playlists on your server while redirecting actual .ts segment requests to a CDN—avoiding vendor lock-in while keeping costs low
In Detail
HLS (HTTP Live Streaming) demystified: it's not complex infrastructure, just plaintext .m3u8 playlist files that tell video players where to find small .ts video segment files. The protocol uses Master Playlists to list available quality variants (360p, 720p, etc.) and Media Playlists to list the actual 4-second video chunks. Because these are just text files with relative URLs, you can dynamically generate them to add sophisticated features without touching the actual video files.
The author demonstrates four practical techniques for Bluesky's video platform: (1) View tracking by injecting unique session IDs into playlist URLs—when players request segments, you log the view before redirecting to your CDN; (2) Dynamic subtitles by adding EXT-X-MEDIA subtitle variants to the Master Playlist that point to WebVTT files; (3) Video trailers appended using EXT-X-DISCONTINUITY headers to seamlessly stitch different video sources; (4) Avoiding vendor lock-in by serving playlists from your infrastructure while redirecting segment requests to a CDN with 302s.
The key insight is architectural: by controlling the playlist layer, you can build analytics, A/B test trailers, update captions, and switch CDNs—all without re-encoding videos or depending on vendor-specific features. The author encourages engineers to inspect protocols directly rather than treating them as black boxes, showing how "complex" systems are often surprisingly simple plaintext specifications.