HLS (HTTP Live Streaming)
HLS is Apple's adaptive bitrate streaming protocol using M3U8 playlists and segmented media files, the most widely deployed streaming technology for live and on-demand video.
You are a file format specialist with deep expertise in HLS (HTTP Live Streaming), including M3U8 playlist structure, adaptive bitrate encoding, segment formats (MPEG-TS and fMP4/CMAF), DRM integration with FairPlay, and Low-Latency HLS configuration. ## Key Points - **2009**: Apple introduces HLS at WWDC, initially for iPhone 3.0. - **2010**: HLS adopted by major CDNs; becomes the default for iOS video. - **2012**: HLS supports fragmented MP4 (fMP4) segments alongside MPEG-TS. - **2016**: HLS gains support for H.265/HEVC, HDR, and 4K content. - **2017**: RFC 8216 published. Apple introduces Low-Latency HLS concepts. - **2019**: Apple formally announces LL-HLS (Low-Latency HLS) for sub-3-second latency. - **2020**: Apple deprecates MPEG-TS in favor of fMP4 (CMAF) segments for new content. - **2020s**: HLS is the dominant delivery protocol for OTT video worldwide. - **Safari**: Native HLS support (macOS and iOS). - **HLS.js**: JavaScript library for HLS playback in Chrome, Firefox, Edge. - **Video.js + HLS plugin**: Popular web player with HLS support. - **VLC**: Plays M3U8 URLs directly.
skilldb get file-formats-skills/HLS (HTTP Live Streaming)Full skill: 199 linesYou are a file format specialist with deep expertise in HLS (HTTP Live Streaming), including M3U8 playlist structure, adaptive bitrate encoding, segment formats (MPEG-TS and fMP4/CMAF), DRM integration with FairPlay, and Low-Latency HLS configuration.
HLS — HTTP Live Streaming
Overview
HTTP Live Streaming (HLS) is an adaptive bitrate streaming protocol developed by Apple and published as an informational RFC (RFC 8216) in 2017. HLS breaks video into small segments (typically 6 seconds) listed in an M3U8 playlist file, allowing players to adaptively switch between quality levels based on network conditions. HLS is the most widely supported streaming protocol, working natively in Safari, iOS, Android, smart TVs, and most streaming platforms. It delivers both live and on-demand (VOD) content over standard HTTP/HTTPS infrastructure.
History
- 2009: Apple introduces HLS at WWDC, initially for iPhone 3.0.
- 2010: HLS adopted by major CDNs; becomes the default for iOS video.
- 2012: HLS supports fragmented MP4 (fMP4) segments alongside MPEG-TS.
- 2016: HLS gains support for H.265/HEVC, HDR, and 4K content.
- 2017: RFC 8216 published. Apple introduces Low-Latency HLS concepts.
- 2019: Apple formally announces LL-HLS (Low-Latency HLS) for sub-3-second latency.
- 2020: Apple deprecates MPEG-TS in favor of fMP4 (CMAF) segments for new content.
- 2020s: HLS is the dominant delivery protocol for OTT video worldwide.
Core Philosophy
HLS (HTTP Live Streaming) is built on a principle that was radical when Apple introduced it in 2009: deliver video using nothing more than standard HTTP servers and simple text-based playlists. By segmenting video into small chunks and listing them in M3U8 playlist files, HLS eliminated the need for specialized streaming servers, proprietary protocols, and persistent connections — making scalable video delivery as simple as serving static files from a CDN.
Adaptive bitrate streaming is HLS's core capability. A master playlist offers multiple quality levels (renditions), and the player dynamically switches between them based on network conditions and device capabilities. This means a single HLS stream can serve viewers on 5G phones, congested hotel Wi-Fi, and gigabit fiber connections — each getting the best quality their bandwidth allows. Design your encoding ladder thoughtfully: too few renditions create jarring quality switches, too many waste encoding resources.
HLS has evolved from an Apple-only technology into the dominant streaming protocol worldwide. CMAF (Common Media Application Format) bridges HLS and DASH, allowing a single set of media segments to serve both protocols. For new streaming projects, target HLS with fMP4 segments (not legacy MPEG-TS) to maximize compatibility and enable CMAF interoperability.
Technical Specifications
| Property | Details |
|---|---|
| Protocol | HTTP/HTTPS-based adaptive bitrate streaming |
| Playlist format | M3U8 (UTF-8 M3U extended playlist) |
| Segment formats | MPEG-TS (.ts), fragmented MP4/CMAF (.m4s, .mp4) |
| Video codecs | H.264, H.265 (HEVC), AV1 (draft support) |
| Audio codecs | AAC, AC-3, E-AC-3 (Dolby Digital), FLAC, MP3 |
| Subtitle formats | WebVTT, IMSC1 (TTML), CEA-608/708 |
| Encryption | AES-128, SAMPLE-AES, Apple FairPlay DRM |
| Segment duration | Typically 6 seconds (Apple recommendation); 2–10 seconds common |
| Latency | Standard: 15–30 seconds. Low-Latency HLS: 1–3 seconds |
| Max resolution | No protocol limit; 4K and 8K supported |
| HDR | HDR10, Dolby Vision, HLG |
| MIME type | application/vnd.apple.mpegurl (M3U8 playlist) |
Playlist Structure
HLS uses two types of M3U8 playlists:
Master Playlist — Lists available quality variants:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360,CODECS="avc1.4d401e,mp4a.40.2"
360p/playlist.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2"
720p/playlist.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080,CODECS="avc1.640028,mp4a.40.2"
1080p/playlist.m3u8
Media Playlist — Lists segments for a specific variant:
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:6.006,
segment0.ts
#EXTINF:6.006,
segment1.ts
#EXTINF:5.005,
segment2.ts
#EXT-X-ENDLIST
For live streams, the #EXT-X-ENDLIST tag is absent, and the player polls for updated playlists.
How to Work With It
Opening
- Safari: Native HLS support (macOS and iOS).
- HLS.js: JavaScript library for HLS playback in Chrome, Firefox, Edge.
- Video.js + HLS plugin: Popular web player with HLS support.
- VLC: Plays M3U8 URLs directly.
- mpv: Full HLS support from URLs.
- ExoPlayer (Android): Native HLS support.
- AVPlayer (iOS): Native HLS support.
Creating
# Create HLS segments from a video file using FFmpeg
ffmpeg -i input.mp4 \
-c:v libx264 -crf 22 -preset fast \
-c:a aac -b:a 128k \
-hls_time 6 -hls_list_size 0 \
-hls_segment_filename "segment_%03d.ts" \
playlist.m3u8
# Multi-bitrate HLS with master playlist
ffmpeg -i input.mp4 \
-filter_complex "[0:v]split=3[v1][v2][v3]; \
[v1]scale=640:360[v1out]; \
[v2]scale=1280:720[v2out]; \
[v3]scale=1920:1080[v3out]" \
-map "[v1out]" -map 0:a -c:v libx264 -b:v 800k -c:a aac -b:a 96k \
-hls_time 6 -hls_list_size 0 -hls_segment_filename "360p_%03d.ts" 360p.m3u8 \
-map "[v2out]" -map 0:a -c:v libx264 -b:v 2800k -c:a aac -b:a 128k \
-hls_time 6 -hls_list_size 0 -hls_segment_filename "720p_%03d.ts" 720p.m3u8 \
-map "[v3out]" -map 0:a -c:v libx264 -b:v 5000k -c:a aac -b:a 192k \
-hls_time 6 -hls_list_size 0 -hls_segment_filename "1080p_%03d.ts" 1080p.m3u8
# Using fMP4 (CMAF) segments instead of MPEG-TS
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -c:a aac \
-hls_time 6 -hls_list_size 0 \
-hls_segment_type fmp4 \
-hls_segment_filename "segment_%03d.m4s" \
playlist.m3u8
Converting
- Shaka Packager: Google's open-source tool for creating HLS (and DASH) packages.
- Bento4: MP4 toolkit with HLS packaging (
mp4hls). - AWS MediaConvert / Elemental: Cloud-based HLS transcoding.
- Apple's HTTP Live Streaming Tools:
mediafilesegmenterandmediastreamsegmenter.
Common Use Cases
- Video on demand (VOD): Netflix, Disney+, Apple TV+, and most OTT platforms.
- Live streaming: Sports, news, events delivered via HLS.
- Social media video: Instagram, TikTok, Twitter/X use HLS for playback.
- E-learning: Adaptive streaming for educational platforms.
- Enterprise video: Internal communications and training video delivery.
- DRM-protected content: FairPlay DRM for premium content protection.
Pros & Cons
Pros
- Widest device and platform support of any streaming protocol.
- Works over standard HTTP/HTTPS (CDN-friendly, firewall-friendly).
- Adaptive bitrate switching for optimal experience on varying networks.
- Native iOS/Safari support with no JavaScript library needed.
- Supports DRM (FairPlay), multiple audio tracks, subtitles, and HDR.
- Low-Latency HLS reduces latency to 1-3 seconds for live content.
- Segment-based design enables efficient CDN caching.
Cons
- Higher latency than WebRTC or WebSocket-based solutions for standard HLS.
- Segment-based overhead (many small files to manage, especially for VOD).
- Apple-originated; DASH is preferred in some markets (Europe, Android-first).
- MPEG-TS segments are less efficient than fMP4/CMAF.
- Complex to set up multi-bitrate adaptive streams correctly.
- Requires a packaging step (segmentation) beyond simple file hosting.
Compatibility
| Platform | Support |
|---|---|
| Safari (macOS/iOS) | Native |
| Chrome/Firefox/Edge | Via HLS.js or similar JavaScript library |
| Android | ExoPlayer (native); Chrome via MSE + HLS.js |
| Smart TVs | Most support HLS natively |
| Set-top boxes | Apple TV (native), Roku, Fire TV |
| Game consoles | Via built-in streaming apps |
| CDNs | Universal support (Cloudflare, Akamai, AWS CloudFront, etc.) |
Related Formats
- DASH (MPD) — MPEG-DASH: ISO standard competitor to HLS; uses MPD manifests.
- CMAF — Common Media Application Format: shared segment format for both HLS and DASH.
- MPEG-TS — Traditional HLS segment format.
- fMP4 — Fragmented MP4: modern HLS segment format, shared with DASH.
- RTMP — Low-latency ingest protocol often used to feed HLS packaging.
- WebRTC — Sub-second latency alternative for real-time communication.
Practical Usage
- Use fMP4 (CMAF) segments instead of MPEG-TS for new content -- they are more efficient and enable sharing segments with DASH.
- Always include a master playlist with multiple quality variants for adaptive bitrate switching.
- Set segment duration to 6 seconds as Apple recommends; shorter segments reduce latency but increase request overhead.
- Enable Low-Latency HLS for live content requiring sub-3-second latency.
- Test playback on Safari natively and on Chrome/Firefox via HLS.js to catch cross-browser issues.
Anti-Patterns
- Using only a single bitrate stream -- Without multiple quality variants, viewers on slow connections will experience buffering instead of graceful quality reduction.
- Setting segment durations too short without LL-HLS -- Very short segments (under 2 seconds) without Low-Latency HLS support create excessive HTTP requests and playlist polling overhead.
- Ignoring the CODECS attribute in master playlists -- Omitting codec strings causes players to probe segments, increasing startup time and potentially selecting incompatible variants.
- Serving HLS over HTTP instead of HTTPS -- Many browsers and platforms block mixed content or require HTTPS for media playback; always use HTTPS.
- Forgetting to set CORS headers for cross-origin playback -- HLS.js and other JavaScript players require proper CORS headers when serving from a CDN different from the page origin.
Install this skill directly: skilldb add file-formats-skills
Related Skills
3MF 3D Manufacturing Format
The 3MF file format — the modern replacement for STL in 3D printing, supporting colors, materials, multi-object assemblies, and precise manufacturing data in a single package.
7-Zip Compressed Archive
The 7z archive format — open-source high-ratio compression using LZMA2, with strong AES-256 encryption, solid archives, and multi-threading support.
AAC (Advanced Audio Coding)
A lossy audio codec standardized as part of MPEG-2 and MPEG-4, designed to supersede MP3 with better quality at equivalent or lower bitrates.
AC3 (Dolby Digital)
Dolby's surround sound audio codec used in cinema, DVD, Blu-ray, and broadcast television for multichannel 5.1 audio delivery.
AI Adobe Illustrator Format
AI is Adobe Illustrator's native vector graphics file format, used for
AIFF (Audio Interchange File Format)
Apple's uncompressed audio format storing raw PCM data, serving as the Mac equivalent of WAV for professional audio production.