Concept 03
Adaptive Bitrate
One video, several encodes at different qualities. The player constantly estimates your available bandwidth and picks the highest quality that will play without buffering — switching mid-stream as conditions change. This is why a stream drops to 480p on a train and jumps back to 1080p on Wi-Fi.
The three variants in this sandbox
| Quality | Resolution | Target bitrate | Media playlist |
|---|---|---|---|
| 1080p | 1920×1080 | 5.0 Mbps | stream_0.m3u8 |
| 720p | 1280×720 | 2.8 Mbps | stream_1.m3u8 |
| 480p | 854×480 | 1.4 Mbps | stream_2.m3u8 |
On the home page, leave quality on Auto and watch the log — LEVEL_SWITCHED events show the player picking a variant. Lock it to a specific quality to override the algorithm.
How the switching decision is made
- 1
Estimate bandwidth
The player measures how fast recent segments downloaded to estimate your throughput.
- 2
Compare against variant bitrates
It picks the highest variant whose bitrate fits comfortably within that estimate, with headroom to keep the buffer full.
- 3
Switch at a segment boundary
Switches happen between segments, so playback never stutters. The next segment simply comes from a different variant's playlist.
- 4
Repeat every segment
The loop runs continuously, adapting up or down as your connection changes.
How the ladder was built
A single ffmpeg command splits the source into three scaled encodes and writes the master playlist that ties them together.
[0:v]split=3[v1][v2][v3];
[v1]scale=1920:1080[v1out];
[v2]scale=1280:720[v2out];
[v3]scale=854:480[v3out]
-b:v:0 5000k -b:v:1 2800k -b:v:2 1400k
-var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2"
-master_pl_name master.m3u8