What Is HTTP Live Streaming (HLS)?
HTTP Live Streaming, commonly abbreviated as HLS, is an adaptive bitrate streaming protocol developed by Apple. It delivers audio and video content over HTTP, making it compatible with standard web infrastructure. Unlike proprietary streaming protocols that require specialized servers, HLS works with ordinary web servers and content delivery networks.
Apple introduced HLS in 2009 alongside iOS 3.0 and QuickTime X. The protocol became an Internet Engineering Task Force (IETF) standard in 2017 under RFC 8216. Today, HLS is the dominant streaming protocol for reaching browsers, mobile devices, and smart TVs.

How HLS Works: The Technical Breakdown
HLS divides a media stream into small segments, typically between 2 and 10 seconds each. The server encodes these segments at multiple bitrates, creating separate streams for different quality levels. The client dynamically switches between these streams based on available bandwidth and device capability.
The Three Core Components
1. Media Segments: The actual audio and video data, sliced into short MPEG-2 Transport Stream (.ts) files or fragmented MP4 files (for newer fMP4 containers). Each segment is a standalone, decodable chunk of content.
2. Playlist Files: M3U8 playlists act as indexes. They list available streams, segment URLs, and metadata. There are two types:
- Master Playlist — lists all available bitrate renditions and their corresponding media playlists.
- Media Playlist — lists the sequence of segment URLs for a single bitrate stream.
3. Key Files: For encrypted content, HLS uses AES-128 encryption or SAMPLE-AES. Key files deliver the decryption information the client needs before playing protected segments.
The Delivery Sequence
When a client requests a stream, the following sequence occurs:
- The client fetches the master playlist, which lists available bitrate renditions.
- Based on current network conditions, the client selects a media playlist.
- The client downloads the first few segments listed in that media playlist and begins playback.
- As playback continues, the client monitors bandwidth and buffer levels, switching to higher or lower bitrate streams as needed.
Adaptive Bitrate Streaming in Detail

Adaptive bitrate (ABR) is the defining feature of HLS. Instead of forcing every viewer into a single quality level, HLS adjusts quality in real time. When network throughput drops, the client drops to a lower resolution. When bandwidth increases, it shifts back up.
This behavior depends on the client-side ABR algorithm. Most players use a throughput-based approach: they measure the download speed of recent segments and select the next segment from the highest bitrate stream that can be downloaded within the segment duration. More advanced algorithms factor in buffer levels and predicted throughput to reduce unnecessary quality switches.
For live content, segment boundaries must align across all bitrate renditions. This alignment allows the client to switch mid-stream without visual artifacts or audio glitches. The encoder handles this by keyframe-aligned segmentation across all output streams.
HLS Architecture: Live vs. On-Demand
Live Streaming Setup
A live HLS workflow involves:
- Encoder: Ingests the live source (camera feed, screen capture) and generates multiple bitrate renditions in real time.
- Packager / Segmenter: Splits encoded streams into segments and updates playlist files. Software like Apple’s Media Stream Segmenter or open-source tools like FFmpeg handle this step.
- Origin Server: Hosts the segments and playlists.
- CDN: Distributes content globally with low latency.
- Player: The client application that fetches playlists, downloads segments, and renders playback.
For live streams, the media playlist uses a sliding window. As new segments appear, the oldest segments fall off the playlist. The EXT-X-TARGETDURATION tag specifies the maximum segment length, while EXT-X-MEDIA-SEQUENCE tracks the playlist’s starting sequence number.
Video on Demand (VOD) Setup
VOD streams differ in one key way: the entire playlist is available from the start. The playlist includes every segment, terminated with the EXT-X-ENDLIST tag, signaling to the client that no new segments will be appended. This allows full seek and rewind functionality.
HLS vs. Other Streaming Protocols

