ApsaraVideo Live offers live stream encapsulation services, supporting playback protocols such as HLS, DASH, and LL-HLS (low latency HLS), and accommodating TS and CMAF segment formats. This topic details the live stream encapsulation feature.
Introduction
ApsaraVideo Live supports streaming protocols including Real-Time Messaging Protocol (RTMP), HTTP-FLV, and HTTP Live Streaming (HLS). For scenarios requiring reduced latency, ApsaraVideo Live has added support for CMAF and LL-HLS through its live stream encapsulation feature. This allows for the use of LL-HLS - TS, LL-HLS - CMAF, HLS - CMAF, Dynamic Adaptive Streaming over HTTP (DASH) - CMAF, or HLS & DASH - CMAF for live stream encapsulation based on segment type, as illustrated in the table below:
Segment Type | Supported Encapsulation Protocols | Supported Encoding Formats |
TS | LL-HLS - TS |
|
CMAF |
|
|
LL-HLS - TS encapsulates the low-latency HLS protocol in TS Format, while LL-HLS - CMAF does so in CMAF Format, among others.
Features and Advantages
-
Once live stream encapsulation is enabled, the live video stream is segmented into TS or CMAF segments and distributed via HLS or LL-HLS protocols. The M3U8 playlist requested by users is continuously updated with new segment URLs.
-
LL-HLS can segment streams into smaller parts (0.2 to 1 second) and supports blocking loading to achieve latencies of 3 to 5 seconds. CMAF format offers broader device and browser support and newer codecs like H.265, compared to the TS format.
-
The live stream encapsulation service, when used alongside live stream transcoding (including multi-bitrate transcoding) and time shifting, offers versatile and comprehensive functionalities.
Scenarios
Low Latency Live Streaming: Our live streaming service offers HLS playback URLs. To achieve lower latency in your business scenarios while maintaining HLS protocol compatibility, consider encapsulating the HLS protocol with the LL-HLS (low latency HLS) protocol.
Multi-device Browser Support: By default, the HLS playback URLs offered by the live streaming service are encapsulated in the TS segment format. Should you require a different format to meet your business needs, the encapsulation feature allows you to package the content in CMAF format, ensuring compatibility across a wider range of devices and browsers.
Precautions
For smooth playback of CMAF and LL-HLS, the GOP size of the stream ingest must be consistent, and the segment length for live stream encapsulation should be an integer multiple of the GOP length. If transcoded streams are included in the encapsulation settings, their GOP size must also be stable.
For the LL-HLS protocol, consider the following:
-
The stuttering rate may increase under poor network conditions. It's recommended to use live stream encapsulation with multi-bitrate transcoding, allowing the bitrate to adjust automatically and reduce stuttering.
-
Ensure the GOP size of the live stream is fixed at 1 or 2 seconds to prevent stuttering or playback failure.
-
You need to use a player compatible with LL-HLS, such as AliPlayer, hls.js, or ExoPlayer.
-
The same host stream domain name can support up to 100,000 viewers. To support additional viewers, please or submit a ticket for support.
-
When you configure encapsulation for a domain name for the first time, domain acceleration is automatically configured and takes effect within 3 to 5 minutes.
Function Usage
Configure Live Stream Encapsulation
ApsaraVideo Live currently supports two methods for configuring the live stream encapsulation feature.
Use Live Stream Encapsulation
Stream Ingest
To ensure smooth playback of CMAF and LL-HLS when using live stream encapsulation, maintain a stable GOP size for the stream ingest.
You can configure OBS Stream Ingest as follows (for additional details on OBS, refer to OBS Streaming Tool):
Playback
Different encapsulation protocols necessitate different playback URLs. Below are examples of playback URLs corresponding to each encapsulation protocol:
Encapsulation Protocol | URL Example |
HLS |
|
DASH |
|
Low Latency HLS |
|
-
When playing encapsulated streams, the
aliyunols=on
parameter is mandatory. -
The protocol URLs provided by each encapsulation format are as follows:
-
LL-HLS - TS: This refers to the low-latency HLS URL and the standard HLS URL.
-
LL-HLS - CMAF: This refers to the low-latency HLS URL and the standard HLS URL.
-
HLS - CMAF: This refers to the HLS URL.
-
DASH - CMAF: This is the DASH URL.
-
HLS & DASH - CMAF: URLs for HLS and DASH.
-
-
We recommend using ApsaraVideo Player. For more details on ApsaraVideo Player, see Player SDK.
-
When using ApsaraVideo Player's web version or playing content directly through the console, you must set up HTTPS certificates and enable cross-domain access. For details on HTTPS certificate configuration, see Configure HTTPS Secure Acceleration. For cross-domain access settings, refer to Configure HTTP Headers.
Use the following example to play with the web version of ApsaraVideoPlayer:
-
Choose the playback type as Live.
-
Enter the streaming URL.
-
Click Play Preview to start playback.
-
To enable cross-domain playback in browsers, configure the HTTP header
Access-Control-Allow-Origin
. For more information, see Configure HTTP Headers.
Advanced Usage
Encapsulate Transcoded Streams
Combine the live stream encapsulation feature with transcoding to encapsulate transcoded streams.
Before encapsulating transcoded streams, you must configure the live stream transcoding feature. For more information, see Live Stream Transcoding.
This section assumes you have already configured the transcoding feature.
When configuring encapsulation, ensure to also encapsulate the Transcoded Stream.
//Whether to ignore transcoded streams. Valid values: true/false. Default value: true
addLivePackageConfigRequest.setIgnoreTranscode(<false>);
To play encapsulated transcoded streams, simply replace the StreamName in the encapsulation protocol URL with StreamName
followed by _Transcoding Template ID
.
For instance, to play a Low Latency HLS transcoded stream, the sample URL would be:
http://<DomainName>/<AppName>/<StreamName_Transcoding Template ID>-llhls.m3u8?aliyunols=on&auth_key=1725503******
-
We recommend using the encapsulation feature alongside the Multi-bitrate Transcoding feature to automatically optimize bitrate for playback under poor network conditions.
-
To play streams using Multi-bitrate Transcoding, simply replace the StreamName with
StreamName
followed by_Transcoding Template Group ID
.
-
When using Multi-bitrate Transcoding for stream encapsulation, the resulting transcoded stream URLs will vary based on the chosen protocol and segment format. For instance, if the encapsulation format is set to DASH - CMAF, only DASH transcoded stream URLs will be generated, while HLS URLs will not be available.
-
When using default or custom transcoding, the URLs of the transcoded streams remain unchanged, and an additional Encapsulation URL for the transcoded stream is provided.
-
For more information on encapsulation URLs, refer to the Playback section of this document.
Time-shifted Playback of Encapsulated Streams
The time shifting feature enables viewers to replay live content during a broadcast. You can use the Live Stream Encapsulation in conjunction with the Time Shifting feature. For more information, see Time Shifting.
When time shifting is enabled, the time-shifted content will adopt the segment length and format defined by the live stream encapsulation. For HLS or LL-HLS - CMAF formats, the segments for time shifting will be in CMAF format. In the case of LL-HLS - TS format, the segments will maintain the TS format.