HLS and DASH Video Streaming Implementation
HLS (HTTP Live Streaming) and DASH (Dynamic Adaptive Streaming over HTTP) are adaptive streaming protocols. Video is cut into 2–10 second segments; player automatically switches between qualities based on user connection speed.
HLS vs DASH
| Feature | HLS | DASH |
|---|---|---|
| Support | All browsers (hls.js for non-Safari) | All browsers (dash.js) |
| Container | MPEG-TS or fMP4 | fMP4 |
| DRM | FairPlay (Apple), Widevine | Widevine, PlayReady |
| Latency | 6–30 sec (LL-HLS: <2 sec) | 2–10 sec |
| CDN compatibility | Excellent | Excellent |
HLS is standard choice. DASH used for services with multiple DRM.
FFmpeg: Create HLS playlist
ffmpeg -i "$INPUT" \
-filter_complex \
"[0:v]split=3[v1][v2][v3]; \
[v1]scale=1920:1080[v1080]; \
[v2]scale=1280:720[v720]; \
[v3]scale=640:360[v360]" \
-map "[v1080]" -map 0:a -c:v:0 libx264 -b:v:0 5000k -c:a:0 aac -b:a:0 192k \
-map "[v720]" -map 0:a -c:v:1 libx264 -b:v:1 2500k -c:a:1 aac -b:a:1 128k \
-map "[v360]" -map 0:a -c:v:2 libx264 -b:v:2 800k -c:a:2 aac -b:a:2 96k \
-f hls -hls_time 6 -hls_playlist_type vod \
-hls_segment_type fmp4 \
-master_pl_name master.m3u8 \
"$OUTPUT_DIR/v%v/index.m3u8"
PHP: Queue integration
HLS transcoding in background queue, upload to S3 or CDN. Player loads master.m3u8, adapts quality to bandwidth.
Implementation timeline
HLS setup with FFmpeg and S3: 3–4 days. With DRM (Widevine) and analytics: 5–7 days.







