Início / Conhecimento / Básicos

How HLS Works: From Slicing to Playback

Este artigo está disponível em chinês e inglês; a tradução para português está a caminho.

HLS (HTTP Live Streaming) is Apple's HTTP-based adaptive streaming protocol. Its goal is simple: let any device play smoothly on any network. The fastest way to understand it is to walk one complete chain.

Step 1: encode and slice

The server encodes the source video into several bitrate/resolution variants (say 240p, 480p, 1080p), then cuts each variant into equal-length chunks (typically 2–10 seconds) wrapped as TS or fMP4 files.

Step 2: generate playlists

A media playlist is created for each variant, listing segment order and duration; a master playlist then groups the variants with their bandwidth and resolution metadata.

Step 3: deliver over HTTP

Playlists and segments are ordinary static files that can sit on any web server or CDN. This is HLS's biggest engineering advantage: no expensive dedicated streaming servers are required — plain HTTP infrastructure scales just fine.

Step 4: play on the client

The player fetches the master playlist, picks a variant based on bandwidth and device capability, then downloads segments on demand, remuxes them and feeds the decoder. When network conditions change, it switches variants at a segment boundary — that's adaptive bitrate (ABR) streaming.

HLS latency mainly comes from segment length and buffering. To reduce it, shorten segments (e.g. 1 second) and use extensions such as LL-HLS to push end-to-end delay down to a few seconds.
← What Is M3U8? A Playlist You Can Actually ReadPlay M3U8 Online: Three Easy Ways →