You can call SetLiveStreamDelayConfig to configure live streaming latency.
Operation description
-
This operation configures the latency for a streaming domain.
-
The server-side cache stores an integer number of Groups of Pictures (GOPs). Therefore, the latency cannot be less than the GOP size. The actual latency is estimated based on the GOP size. For example, if you set RtmpDelay to 4 seconds for an RTMP stream and the GOP size is 2 seconds, the actual latency ranges from 2 seconds (4 - 2) to 6 seconds (4 + 2). If the GOP size is larger than the configured RtmpDelay, for example, GOP = 5 seconds and RtmpDelay = 4 seconds, the latency fluctuates between 0 and 9 seconds.
-
Latency configurations do not take effect for audio-only streams. The default latency is close to 0 seconds.
-
For an HLS configuration, the segment size is calculated as `Delay / 3` and rounded down to the nearest integer. The minimum segment size is 1 second. The maximum number of segments is 4 if the segment size is 3 seconds or more. Otherwise, the maximum is 6 segments.
-
The actual HLS segment size cannot be smaller than the GOP size.
-
The HLS latency is calculated as: Configured Segment Size × 3.
-
If you do not call this operation, the system uses the default values. The default latency is 2 seconds for RTMP and 4 seconds for FLV. For HLS, the default segment size is 5 seconds, which results in a latency of 15 seconds with a maximum of 6 segments.
Queries per second (QPS) limit
The QPS limit for this operation is 1,000 calls per second per user. If you exceed this limit, API calls are throttled, which may affect your business. Plan your calls accordingly.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
live:SetLiveStreamDelayConfig |
update |
*Domain
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
No |
The region ID. |
cn-shanghai |
| DomainName |
string |
Yes |
The streaming domain. |
example.com |
| HlsDelay |
integer |
No |
The HLS playback latency. Unit: seconds. Note
If this parameter is left empty, the latency is set based on the value of HlsLevel. |
4 |
| HlsLevel |
string |
No |
The HLS latency level. This parameter is ignored if HlsDelay is set. Valid values:
Note
If both HlsDelay and HlsLevel are left empty, the default value short is used. |
short |
| FlvDelay |
integer |
No |
The FLV playback latency. Unit: seconds. Note
If this parameter is left empty, the latency is set based on the value of FlvLevel. |
8 |
| FlvLevel |
string |
No |
The FLV latency level. This parameter is ignored if FlvDelay is set. Valid values:
Note
If both FlvDelay and FlvLevel are left empty, the default value short is used. |
medium |
| RtmpDelay |
integer |
No |
The RTMP playback latency. Unit: seconds. Note
If this parameter is left empty, the latency is set based on the value of RtmpLevel. |
4 |
| RtmpLevel |
string |
No |
The RTMP latency level. This parameter is ignored if RtmpDelay is set. Valid values:
Note
If both RtmpDelay and RtmpLevel are left empty, the default value short is used. |
short |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
4C747C97-7ECD-4C61-8A92-67AD806331FF |
Examples
Success response
JSON format
{
"RequestId": "4C747C97-7ECD-4C61-8A92-67AD806331FF"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.