DASH vs HLS: A Beginner’s Guide to Adaptive Streaming Protocols

Updated on
8 min read

Introduction

In the world of video streaming, adaptive bitrate (ABR) provides a seamless viewing experience across a variety of networks and devices. This article is designed for content creators, developers, and anyone interested in optimizing video delivery. We will explore the two leading adaptive streaming protocols: MPEG-DASH (DASH) and Apple HTTP Live Streaming (HLS). You’ll gain insights into how ABR works, key differences between DASH and HLS, implementation steps, and guidance for selecting the best option for your project.

What This Article Covers:

  • Basics of adaptive streaming (manifests, segments, codecs)
  • Protocol overviews: MPEG-DASH and HLS
  • Side-by-side feature comparison (compatibility, latency, DRM, CDNs)
  • Simple packaging and player examples
  • Best practices for choosing the right approach

How Adaptive Streaming Works — The Basics

Adaptive bitrate streaming can be likened to choosing from a restaurant menu (manifest/playlist) where each dish corresponds to short video segments. The player reads the menu and selects video tiles based on current network conditions to provide a smooth playback experience.

Key Building Blocks:

  • Manifests / Playlists: Define available renditions and segments. DASH uses an MPD (XML) file while HLS uses an M3U8 playlist (plain text). For more details, check the HLS specification and DASH guidance.

  • Media Segments: Small files, usually 2–6 seconds long, that contain encoded video/audio. Players download these segments sequentially or via byte ranges.

  • Codecs & Container Formats: Common codecs include H.264 (AVC), H.265 (HEVC), and AV1, while audio often uses AAC. While the container formats historically differed (.ts for HLS and .mp4 for DASH), both now support fragmented MP4 (fMP4) for increased interoperability.

  • Player ABR Logic: Players assess throughput, buffer levels, and CPU usage to decide when to switch bitrates, fetching corresponding segments from the manifest.

Analogy:

Manifest = menu; segment = food portion; player = waiter determining portion size based on diner appetite (bandwidth) and kitchen speed (encoder/CPU).

Protocol Overviews: MPEG‑DASH and HLS

MPEG‑DASH

MPEG-DASH is an open standard (ISO/IEC 23009-1) supported by the DASH Industry Forum (DASH-IF). It is codec-agnostic, employs an MPD manifest written in XML, and allows for advanced segmentation schemes and features such as period/adaptation sets.

Common Use Cases:

  • Multi-platform web deployments using HTML5 players (e.g., dash.js, Shaka Player)
  • OTT services requiring multi-DRM strategies (Widevine, PlayReady)
  • Workflows favoring open standards with detailed control

Explore DASH-IF resources for profiles, examples, and more at DASH-IF.

HLS (HTTP Live Streaming)

Introduced by Apple and later standardized (RFC 8216), HLS is the native streaming protocol on iOS, tvOS, and macOS devices. Initially using MPEG-TS (.ts) segments, HLS now supports fragmented MP4 (fMP4) and includes low-latency extensions (LL-HLS).

Common Use Cases:

  • Applications primarily targeting Apple devices
  • Services requiring compatibility on iOS without additional libraries
  • Streaming for diverse audiences in live and VOD scenarios

For best practices, reference Apple’s streaming documentation at Apple Developer.

Interoperability Improvement: Both protocols now support fMP4 and CMAF (Common Media Application Format), enhancing compatibility. Learn more at CMAF guidance.

Side-by-Side Feature Comparison

Here’s a concise comparison of DASH and HLS features:

FeatureHLS (RFC 8216)MPEG‑DASH (ISO/IEC 23009-1)
Native Apple SupportNative on iOS/macOS/tvOSNo native support on Apple devices (requires player libraries)
Manifest FormatM3U8 (text playlist)MPD (XML)
Segment FormatsMPEG-TS (historically); now fMP4 + LL-HLSfMP4; supports LL-DASH / CMAF
LatencyTraditionally higher; LL-HLS reduces latency but requires supportTypically lower latency with LL-DASH / CMAF depending on implementation
DRMFairPlay for Apple; CMAF + CENC optionsExcellent multi-DRM support (Widevine, PlayReady) via CENC
CDN CachingEffective; segment duration affects cachingEffective; segment duration affects caching
Live vs VODStrong support for both; LL-HLS for low latency liveStrong support for both; LL-DASH for low latency live
Tooling / EcosystemBroad, robust on Apple platformsBroad, strong for web and OTT platforms

Key Notes:

  • DASH’s MPD is expressive with multiple adaptation constructs, while HLS’s M3U8 is simpler to parse. Both formats are mature with extensive tooling support.
  • Historically, higher latency in HLS was due to playlist refresh patterns. Apple’s LL-HLS and CMAF/LL-DASH have narrowed this gap.
  • For DRM, DASH typically integrates with CENC and Widevine/PlayReady, while HLS commonly employs FairPlay.
  • CDN behavior varies: shorter segments may increase requests but can reduce latency. Typical segment lengths are 2–6 seconds; low-latency implementations may use sub-second chunked transfer models.

Ecosystem Highlights:

  • Players: video.js, hls.js, dash.js, Shaka Player, Bitmovin Player, THEOplayer.
  • Packagers & Tools: ffmpeg, Shaka Packager, Bento4, AWS Elemental MediaPackage.
  • Commercial Services: Akamai, AWS (MediaPackage, IVS), Fastly, CloudFront.

Implementation Basics

High-Level Pipeline:

  1. Source asset (camera, file, live encoder)
  2. Transcode to multiple bitrate renditions (e.g., 1080p, 720p, 480p)
  3. Package into HLS and/or DASH (generate M3U8 and/or MPD + segments)
  4. Serve via HTTP(S) from origin/CDN
  5. Client player consumes manifest and plays segments

