Skip to content
Whatplay
All guides

Playback

HLS and DASH: how adaptive streaming works

4 min read

If you’ve ever seen a video start out blurry and turn sharp a few seconds later, or drop in quality when the Wi-Fi weakens, you’ve seen adaptive streaming in action. Almost all video on the internet is delivered this way, using two systems: HLS and DASH. They work in a similar way, and understanding them explains a lot of behavior that looks like a fault but isn’t.

The idea: split it up and offer several qualities

Instead of one huge file, the server stores the video split into segments a few seconds long. And not just once, but several times: the same movie in 1080p, in 720p, in 480p, each version with its own data rate, or bitrate. The player first downloads an index, the manifest, which tells it which versions exist and where each chunk is. Then it requests the segments one by one and, at every moment, picks the quality it thinks your connection can sustain.

The advantages are clear: the video starts quickly because it begins with light chunks, it adapts to the network without stopping, and you can jump to any point by downloading only what’s needed. Live broadcasts work the same way: the manifest keeps updating with the new segments.

HLS

HLS (HTTP Live Streaming) was created by Apple and is the most widespread. Its manifest is a text file with the .m3u8 extension, and there are two kinds.

The master playlist lists the available qualities. Each one has its bandwidth, resolution and codecs:

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080,CODECS="avc1.640028,mp4a.40.2"
1080p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=1280x720,CODECS="avc1.64001f,mp4a.40.2"
720p/index.m3u8

The media playlist for each quality lists its segments and how long each one lasts:

#EXTM3U
#EXT-X-TARGETDURATION:6
#EXTINF:6.0,
segmento-001.ts
#EXTINF:6.0,
segmento-002.ts
#EXT-X-ENDLIST

The #EXT-X-ENDLIST tag means the video is complete, that is, on demand. If it’s missing, it’s a live broadcast and the player requests the list again every few seconds. Segments can be TS or fMP4 (fragmented MP4, recognizable by the #EXT-X-MAP tag). Audio in other languages and subtitles can come as separate tracks, declared with #EXT-X-MEDIA.

By the way, the fact that the HLS manifest has the same extension as many video lists causes confusion; we clear it up in M3U, M3U8 and W3U.

DASH

DASH (Dynamic Adaptive Streaming over HTTP, or MPEG-DASH) is an open international standard. Its manifest is an XML file with the .mpd extension. It organizes the content into adaptation sets (the video, the audio for each language, the subtitles) and, within each one, representations, which are the quality levels. Many platforms and websites use it. For the viewer, the difference from HLS is almost nil: the index format changes, not the idea.

Why does the quality change?

The player measures how fast the segments arrive and how many seconds it has stored ahead, the buffer. If the download has plenty of headroom, it moves up in quality; if things are tight, it drops down before it runs out of video. That’s why:

  • The start is often blurry: it doesn’t know yet how much your connection can handle, so it starts cautiously.
  • It drops when another device at home downloads something or when you move away from the router.
  • It takes a few seconds to go up even when the network improves, because it switches at the next segment, not instantly.
  • A video may never go above 720p even if you have fiber, if the server doesn’t offer more or the device can’t decode the higher version.

A temporary drop in quality isn’t a fault: it’s the system avoiding an interruption. If interruptions are frequent, see dropouts, stuttering and slow loading.

Live, delay and window

In a live broadcast, the player doesn’t position itself at the very last second broadcast, but a few segments behind, to leave some margin. That’s why a live stream over the internet usually runs behind traditional TV, and two devices can be out of sync. Some broadcasts let you go back a while, as far as the manifest’s window allows; others only offer the latest segments.

Encryption and DRM

HLS can encrypt segments with AES-128 and a key downloaded from an address. That isn’t DRM: any HLS player can open it if it can download the key, and so can Whatplay. DRM (Widevine, PlayReady, FairPlay) is something else: a device-bound licensing system used by paid platforms, declared in HLS with methods such as SAMPLE-AES and in DASH with the ContentProtection tag. Whatplay doesn’t play DRM content; we explain this in the Whatplay browser and DRM.

HLS and DASH in Whatplay

  • You can put the address of an .m3u8 or an .mpd in a list, or open it once with “Add list” and “Just play, don’t save”.
  • The quality is chosen automatically. In the player’s “Options” you can see the resolution and Mb/s of what’s playing.
  • In the browser, when a website uses HLS or DASH, the “Videos on this page” sheet shows the highest resolution it offers (“up to 1080p”) and how many quality levels it has.
  • When you cast it to a Chromecast, the TV usually downloads the segments by itself. If the server requires access details the TV can’t send, your phone acts as a bridge and has to stay on the Wi-Fi.

More guides

Still have a question?

Write to us and we’ll help you out.

Contact us

Telegram