What Is HLS HTTP Live Streaming Explained

What Is HLS? HTTP Live Streaming Explained

What is HLS? HLS, short for HTTP Live Streaming, delivers video as short files listed in a playlist. Any player can fetch them over ordinary HTTP. Apple released it in 2009. Since then, it has become one of the most common ways live and recorded video reaches browsers and phones.

This guide explains how HLS works, what a playlist and a segment are, why it adds delay and why it scales. It draws on Wikipedia, the specification and our own bandwidth maths. It also points to the next articles on RTMP, delay and servers.

📖 Comparing it with RTMP?

Read RTMP vs HLS: Which Protocol Fits Your Live Stream? for the delay, the browsers and the scale of each protocol.


What Does HLS Stand For?

HLS stands for HTTP Live Streaming, a streaming protocol that Apple created and released in 2009. So the name says what it does: it streams live and recorded video over plain HTTP, the same protocol that serves web pages.

According to Wikipedia, an annual industry survey found HLS to be the most popular streaming format in 2022. In addition, Twitch uses it to reach many viewers at once, and it became an IETF informational standard, RFC 8216, in 2017.

The format in five dates

2009Apple releases HTTP Live Streaming
2016Fragmented MP4 joins the original transport stream segments
2017The format becomes RFC 8216
2019Apple announces Low-Latency HLS
2020Low-Latency HLS enters the specification, on 30 April

Table of five dates in the history of HLS: Apple released it in 2009, fragmented MP4 was added in 2016, it became RFC 8216 in 2017, Low-Latency HLS was announced in 2019 and entered the specification on 30 April 2020.


What Is HLS Streaming and How Does It Work?

HLS streaming works in four steps: an encoder makes the video, a packager cuts it into segments, a playlist lists them, and the player downloads them in order. Nothing in the delivery is special, because the player simply makes a series of HTTP requests.

From camera to screen: how an HLS stream is built

1. Encoder
compresses the video
→
2. Packager
cuts segments
→
3. Web server
playlist and files
→
4. Player
downloads in order

A cache or CDN can sit between steps 3 and 4.

Flow diagram of an HLS stream in four steps: an encoder compresses the video, a packager cuts segments, a web server holds the playlist and files, and a player downloads them in order, with an optional cache or CDN between the server and the player.

In a live setup, the encoder often sends the stream to the packager over RTMP. Our beginner’s guide to RTMP covers that first leg.

What Is an M3U8 Playlist?

An m3u8 file is a plain-text playlist that tells the player which segments to download, and in what order. The player reads it, fetches the segments, and then reloads it to look for new ones. Here is a live playlist with three segments:

# stream.m3u8: a live media playlist with three 6-second segments

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:120
#EXTINF:6.000,
segment120.ts
#EXTINF:6.000,
segment121.ts
#EXTINF:6.000,
segment122.ts

Each tag has a job. EXT-X-TARGETDURATION gives the longest segment length in seconds. EXT-X-MEDIA-SEQUENCE numbers the first segment in the list, and EXTINF gives the length of each one. Meanwhile, a live playlist keeps changing, because old segments drop off the top and new ones appear at the bottom. A recorded video, by contrast, ends with an EXT-X-ENDLIST tag.

What Is a Segment?

A segment is a short video file, usually a few seconds long. The player downloads it, plays it and then moves to the next one. Wikipedia gives 6 seconds as a standard length, while the Nginx RTMP module defaults to 5, according to its wiki.

The specification expects each H.264 segment to contain a keyframe. As a result, the encoder’s keyframe interval and the segment length need to match.

What Can a Segment Contain?

Wikipedia lists H.264 video with AAC, MP3, AC-3 or E-AC-3 audio, wrapped in an MPEG-TS or fragmented MP4 container. The container is the file wrapper, and the codecs inside it do the compression.

What an HLS segment can hold

PartWhat Wikipedia lists
ContainerMPEG-TS, and fragmented MP4 since 2016
VideoH.264
AudioAAC, MP3, AC-3 or E-AC-3

Table of what Wikipedia lists for an HLS segment: MPEG-TS or fragmented MP4 containers, H.264 video, and AAC, MP3, AC-3 or E-AC-3 audio.


How Does the Player Change Quality Mid-Stream?

A second playlist lists the same stream at several bitrates, and the player switches between them as the connection changes. This is adaptive bitrate, so a video drops to a lower quality instead of freezing.

# master.m3u8: one stream, two qualities

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=3200000,RESOLUTION=1280x720
720p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1600000,RESOLUTION=854x480
480p/index.m3u8

Each BANDWIDTH value is the rung’s bitrate in bits per second. The specification asks for the peak value, and it warns that an inaccurate one can stall playback. In addition, someone has to create every rung. That work is transcoding, which our beginner’s guide explains.

📖 Sizing the transcoding side?

Read Video Transcoding Server: CPU, GPU, and What to Check Before You Rent for how to measure capacity and which plans fit.


Which Devices and Browsers Play HLS?

HLS plays natively in Safari, on iOS and in Chrome on Android, while other browsers use a JavaScript player that reads the same playlists. According to Wikipedia, those native players need no extra software.

For the others, a script downloads the segments and feeds them to the browser’s video engine, so the viewer notices nothing. Also, MPEG-DASH is the open counterpart that works the same way, with its own playlist format.


Why Does This Format Scale So Well?

HLS scales because its segments are ordinary files, so any web server, cache or CDN can serve them without knowing anything about video. Wikipedia adds that the format passes any firewall or proxy that lets HTTP through. UDP-based protocols, by contrast, often do not.

Segment length sets the request load. A viewer downloads one new segment every time one ends, so shorter segments mean more requests. The chart shows how fast the load grows:

