Ch. 15 · Low-Latency and Real-Time Streaming

한국어日本語
7 min

Where Latency Comes From: The Pipeline at a Glance

We break down the time from the moment something is captured to the moment it appears on the viewer's screen (glass-to-glass) into stages, and get a feel for which stages are easy to shorten.

In Chapter 10 you learned that adaptive streaming such as HLS and DASH cuts video into segments a few seconds long (Adaptive streaming). This approach is stable and works well with CDNs, but a segment can only be sent after it has been fully produced, so latency is large by default. This chapter covers where that latency can be reduced, by how much, and at what cost.

Glass-to-glass latency

The total time from something happening in front of the camera lens (glass) to it appearing on the viewer's screen (glass) is called glass-to-glass latency. It isn't produced in one place. It is the sum of several stages.

Capture Encoding Ingest Packaging CDN Playerbuffer Screen The highlighted stages (encoding, packaging, player buffer) are where settings change the most Your protocol choice changes the character of the ingest and delivery legs
The stages where latency builds up: most of them hold a buffer (a wait)
StageWhat creates latencyHow to reduce it
EncodingB-frames and lookahead wait for future frames; frame-level multithreading waits tooTurn off B-frames, reduce lookahead, use a faster preset (Lesson 2)
PackagingA segment is only a finished file once it ends → you wait one segment lengthSplit it into shorter pieces (chunks or parts) and send them before the segment is complete (Lesson 3)
DeliveryCDN cache tiers, network round-trip time (RTT)Check that your protocol and CDN support low latency
Player bufferThe player stacks up a few segments in advance to avoid stallsShrink the buffer and accept a higher risk of stalls — often the biggest item

Example: how segment length affects latency (calculated with assumed numbers)

Suppose the player keeps N segments queued while playing. The player buffer alone then puts you N × segment length behind. For example, with 6-second segments and N=3 that is 18 seconds, and with 2-second segments and N=3 it is 6 seconds. These numbers are assumptions for illustration, and how many segments a real player queues depends on the player and its settings. The point is that shortening the segments shrinks this term proportionally.

Latency ↔ stability ↔ efficiency: a three-way scale

Every way of cutting latency gives something up. A smaller buffer makes stalls more likely when the network wobbles, and more frequent keyframes cost more bitrate for the same quality (GOP structure). Turning off B-frames lowers compression efficiency (Inter prediction). In practice the goal is not "the lowest latency" but as much latency as your use case allows.

Use caseLatency requirement (typical grouping)
Regular live broadcast (mostly watching)Tens of seconds is usually tolerated — stability and quality come first
Live with chat or donations, sportsWant a few seconds → LL-HLS / LL-DASH
Video calls, remote consultations, auctions and quizzes where interaction is the pointAround one second or less → WebRTC family

These ranges are rough groupings commonly used in the industry. The exact thresholds differ by service.

Glass-to-glass latencyGlass-to-glass latency

The total time from the moment something is captured by the camera to the moment it appears on the viewer's screen.

Player bufferPlayer buffer

The amount the player downloads ahead of playback to prevent stalls. It is the first thing you shrink for low latency, and also the riskiest.

RTTRound-trip time

The time a packet takes to go out and come back. It is the yardstick for sizing buffers in retransmission-based protocols.

Check yourself

What is the most direct reason segment-based streaming (HLS/DASH) has high latency by default?