Skip to content

How to HLS work

Updated: at 09:12 AM

HTTP Live Streaming (HLS) is a media streaming protocol created by Apple to deliver audio and video content over the internet. Here’s a simplified overview of how HLS works:

Table of contents

Open Table of contents

What is HLS?

HLS (HTTP Live Streaming) is a streaming protocol that allows you to deliver video content over the internet. It works by breaking the video into small chunks, which are then delivered over HTTP. This approach allows for adaptive bitrate streaming, meaning the video quality can adjust in real-time based on the viewer’s internet connection speed.

Key Components of HLS:

  1. Media Files: The original media content (audio/video) is encoded and split into small segments (typically 2-10 seconds each). These segments are usually in MPEG-TS format.
  2. Playlist (M3U8) Files: These are text files that list the URLs of the media segments. There are two types of playlists:

Content Preparation

Video Source → Encoder → Segments (.ts files)

                         Playlist (.m3u8)

                        Server

                       Player (Client)

Adaptive Bitrate

HLS supports multiple bitrates to suit different network conditions. The playlist can contain multiple versions of the video at different resolutions and bitrates.

  1. Example:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
low.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=854x480
medium.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
high.m3u8

And a corresponding media playlist (low.m3u8):

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
segment0.ts
#EXTINF:10.0,
segment1.ts
#EXTINF:10.0,
segment2.ts

In this example:

Streaming

Content Updating

Advantages of HLS

Disadvantages of HLS

How to setup hls server