Live stream transcoding resolves playback issues that are caused by high or low ingest bitrates. This topic describes the scenarios, limits, features, template parameters, transcoding rules, and adaptive width of live stream transcoding.
Scenarios
If the ingest bitrate is high and the client bandwidth is limited, video playback may stutter. If the ingest bitrate is low, the playback quality is poor. Live stream transcoding helps you quickly resolve these issues.
Player plug-ins must support multi-bitrate switching. To enable bitrate switching on the frontend player, you must provide multiple streaming URLs with different bitrates for the same ingest stream. The real-time transcoding feature of ApsaraVideo Live provides this service.
You can ingest a stream with H.264 encoding and transcode it into an H.265 live stream in real time to reduce bandwidth usage.
You can ingest a stream with H.265 encoding and transcode it into a low-bitrate H.265 live stream in real time.
To resolve the incompatibility of H.265 in browsers, you can transcode the stream into an H.264 live stream in real time.
The live stream transcoding feature incurs transcoding fees. Fees are charged based on the transcoding standard, resolution, and total transcoding length. For more information about the billing rules, see Live stream transcoding fees.
Limits
When you configure a transcoding template for a domain name and an AppName, you cannot set the Template Type to both Standard Template and Narrowband HDTM template in the same template.
If you configure a transcoding template by AppName, the template takes effect when the AppName in the ingest URL matches the AppName in the template. Sub-streaming domains reuse the transcoding templates of the primary streaming domain. Configurations for sub-streaming domains are invalid.
For live centers in Beijing, Shanghai, and Shenzhen, each domain name supports up to 300 concurrent transcoded streams. For other live centers, each domain name supports up to 50 concurrent transcoded streams. For example, if a high-definition (HD) live stream is ingested and transcoded into standard-definition (SD) and low-definition (LD) streams for playback, it counts as two transcoded streams. When the limit is reached, playback connections that exceed the limit play the original stream. You can go to Basic Information in the basic configuration of your streaming domain to view the current usage and increase your quota.
If the provided live streaming service does not meet your business requirements, you can contact your Alibaba Cloud account manager or consult us through other channels.
Features
The transcoding feature includes Default Transcoding, Custom Transcoding, Multi-bitrate Transcoding, and HTML5 Auto Transcoding.
Default Transcoding: You can reference system-preset templates, which include the template ID and the output resolution. The output bitrate is preset by the system and cannot be modified.
Custom Transcoding: You can set the encoding format, resolution, bitrate, frame rate, video GOP, transcoding trigger, and transcoding template ID.
Multi-bitrate Transcoding: A transcoding template can contain multiple transcoding configurations. After you configure multi-bitrate transcoding, the player can automatically play the live stream with the appropriate bitrate based on the network bandwidth of the client. This improves the playback experience.
HTML5 Auto Transcoding: This feature resolves issues such as the lack of support for video B-frames and AAC encoding in native browsers for Real-Time Streaming (RTS) (artc://).
System-preset templates
Transcoding rules
ApsaraVideo Live supports on-demand transcoding by default. The system monitors live transcoded streams. If no one is watching a stream, transcoding is not performed. Transcoding starts when the first viewer begins to watch the stream. If no one is watching the stream for 5 minutes during the transcoding process, transcoding stops.
Each transcoded stream is transcoded only once.
Transcoding is an optional service that you can configure as needed.
The transcoding feature supports the FLV, RTMP, HLS, and RTS protocols.
Adaptive resolution
Transcoding uses an adaptive resolution algorithm based on whether the video is in landscape or portrait mode.
For adaptive landscape transcoding, the width of the transcoded video is adapted based on the template height.
For adaptive portrait transcoding, the height of the transcoded video is adapted based on the template width.
The following formula describes how the adaptive width is calculated:

For example, if you transcode a 1920 × 1080 video using the LD landscape template (template ID: ld), the resolution has an adaptive width and a height of 360. The resolution of the transcoded video is 640 × 360.
For example, if you transcode a 1920 × 1080 video using the LD portrait template (template ID: ld-v), the resolution has a width of 360 and an adaptive height. The resolution of the transcoded video is 360 × 203.
Currently, only Default Transcoding and Custom Transcoding support adaptive resolution.
Configuration
Default transcoding
You can configure default transcoding in ApsaraVideo Live in two ways:
Custom transcoding
If the default transcoding templates do not meet your requirements, you can use Custom Transcoding. Custom Transcoding lets you set the encoding format, resolution, bitrate, frame rate, video GOP, transcoding trigger, and transcoding template ID.
You can configure Custom Transcoding for ApsaraVideo Live in two ways:
Multi-bitrate transcoding
Multi-bitrate Transcoding lets you configure multiple transcoding modes in a single transcoding template. In some regions, network environments vary greatly, and network fluctuations can affect the playback experience on clients. Therefore, you need to configure multiple bitrates to match different bandwidth conditions. After you configure Multi-bitrate Transcoding, the player can automatically play the live stream with the appropriate bitrate based on the network bandwidth of the client. This improves the playback experience.
Currently, Multi-bitrate Transcoding can only be configured in the ApsaraVideo Live console.
Currently, Multi-bitrate Transcoding streams can provide only HLS transcoded stream URLs.
To play a Multi-bitrate Transcoding stream, you must add the
aliyunols=onparameter.aliyunols=onis a required fixed field.
The following is an example URL:
http://<DomainName>/<AppName>/<StreamName>_<Template Group ID>.m3u8?aliyunols=on&auth_key=1234****The following example shows how to use Multi-bitrate Transcoding in a real-world scenario:
For example, you can add a Multi-bitrate Transcoding configuration as shown in the following figure.

In this template group, four levels of transcoding configurations are customized. For information about the parameter values for different levels, see System-preset templates in this topic.
Then, you can ingest the stream and use the web-based ApsaraVideo Player for playback. During debugging, you can see that the player automatically plays the transcoded stream with the appropriate bitrate based on the network bandwidth of the client.

For more information about using ApsaraVideo Player, see Player SDK.
H5 automatic transcoding
Real-Time Streaming (RTS) is based on Web Real-Time Communication (WebRTC) signaling. Native browser WebRTC does not support video B-frames or AAC encoding. H5 automatic transcoding provides adaptive transcoding to ensure smooth playback.
You can enable H5 automatic transcoding when you activate RTS. For more information, see Step 5: Activate the RTS feature.
H5 automatic transcoding is used to handle issues such as video B-frames and AAC encoding in native browser RTS (artc://). To transcode video content, such as by adjusting the bitrate, frame rate, or resolution, you still need to configure it through Default transcoding or Custom Transcoding.
H5 automatic transcoding can be used in conjunction with Default transcoding or Custom Transcoding.
When you use H5 automatic transcoding, fees for audio-only transcoding are incurred. For more information, see Live stream transcoding fees.
Video encryption
When you configure Default transcoding or Custom Transcoding, you may notice video encryption-related fields. You can implement the Alibaba Cloud Proprietary Cryptography feature through the transcoding configuration. For more information about the Alibaba Cloud video encryption feature and how to implement it, see Alibaba Cloud video encryption.
References
For more information about transcoding-related APIs, see Live stream transcoding.
For more information about using the Java SDK, see Java SDK guide.