Minimal ffmpeg Examples

  • Create HLS (fMP4 segments):
ffmpeg -i input.mp4 \
  -map 0:v -map 0:a \
  -c:v libx264 -b:v:0 3000k -s:v:0 1280x720 \
  -c:v libx264 -b:v:1 1500k -s:v:1 854x480 \
  -c:a aac -b:a 128k \
  -f hls \
  -hls_playlist_type vod \
  -hls_segment_type fmp4 \
  -hls_time 6 \
  -master_pl_name master.m3u8 \
  stream_%v.m3u8
  • Create DASH (simple):
ffmpeg -i input.mp4 \
  -map 0:v -map 0:a \
  -c:v libx264 -b:v:0 3000k -s:v:0 1280x720 \
  -c:v libx264 -b:v:1 1500k -s:v:1 854x480 \
  -c:a aac -b:a 128k \
  -f dash -seg_duration 6 manifest.mpd

For production packaging, consider specialized packagers like Shaka Packager or Bento4 to utilize features such as segment alignment, CMAF output, and low-latency options.

Player Integration Examples

  • HLS in the browser (using hls.js):
<video id="video" controls></video>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
  if (Hls.isSupported()) {
    const hls = new Hls();
    hls.loadSource('https://example.com/stream/master.m3u8');
    hls.attachMedia(document.getElementById('video'));
  } else {
    document.getElementById('video').src = 'https://example.com/stream/master.m3u8';
  }
</script>
  • DASH with dash.js:
<video id="video" controls></video>
<script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>
<script>
  const player = dashjs.MediaPlayer().create();
  player.initialize(document.querySelector('#video'), 'https://example.com/stream/manifest.mpd', true);
</script>

Notes:

  • Ensure all streaming assets use HTTPS and have correct MIME types configured (e.g., application/dash+xml for MPD, application/vnd.apple.mpegurl for M3U8).
  • Use hls.js for HLS playback in browsers without native support.
  • For serving both DASH and HLS from the same assets, use CMAF/fMP4 and generate both manifests.

How to Choose: Practical Decision Guide

Checklist for Choosing Between HLS and DASH:

  • Target Devices: Is your audience primarily on Apple devices (iOS/macOS)? If yes, HLS is a reliable choice.
  • DRM Requirements: Need FairPlay for Apple devices? Opt for HLS; for Widevine/PlayReady, DASH with CENC is ideal.
  • Latency Needs: Require low-latency options for live streaming? Consider LL-HLS or LL-DASH with CMAF.
  • Operational Footprint: Prefer open standards and a single packaging solution? CMAF with dual manifests can minimize redundancy.

When to Pick HLS:

  • Your audience predominantly uses iOS/tvOS.
  • You seek straightforward native playback on Apple devices without extra libraries.
  • You prefer Apple’s ecosystem for low-latency implementations.

When to Pick DASH:

  • You require extensive web platform coverage or integration with open-standard DRM.
  • You need multifunctional MPD features for ads or multi-period workflows.
  • You’re creating an OTT service for multiple device platforms.

Hybrid Approaches and CMAF: CMAF allows for a unified package (fMP4) that generates both HLS and DASH manifests, reducing storage and encoding overhead. For FairPlay and Widevine/PlayReady needs, consider a dual-DRM strategy to simplify content delivery.

Simple Decision Flowchart:

  • If mostly Apple users and FairPlay is required -> Choose HLS.
  • If multi-platform strategy is needed with Widevine/PlayReady -> Choose DASH.
  • If seeking single-packaging solution -> Opt for CMAF with dual manifests.

Common Pitfalls and Best Practices (For Beginners)

Typical Mistakes:

  • Segment Duration: Longer segments increase latency; shorter segments heighten request frequency and CPU load. Start with 4–6 seconds for VOD, 2–4 seconds for live content.
  • MIME Types: Ensure MPD utilizes application/dash+xml and M3U8 uses application/vnd.apple.mpegurl or audio/mpegurl based on server requirements.
  • CORS & HTTPS: Browsers necessitate CORS headers and secure contexts; configure your origin/CDN accordingly.
  • Codec Compatibility: Ensure players and devices support the codecs you’ve packaged (e.g., AV1 support varies by device).

Performance & Scalability Tips:

  • Utilize a CDN for global delivery, as segment caching is efficient; adjust cache TTL based on content type.
  • Use separate origins for live and VOD content workflows if differing caching behaviors are required.
  • Align encoding plans based on the expected number of concurrent streams.
  • Consider containerizing packagers and streaming players to streamline operations.

Monitoring & Debugging Basics:

  • Leverage player debug logs and browser developer tools to check manifests and segment retrieval.
  • Monitor CDN hit rates, origin requests, and error rates for performance troubleshooting.
  • Implement performance monitoring tools to track encoding and transcoding loads.
  • Build a lab setup to simulate real conditions for testing and optimization.

Conclusion

MPEG-DASH and HLS are robust ABR streaming protocols. HLS is ideal for applications targeting Apple devices, while DASH offers flexibility and strong multi-DRM support. CMAF acts as a bridge, enabling both protocols to utilize a single package effectively.

Actionable Next Steps:

  1. Package a short VOD asset into both HLS and DASH using ffmpeg or Shaka Packager.
  2. Test playback with hls.js and dash.js across various browsers.
  3. Experiment with CMAF packaging to explore dual manifests and segment sharing.

For a complete streaming system design, consider modular architecture patterns and network optimization techniques for effective delivery.

TBO Editorial

About the Author

TBO Editorial writes about the latest updates about products and services related to Technology, Business, Finance & Lifestyle. Do get in touch if you want to share any useful article with our community.