Getting ready
The video is cut into short files called segments, here 6 seconds each. Every segment is encoded several times, from 360p at 0.8 Mb/s up to 1080p at 6 Mb/s. That set of qualities is the quality ladder.
You press play, and the player first downloads a manifest: an HLS playlist or a DASH MPD. It is a small text file listing every rung of the ladder, its bitrate (bits per second) and where its segments are.
Segments are ordinary files fetched over HTTP, so a CDN (content delivery network) keeps copies on edge servers near viewers. The first request is a miss and goes back to the origin; everyone after gets the cached copy.
Adaptive bitrate
The player knows nothing about your network yet, so it starts on a low rung. The 360p segment is only 4.8 megabits (0.6 MB) and arrives in 0.24 s. With 6 s of video in the buffer, playback begins.
Throughput = bits ÷ seconds: 4.8 Mb in 0.24 s is 20 Mb/s. To stay safe the player spends 80% of that, 16 Mb/s, and picks the highest rung that fits: 1080p at 6 Mb/s. That is adaptive bitrate (ABR).
Each 6-second 1080p segment arrives in 1.8 s, so the buffer grows faster than it plays. At its 30 s goal the player stops downloading for a while, then fetches one segment every 6 s, as fast as you watch.
Someone else starts a big download and your share falls to 4 Mb/s. The 1080p segment in flight (36 megabits) now takes 9 s to arrive but plays for only 6 s, so the buffer shrinks from 30 s to 27 s.
The player measured 4 Mb/s; 80% is 3.2 Mb/s, so it picks 720p at 3 Mb/s. Each segment now arrives in 4.5 s, faster than it plays, and the buffer grows again. You get a softer picture instead of a frozen one.
Stalls and live
In a weak signal the link falls to 0.5 Mb/s, below even the lowest rung (0.8 Mb/s). A 360p segment needs 9.6 s for 6 s of video, so the buffer drains. At 0 s the picture freezes and a spinner appears: a rebuffer.
On-demand video already exists, so the player may buffer far ahead. Live segments appear as it happens; an HLS player starts at least three segment lengths back from the newest one: here 18 s. Low-latency HLS and DASH cut that to a few seconds.
The arithmetic
;; step 1/10 · cut-segments · prepare ;; at the origin segment length 6 s (Apple's HLS guide recommends 6 s) one segment = bitrate × 6 s, at every rung (illustrative ladder): 360p 640x360 0.8 Mb/s 4.8 Mb = 0.6 MB per segment 480p 854x480 1.5 Mb/s 9 Mb = 1.13 MB per segment 720p 1280x720 3 Mb/s 18 Mb = 2.25 MB per segment 1080p 1920x1080 6 Mb/s 36 Mb = 4.5 MB per segment segments line up in time, so the player can switch rung at any boundary
Each tile in the buffer is one segment; its colour is its rung on the ladder. Measured throughput here is segment size ÷ download time; real players smooth it over several segments and also watch the buffer level.