Learn what causes live streaming latency and how to reduce it at the ingest, server, and playback levels.
Causes of live streaming latency
Stream ingest client
-
A Group of Pictures (GOP) is a sequence of frames starting with a keyframe and serves as the basic encoding and decoding unit. A large GOP size increases latency because the player must load more frames before playback begins.
-
Third-party ingest applications often increase the encoding buffer to prevent stuttering, but a large buffer adds latency.
-
Hardware limitations may prevent the encoder from meeting bitrate, frame rate, or high-profile encoding requirements, causing delays.
Server-side
The server caches stream data before playback to ensure fast startup and reduce stuttering, which introduces latency. Network jitter during playback can add a further 2-3 second delay.
Playback client
Most playback clients without fast-forward support begin decoding only after the receive buffer is full. The time to fill this buffer adds latency.
Reduce latency
To reduce latency, adjust the following settings:
-
Configure the stream ingest client
-
Set the GOP size to 1 or 2 seconds to reduce player load time. Configure this in the Custom transcoding console or through the AddCustomLiveStreamTranscode API.
-
Use the Alibaba Cloud Push SDK to reduce a large encoding buffer that causes high latency.
-
Use hardware encoding on iOS for higher efficiency and lower power consumption. Use software encoding on Android — hardware encoding may cause compatibility issues across device models and CPU types.
-
-
Select an appropriate streaming protocol
ApsaraVideo Live supports three playback protocols: HTTP-FLV, HLS, and RTMP. Select one based on your scenario.
-
HTTP-FLV and RTMP offer lower latency for real-time playback. HLS has higher latency but broader device compatibility.
-
HTTP-FLV and RTMP require a Flash player. HLS plays directly in browsers.
-
Mobile browsers require HLS.
NoteWith HLS, 10-30 seconds of latency is normal. To reduce it, adjust the server configuration or switch to FLV.
The following table compares the HTTP-FLV, HLS, and RTMP protocols.
Protocol
Description
Transport protocol
Video container format
Recommended scenario
HTTP-FLV
Encapsulates streaming data in FLV format over HTTP. Latency is about 2 seconds. Supports HTTPS and Android.
HTTP
FLV, TAG
Low-latency streaming
HLS
Segments streams into TS shards (typically 3-4 shards of 5+ seconds each), resulting in 10-30 seconds latency but smooth playback. Mainly used on iOS for live streaming and recording.
HTTP
M3U8, TS
Cross-platform streaming
RTMP
Splits messages into chunks transmitted over TCP. The receiver reassembles chunks into stream data. Can be unstable. iOS requires a third-party decoder.
HTTP
FLV, TAG
Interactive streaming
-
-
Configure the server
Reduce the server-side cache to decrease latency. Configure latency in the console — a lower setting means a smaller cache. Settings vary by protocol.
-
Log on to the ApsaraVideo Live console.
-
In the navigation pane on the left, click Domain Names to go to the Domain Management page.
-
For the streaming domain that you want to configure, click Domain Settings in the Actions column.
-
Click .
NoteA smaller cache may cause stuttering on unstable networks because data cannot be downloaded in time. Configure this setting as described in Delay Configuration.
-
Real-Time Streaming (RTS)
If the preceding methods are insufficient, use Real-Time Streaming (RTS). RTS delivers millisecond-level latency for tens of millions of concurrent viewers, overcoming the 3-6 second latency of traditional live streaming with ultra-low latency, minimal stuttering, and fast startup.
-
RTS costs
The costs for RTS differ from standard live streaming. Check billing rates on the Alibaba Cloud Pricing page.
-
Activate the RTS service
The RTS overview explains how to activate and use the RTS service.