Fundamentals 7 min read

What Is HLS? A Deep Dive into HTTP Live Streaming and Its Comparison with DASH

HTTP Live Streaming (HLS) is Apple’s HTTP‑based media protocol that segments video into .ts files indexed by .m3u8 playlists, supporting adaptive bitrate, encryption, and CDN acceleration, and the article compares its features, workflow, VOD vs live modes, and how to generate segments with ffmpeg.

Goodme Frontend Team
Goodme Frontend Team
Goodme Frontend Team
What Is HLS? A Deep Dive into HTTP Live Streaming and Its Comparison with DASH

What is HLS?

HLS (HTTP Live Streaming) is a protocol introduced by Apple that delivers media over HTTP. It splits audio/video into small

.ts

segment files and uses an

.m3u8

playlist to index and schedule them. Its good compatibility, CDN support, and adaptive‑bitrate capabilities make it popular for both VOD and live streaming.

Comparison with DASH

Standard ownership: HLS is Apple’s proprietary protocol; DASH is an international MPEG standard.

Container format: HLS traditionally uses MPEG‑TS, modern versions also support fMP4; DASH primarily uses fMP4.

Playlist format: HLS uses

.m3u8

(M3U8); DASH uses

.mpd

(XML).

Latency: HLS typically 6‑30 s; DASH 2‑15 s.

Bitrate adaptation: Both support multi‑bitrate playlists, DASH is more flexible.

Encryption: HLS supports AES‑128 and FairPlay; DASH supports Widevine, PlayReady, FairPlay, etc.

Browser support: HLS natively in Safari; other browsers need

hls.js

. DASH works natively in Chrome/Edge via Media Source Extensions.

Player ecosystem: HLS: Safari, QuickTime,

hls.js

,

video.js

; DASH: Dash.js, Shaka Player, Bitmovin.

HLS Interaction Flow

1. Master playlist (main.m3u8)

The client (e.g., using

hls.js

) requests the master playlist, which may look like:

<code>#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
low/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=1280x720
mid/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1920x1080
high/index.m3u8
</code>

Key tags:

#EXTM3U

: marks the file as an M3U8 playlist.

#EXT-X-STREAM-INF

: introduces a variant stream; attributes such as

BANDWIDTH

(bitrate) and

RESOLUTION

(width × height) guide adaptive selection.

2. Media playlist (media.m3u8)

Example content:

<code>#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0

#EXTINF:9.984,
fileSequence0.ts
#EXTINF:10.000,
fileSequence1.ts
#EXTINF:10.000,
fileSequence2.ts

#EXT-X-ENDLIST
</code>

Important tags:

#EXT-X-VERSION

: protocol version (optional).

#EXT-X-TARGETDURATION

: maximum segment duration in seconds.

#EXT-X-MEDIA-SEQUENCE

: sequence number of the first segment.

#EXTINF:&lt;duration&gt;,

: duration of the following media segment.

#EXT-X-ENDLIST

: indicates the playlist is complete (used for VOD).

VOD vs. Live

HLS supports two modes:

Video‑on‑Demand (VOD): playlist contains all segments, includes

#EXT-X-ENDLIST

, and the media duration is known.

Live: playlist is continuously updated, does not contain

#EXT-X-ENDLIST

, and only recent segments are listed, so total duration is unknown.

Generating HLS Segments with ffmpeg

Use a single ffmpeg command to split a source video into 10‑second .ts segments and produce a master

.m3u8

playlist:

<code>ffmpeg -i input.mp4 \
 -codec: copy \
 -start_number 0 \
 -hls_time 10 \
 -f hls output.m3u8
</code>

Conclusion

HLS is a widely adopted streaming protocol with strong compatibility and a mature ecosystem, making it suitable for both VOD and live scenarios. However, its higher latency in live streaming may motivate some to consider DASH as a future‑proof alternative.

FFmpegadaptive bitrateHLSStreaming ProtocolHTTP Live Streaming
Goodme Frontend Team
Written by

Goodme Frontend Team

Regularly sharing the team's insights and expertise in the frontend field

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.