Several protocols compete with HLS. Understanding their differences helps you choose the right one for your deployment.
HLS vs. MPEG-DASH
MPEG-DASH is the ISO-standard counterpart to HLS. Both use adaptive bitrate delivery over HTTP. The primary differences:
- Codec support: HLS mandates H.264/H.265 video and AAC audio for broad compatibility. MPEG-DASH is codec-agnostic.
- DRM: HLS uses FairPlay for encrypted content on Apple devices. MPEG-DASH supports Widevine and PlayReady.
- Browser support: Safari natively supports HLS. Most other browsers require JavaScript players for both protocols.
- Latency: Standard HLS has 30–45 seconds of latency. Low-Latency HLS (LL-HLS) and Low-Latency DASH (LL-DASH) both aim for sub-5-second delivery.
HLS vs. RTMP
Real-Time Messaging Protocol (RTMP) was the standard for Flash-based streaming. RTMP offers sub-second latency but requires a persistent TCP connection and a dedicated media server. RTMP is no longer viable for playback delivery since Adobe deprecated Flash. It remains useful for ingest from encoders to media servers, but HLS handles final viewer delivery.
HLS vs. WebRTC
WebRTC provides real-time, sub-second latency ideal for video conferencing and interactive applications. However, WebRTC scales poorly for large broadcast audiences. Each connection consumes server resources, making it expensive for one-to-many streaming. HLS remains the practical choice for broadcasts exceeding a few hundred concurrent viewers.
Low-Latency HLS
Apple introduced Low-Latency HLS (LL-HLS) in 2019 to address the protocol’s inherent delay. LL-HLS reduces glass-to-glass latency to roughly 4–8 seconds through several mechanisms:
- Partial Segments: Instead of waiting for a full segment, the client downloads smaller partial segments (typically 200–500ms each) as they become available.
- Delta Playlists: Rather than re-fetching the entire playlist, the client requests only the changes since the last update.
- Blocking Playlist Reloads: The server holds the request until new content is ready, eliminating polling overhead and reducing latency.
Implementing LL-HLS requires encoder, packager, and player support. Safari on macOS and iOS supports LL-HLS natively. Other browsers need a compatible JavaScript player like hls.js.
Implementing HLS: Practical Considerations
Encoding Settings
Choose encoding parameters that balance quality, bandwidth, and device compatibility:
- Resolution ladder: Include at least 4–5 renditions (e.g., 1080p @ 6 Mbps, 720p @ 3 Mbps, 480p @ 1.5 Mbps, 360p @ 800 kbps, 240p @ 400 kbps).
- Keyframe interval: Set the Group of Pictures (GOP) size to exactly match your segment duration. For 6-second segments, use a keyframe interval of 6 seconds.
- Codec: H.264 with the High profile provides the widest device support. H.265 (HEVC) reduces bandwidth 30–50% but lacks browser support outside Safari.
Segment Duration
Shorter segments reduce latency but increase the number of HTTP requests and playlist file sizes. Standard HLS uses 6–10 second segments. LL-HLS uses 6-second segments with partial segments of 200–500ms. Avoid segments shorter than 2 seconds for non-LL-HLS streams, as the overhead degrades performance.
Caching and CDN Strategy
Since HLS delivers content over HTTP, you can cache segments and playlists at any CDN edge node. Configure cache policies as follows:
- Segments: Cache indefinitely (or until content is removed). Segments are immutable once published.
- VOD Playlists: Cache indefinitely with long TTLs.
- Live Playlists: Cache with short TTLs (1–2 seconds) or disable caching entirely, since the playlist updates frequently.
Player Selection
For browsers without native HLS support, you need a JavaScript player. hls.js is the most widely deployed open-source option. It supports standard HLS, LL-HLS, and fMP4 containers. Video.js and Shaka Player are solid alternatives with different API styles and plugin ecosystems.
Common Problems and Debugging
- Playback stalls: Usually caused by insufficient bandwidth for the lowest rendition. Check your encoding ladder and ensure your lowest bitrate stream is truly watchable on slow connections.
- Audio sync drift: Segment boundaries that don’t align across renditions cause this problem. Verify that your encoder produces keyframe-aligned segments for every output stream.
- Playlist 404 errors: The client requested a playlist that hasn’t been published yet or has been removed. Check segmenter timing and CDN cache invalidation settings.
- Encryption playback failures: Incorrect key server configuration or CORS headers blocking key delivery. Test key delivery directly in the browser before debugging the player.
FAQ
What is the typical latency for standard HLS compared to Low-Latency HLS?
Standard HLS delivers content with 30–45 seconds of glass-to-glass latency. Low-Latency HLS reduces this to approximately 4–8 seconds by delivering partial segments, using delta playlists, and implementing blocking playlist reloads. If you need sub-second delivery, HLS is not the right protocol—consider WebRTC instead.
Can HLS streams be played natively in all browsers?
No. Safari on macOS, iOS, and tvOS supports HLS natively without any additional software. Every other major browser (Chrome, Firefox, Edge) requires a JavaScript player like hls.js to handle HLS playback. Android supports HLS natively in its WebView and some OEM browsers, but compatibility varies by device.
What container formats does HLS support?
HLS originally required MPEG-2 Transport Stream (TS) containers. Starting with the HLS authoring specification version 7, Apple added support for fragmented MP4 (fMP4) containers. fMP4 offers better efficiency and is required for Low-Latency HLS. Most modern encoders and packagers can output both formats, but fMP4 is the recommended choice for new deployments.
