What Is HLS?
HTTP Live Streaming (HLS) is an adaptive bitrate streaming protocol introduced by Apple in 2009. Built on standard HTTP, it has become the dominant standard for internet video delivery. Netflix, YouTube, and virtually every major streaming platform use HLS.
HLS works in three steps: ① The server splits the video into short segments (2–10 seconds each, stored as .ts files); ② A M3U8 playlist file is generated, listing all segment URLs; ③ The player reads the M3U8, downloads segments in order, and switches quality based on network speed.
Two Types of M3U8 Files
- Master Playlist: Lists all available quality levels, each pointing to a separate media playlist
- Media Playlist: Lists the actual .ts segment URLs for one specific quality level
The player first parses the master playlist, picks a bitrate, fetches the corresponding media playlist, and starts downloading segments.
Master Playlist Example
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
360p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=1280x720
720p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
1080p/index.m3u8
Media Playlist Example
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:9.009,
https://cdn.example.com/seg000.ts
#EXTINF:9.009,
https://cdn.example.com/seg001.ts
#EXT-X-ENDLIST
Key Tag Reference
| Tag | Meaning |
|---|---|
#EXTM3U | File header — must appear on the first line |
#EXT-X-VERSION | HLS spec version; affects available features |
#EXT-X-TARGETDURATION | Maximum segment duration in seconds |
#EXT-X-MEDIA-SEQUENCE | Sequence number of the first segment (used for live) |
#EXTINF | Exact duration of the following segment |
#EXT-X-KEY | Encryption info; points to AES-128 key URL |
#EXT-X-ENDLIST | End of playlist — present for VOD, absent for live |
#EXT-X-STREAM-INF | Master playlist only — declares bitrate and resolution |
How Adaptive Bitrate (ABR) Works
The player's bandwidth estimator tracks recent segment download speeds and compares them against the BANDWIDTH values in the master playlist. When bandwidth drops below 1.5× the current level for several segments, the player switches down; when bandwidth improves, it gradually steps up. The transition is seamless — no buffering, no interruption.
HLS vs. Other Streaming Protocols
| Protocol | Latency | CDN-friendly | Browser support | Best for |
|---|---|---|---|---|
| HLS / M3U8 | 8–30s | ✓ Native | All platforms | VOD, large-scale live |
| RTMP | 1–3s | ✗ Dedicated server | Plugin required | Encoder → server ingest |
| DASH | 8–30s | ✓ Native | Good | VOD (Netflix, etc.) |
| WebRTC | <1s | ✗ Hard to cache | Modern browsers | Real-time (video calls) |
Want to try HLS playback right now? Use the StreamFlow online player — paste any M3U8 URL and play instantly, no installation needed.
- Live streams have no
#EXT-X-ENDLIST— players must poll for updates. This is by design, not a broken file. - Segment URLs in a playlist can be relative paths — always resolve them against the M3U8 file's own URL, not the page URL.
- CORS errors are a server configuration issue, not a player bug. The server must return
Access-Control-Allow-Origin: *. - The
BANDWIDTHvalue is peak bitrate, not average. Inflating it causes unnecessary quality downgrades. - Encrypted streams (
#EXT-X-KEY) require the key URL to also be accessible. A blocked key endpoint means no playback, even if the segments load fine.