TodayTools

HTTP Live Streaming

How HLS works

How video plays in small chunks over HTTP

Donate
L7ApplicationPort 443TCP
What brings you here?

Watch it happen

How much detail

A phone starts a video: master playlist, a quality level, its playlist, then 6 second chunks.

Lucas's phone
Home Wi-Fi router
Internet
Video server
Wi-FiInternetRequestResponseDataEncrypted

4 steps, 8 packets

First up: Master playlist. Press Play to watch it happen, one step at a time.

0 of 40/4

What is HLS?

HLS plays video by splitting it into small files, usually a few seconds each, and listing them in a text playlist ending in .m3u8. The player downloads the playlist, then fetches the chunks one after another over ordinary HTTPS, keeping a few seconds of video ready.

The same video is prepared at several qualities. If the connection slows down, the player simply fetches the next chunk from a lower quality, so the video keeps playing instead of freezing. Because every chunk is a plain web file, normal web caches can serve millions of viewers. Most phone apps, smart TVs and websites play video this way.

Think of it like this. HLS is like a book delivered one chapter at a time, with a table of contents listing each chapter in large print, normal print and small print. If the post gets slow, you ask for the next chapter in small print: thinner, quicker to send, same story.

Step by step

Normal

4 steps

A phone starts a video: master playlist, a quality level, its playlist, then 6 second chunks.

  1. 1

    Master playlist

    What qualities exist?

    The player fetches master.m3u8, a small text file listing the same video at several qualities, each with its bitrate, size and codecs.

  2. 2

    Pick a quality

    Fit the connection

    The player estimates its speed and picks the best level that fits with room to spare: here 720p at 3.2 Mbps.

  3. 3

    Media playlist

    The list of chunks

    The 720p playlist lists every 6 second segment in order. #EXT-X-ENDLIST at the bottom means this is a finished video, not a live one.

  4. 4

    Segments

    Ordinary HTTPS downloads

    The player downloads segments one by one and keeps a buffer of several ahead. Each is a normal file that any web cache can store, which is why HLS scales to millions of viewers.

Adaptive switch

4 steps

The Wi-Fi slows down, the buffer drains, and the player drops to a lower quality to keep playing.

  1. 1

    Playing 1080p

    Fast downloads

    On a good connection the player chose 1080p. Each 6 second segment arrives in about a second.

  2. 2

    Speed drops

    Someone starts a big download

    The same segment size now takes far longer to arrive. The player measures about 2 Mbps, well below the 6.5 Mbps that 1080p needs, and its buffer starts to shrink.

  3. 3

    Switch down

    Fetch the 480p playlist

    The player loads the 480p media playlist and continues with the next segment number from that level. All levels are cut at the same points, so the switch is seamless.

  4. 4

    Keep playing

    Lower quality, no spinning wheel

    Smaller segments arrive faster than they play, so the buffer refills. When the speed recovers, the player steps back up.

Live stream

3 steps

For a live event the playlist keeps growing, so the player reloads it every few seconds.

  1. 1

    Live playlist

    No end tag

    A live media playlist has no #EXT-X-ENDLIST and lists only the last few segments. The player starts about three segments from the newest one.

  2. 2

    Reload

    Every target duration

    The player asks for the playlist again about every 6 seconds. Each time, an old segment drops off the top and a new one appears at the bottom, and the media sequence number goes up.

  3. 3

    Delay

    Why live HLS lags

    Encoding, cutting 6 second segments and keeping a buffer add up to about 15 to 30 seconds behind real life. Low-Latency HLS cuts this to a few seconds with smaller parts.

Myths and mix-ups

  • HLS is not a special streaming server protocol; it is plain file downloads over HTTPS.
  • A blurry patch is not always a bad source; it is often the player stepping down to a lower quality to avoid a pause.
  • Live HLS is not real time; normal setups run about 15 to 30 seconds behind.
  • HLS does not need a special port; it uses the same port 443 as any website.

Try it yourself

Run these on your own computer to see HLS at work.

  • Read a playlist

    curl -s https://video.example.com/show/master.m3u8

    Use any .m3u8 link from your browser's Network tab while a video plays. You will see the quality levels as plain text.

  • Make your own HLS

    ffmpeg -i in.mp4 -c:v libx264 -c:a aac -f hls -hls_time 6 -hls_playlist_type vod out.m3u8

    Cuts a local video into 6 second segments and writes the playlist next to them.

  • Inspect a stream

    ffprobe -hide_banner https://video.example.com/show/master.m3u8

    Lists every variant with its resolution and bitrate.

  • Watch it in the browser

    F12, Network tab, filter m3u8 or .ts

    Play a video and watch segments arrive every few seconds. Throttle the network to see the quality drop.

HLS at a glance

Layer
Application (7), runs on HTTP
Port
443 (HTTPS), or 80
Transport
TCP (or QUIC with HTTP/3)
Playlist
.m3u8 text file (UTF-8)
Segments
MPEG-TS or fragmented MP4, often 2 to 6 seconds
Adaptive
Yes, the player switches quality per segment
Introduced
2009; RFC 8216 in 2017

Defined inRFC 8216draft-pantos-hls-rfc8216bis (Low-Latency HLS)

Header fields

What HLS puts in its messages, with example values from the stories above.

HTTP/1.1 (inside TLS)

Start line
GET /show/master.m3u8 HTTP/1.1
Path
/show/master.m3u8The master playlist lists every quality level.
Content-Type
application/vnd.apple.mpegurlThe official type for an .m3u8 playlist.
Variants
4 levels, 0.6 to 6.5 MbpsBANDWIDTH is the peak bitrate in bits per second. The player compares it with its own speed.
Target duration
6No segment is longer than this many seconds.
End
#EXT-X-ENDLISTThis video is complete, so the list will not change.
Content-Length
2240000
Duration
6 seconds of video
Download time
1790 msThe player divides bytes by time to estimate the speed of the connection.
Media sequence
10Segment numbers line up across levels, so the player continues with number 12.

Test yourself

Question 1 of 5Score 0

What does a master playlist contain?

Questions people ask

What is an m3u8 file?

A small UTF-8 text playlist. A master .m3u8 lists the quality levels; a media .m3u8 lists the video segments in order, each with its length.

What is the difference between HLS and RTMP?

RTMP is mostly used to send a live stream up to a server. HLS is used to deliver it to viewers, as small files over HTTPS that any web cache can serve.

Why does my video go blurry and then sharp again?

The HLS player switched to a lower quality when your connection slowed down, then back up when it recovered. It does this instead of pausing.

How do I download or play an m3u8 link?

Open it in a player that supports HLS, or use ffmpeg -i link.m3u8 -c copy out.mp4 to save it, if you have the rights to that video.

What is Low-Latency HLS?

An extension that splits segments into smaller parts and lets the player ask for parts before a full segment is ready, bringing live delay down to a few seconds.

Donate