HLS
Video as a text playlist of small files, so a web server and a CDN are all you need.
A media playlist
A text file that says which chunks make up the video.
Whole frame
A playlist is just a text file listing video chunks. HLS needs no special server: any web server or CDN that can serve files will do.
| Field | Offset | Example value | Meaning |
|---|---|---|---|
| Header tag | Byte 0–7 | #EXTM3U | Every playlist begins with #EXTM3U. Lines starting with # are tags (instructions); lines without # are URIs of media. Lines end with a plain LF here (CRLF is also allowed). |
| Target duration | Byte 8–31 | #EXT-X-TARGETDURATION:6 | The maximum segment length in seconds. A player uses it to decide how often to re-fetch a live playlist (about once per target duration). |
| Segment duration | Byte 32–44 | #EXTINF:6.0, | The exact duration of the NEXT segment: 6.0 seconds. The tag always precedes its URI. |
| Segment URI | Byte 45–52 | seg0.ts | Where to download the media: a relative URL, so this is fetched with a normal HTTP GET from the same directory. It is a few seconds of MPEG-TS (or fMP4) video. |
| Segment duration | Byte 53–65 | #EXTINF:6.0, | The second segment is also 6 seconds. |
| Segment URI | Byte 66–73 | seg1.ts | The second segment. |
| End of list | Byte 74–88 | #EXT-X-ENDLIST | Says the list is complete: this is a recorded video (VOD). A live playlist has no ENDLIST and keeps growing; the player keeps reloading it. |
Overview
HTTP Live Streaming cuts a video into a few seconds long segments and publishes a text playlist (.m3u8) that lists them. The player downloads the playlist, then the segments, over plain HTTP. For adaptive bitrate, a master playlist offers the same video in several qualities and the player switches between them as bandwidth changes.
Because it is just HTTP and files, it passes every firewall and scales on any CDN: the price is latency of several seconds, which Low-Latency HLS reduces by publishing partial segments.
Key facts
- Transport
- HTTP(S) over TCP
- Playlist
- .m3u8 (UTF-8 text)
- Segments
- MPEG-TS or fragmented MP4, ~2–10 s
- Adaptive
- Yes, per segment
- Latency
- ~6–30 s (LL-HLS: 2–3 s)
- Standard
- RFC 8216
A master playlist
The same video at several qualities.
Whole frame
The master playlist lists the same video at several qualities. The player starts somewhere in the middle and switches up or down between segments as the connection changes.
| Field | Offset | Example value | Meaning |
|---|---|---|---|
| Header tag | Byte 0–7 | #EXTM3U | A master playlist also starts with #EXTM3U. |
| Variant 1 info | Byte 8–61 | #EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360 | Describes the next URI as one rendition of the same video: needs about 800 kbit/s and is 640×360. The player picks among renditions by measured throughput. |
| Variant 1 playlist | Byte 62–76 | low/index.m3u8 | The media playlist for the low-quality version. |
| Variant 2 info | Byte 77–132 | #EXT-X-STREAM-INF:BANDWIDTH=3000000,RESOLUTION=1280x720 | A medium version: 3 Mbit/s, 720p. |
| Variant 2 playlist | Byte 133–147 | mid/index.m3u8 | Its media playlist. |
Playing and adapting
Nothing but HTTP requests, one file at a time.
Whole exchange
HLS turns video into a series of small files and lets the player decide quality. That is why it scales on ordinary CDNs, and why it has latency of several seconds.
1Fetch the master playlist
An ordinary HTTP GET. There is no streaming server and no special protocol: it is just a file.
2Choose a quality
The player reads the variants and starts with a conservative one, then measures how fast the downloads go.
3Download segment 0
Video arrives as 6-second chunks, each an independent HTTP download.
4Play it
The segment is a short MPEG-TS file. The player decodes it while fetching the next one.
5Throughput was good: step up
Downloading segment 0 was much faster than real time, so the player requests the next segment from a higher-quality variant. Quality changes only at segment boundaries.
6And on it goes
For a live stream the player also re-fetches the media playlist about every target duration to discover new segments.
Where you meet it
- Video on websites, Safari/iOS (native), and most video platforms
- Live events on CDNs for audiences of millions
- DRM-protected streaming with FairPlay
Watch out for
- Segment length trades latency for efficiency: short segments mean more requests and a bigger playlist.
- Segments should start with a key frame, or quality switching shows glitches.
- Cross-origin playback in browsers needs CORS headers on both playlists and segments.
Standards
- RFC 8216: HTTP Live Streaming