Halving the segment length doubles the requests: 30,000 a minute at 2 seconds

Segment requests per minute from 1,000 viewers, one quality level. Players also reload the playlist.

2-second segments

30,000

4-second segments

15,000

6-second segments

10,000

10-second segments

6,000

Our arithmetic: 1,000 viewers times 60 seconds divided by the segment length.

Horizontal bar chart of segment requests per minute for 1,000 viewers: 30,000 with 2-second segments, 15,000 with 4-second, 10,000 with 6-second and 6,000 with 10-second segments.

A cache absorbs that load, because it fetches each segment from the origin server once and then hands copies to every viewer. Without a cache, however, one 1 Gbps port serves about 166 viewers of a 6 Mbps stream.

📖 How many viewers can one port serve?

Read Dedicated Server for Streaming for the bandwidth maths behind concurrent viewers.


Why Does HLS Add Delay?

HLS keeps players at least three segments behind live by default, so 6-second segments mean about 18 seconds. This latency comes from the rule itself: the specification sets the hold-back at three times the target duration. A shorter target reduces the delay, but it also shrinks the buffer.

Segment length moves that floor: 2-second segments mean about 6 seconds, and 10-second segments mean about 30. Meanwhile, Low-Latency HLS cuts the wait by splitting each segment into parts shorter than a second. The full comparison, with a chart of delay by segment length, is in our RTMP vs HLS guide.


Is the Stream Secure?

HLS can run over HTTPS and encrypt each segment, so both the files and the keys can be protected without a separate protocol. Wikipedia notes a standard encryption mechanism and HTTPS-based key delivery. Also, the Nginx module supports AES-128 encryption for fragments.

The transport matters too. Plain HTTP exposes the playlist and segments to anyone on the path, whereas TLS hides them. The security table in our Nginx RTMP guide lists the fixes for each exposure.


Who Uses HLS?

Twitch delivers with HLS, YouTube accepts it as a live input, and PeerTube cuts live streams into it. Wikipedia says Twitch uses it to reach many concurrent viewers, and the Nginx RTMP module can package live streams in the same format.

YouTube accepts HLS as a live input, for HDR and for newer codecs that an older encoder cannot send over RTMP. Meanwhile, PeerTube cuts live streams into HLS and shares them between viewers.


What Does It Take to Serve HLS Yourself?

You need a web server for the files, a packager that creates them and enough bandwidth, and the Nginx RTMP module does the first two on one server. It receives the stream, cuts the segments and writes the playlist, and Nginx then serves them over HTTP.

  • Packager: the Nginx module or FFmpeg turns one live input into segments.
  • Delivery: any web server works, and a cache keeps viewers off the origin.
  • Bandwidth: the port, not the CPU, sets the audience.

An HLS streaming server also sits inside larger platforms. Our PeerTube guide shows how one cuts live streams into HLS and shares them between viewers.

📖 Ready to run your own?

Read Nginx RTMP Server: How to Set It Up and What to Run It On for a working configuration and the hardware it needs.


What Is HLS? The Short Version

What is HLS in the end? It is a way to deliver video as short files on a playlist, over plain HTTP. As a result, that design makes it easy to cache, easy to play and easy to scale, at the price of a delay.

  • A playlist lists the segments, and a second playlist lists the qualities.
  • Safari and phones play it natively, and other browsers use a script.
  • Shorter segments cut the delay and raise the request load.

Serve HLS From a Server You Control

Swify dedicated servers start at €120 a month, with full root access, 1 Gbps unmetered bandwidth and up to 40 physical cores for FFmpeg. Hosted in the Netherlands on AMS-IX, with monthly billing and no long contracts.

→ Explore Swify Dedicated Servers


Frequently Asked Questions

What is HLS?

HLS is a streaming protocol that delivers video as short files listed in a playlist, fetched over ordinary HTTP. Apple released it in 2009, and browsers, phones and CDNs all handle it, which is why it is so widely used for live and recorded video.

Read RTMP vs HLS: Which Protocol Fits Your Live Stream? to see how it fits next to RTMP.


What does HLS stand for?

HLS stands for HTTP Live Streaming. Apple created it, and it became an IETF informational standard, RFC 8216, in 2017.


What is an m3u8 file?

An m3u8 file is a plain-text playlist used by HLS. It lists the segments to download and their lengths, and a second kind of m3u8 file lists the same stream at several qualities so the player can switch between them.

Read What Is Video Transcoding? A Complete Beginner’s Guide for how each quality is made.


Which browsers and devices play HLS?

Safari, iOS and Chrome on Android play HLS natively. Other browsers play it through a JavaScript player that downloads the same segments and hands them to the browser’s video engine.


Is HLS the same as RTMP?

No. RTMP keeps one live connection open and mostly carries video from an encoder to a server, while HLS delivers short files to viewers over HTTP. Most live setups use RTMP in and HLS out.

Read What Is RTMP? Real-Time Messaging Protocol Explained for the first leg of the pipeline.


Is HLS encrypted?

It can be. HLS runs over HTTPS and has a standard way to encrypt each segment, with the key delivered over HTTPS. Without those, the playlist and segments travel in the clear like any web file.


What do you need to host HLS?

A web server for the playlist and segments, a packager that creates them, and enough bandwidth for your audience. One 1 Gbps port serves about 166 viewers of a 6 Mbps stream without a cache.

Read Nginx RTMP Server: How to Set It Up and What to Run It On for a working setup.


What is the difference between HLS and DASH?

Both cut video into short segments listed in a playlist and let the player switch quality over HTTP. HLS comes from Apple and uses m3u8 playlists, while MPEG-DASH is the open counterpart with its own playlist format.

Read RTMP vs HLS: Which Protocol Fits Your Live Stream? for how the protocols fit together.