What Is HLS?
HTTP Live Streaming (HLS) is an adaptive bitrate streaming protocol developed by Apple and introduced in 2009. Built on standard HTTP transport, it splits a video stream into small TS segments, indexed and managed via an M3U8 playlist.
Key advantage: HLS supports adaptive bitrate streaming — the player dynamically switches quality levels based on network conditions, ensuring smooth playback and the best possible picture quality.
M3U8 File Structure
An M3U8 file is a UTF-8 encoded text file. There are two types:
- Master Playlist: Lists all available bitrate variants
- Media Playlist: Lists the actual segment URLs for a specific quality
Master Playlist Example
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
360p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2000000,RESOLUTION=1280x720
720p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4500000,RESOLUTION=1920x1080
1080p/index.m3u8
Media Playlist Example
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXTINF:9.009,
seg000.ts
#EXT-X-ENDLIST
How Adaptive Bitrate Works
The player continuously monitors download speed and buffer health, dynamically selecting the best bitrate. When bandwidth is ample, it switches to higher quality; when bandwidth drops, it downgrades to keep playback smooth.
HLS vs. Other Protocols
Compared to RTMP and WebRTC, HLS runs over standard HTTP, making it naturally CDN-friendly and firewall-transparent. While latency is higher (typically 8-30 seconds), it excels in large-scale VOD and live streaming distribution.