The bitrate of an ingested stream may not be suitable for the network conditions of a streaming client. As a result, the quality of the playback is affected. To resolve this issue, you can use live stream transcoding. This topic describes the scenarios and limits of live stream transcoding. This topic also describes the transcoding feature, transcoding template parameters, transcoding rules, and the adaptive width feature.
Scenarios
If a high bitrate is set on the stream ingest client but the bandwidth of the streaming client is insufficient, stuttering occurs during video playback. If a low bitrate is set on the stream ingest client, the resulting playback quality on the streaming client is low. In such scenarios, you can use live stream transcoding to resolve these issues.
A player plug-in requires multi-bitrate switching. To allow the player plug-in to switch between different bitrates, you must provide streaming URLs of the ingested stream at different bitrates. You can use the real-time transcoding feature of ApsaraVideo Live to achieve this purpose.
Limits
A standard transcoding template and a Narrowband HDTM transcoding template cannot be used at the same time. You can use only one type of transcoding templates for a specific application under a domain name.
For live centers of the China (Beijing), China (Shanghai), China (Shenzhen), and Singapore regions, each domain name supports up to 50 concurrent transcoded streams. For live centers of other regions, each domain name supports up to 10 concurrent transcoded streams. If you transcode a high definition (HD) live stream into standard definition (SD) and low definition (LD) for playback, two transcoded streams are recognized.
If ApsaraVideo Live cannot meet your business requirements, contact your Alibaba Cloud account manager or consult Alibaba Cloud by other means.
H.265 transcoding is not supported in regions outside the Chinese mainland. If you want to use H.265 transcoding, contact your Alibaba Cloud account manager or consult Alibaba Cloud by other means.
Transcoding templates
ApsaraVideo Live provides various transcoding templates, including the default transcoding templates, custom transcoding templates, Real-Time Streaming (RTS) transcoding templates, and multi-bitrate transcoding templates.
The default transcoding templates are preset by the system, and the template ID, output resolution, and output bitrate in such a template cannot be changed. If the default transcoding templates cannot meet your requirements, you can use a custom transcoding template or an RTS transcoding template. In a custom transcoding template, you can specify the encoding format, resolution, bitrate, frame rate, group of pictures (GOP) size, and template ID and also specify how to trigger transcoding.
Both the default and custom transcoding templates include standard transcoding templates and Narrowband HDTM transcoding templates. In addition to parameters in standard transcoding templates and Narrowband HDTM transcoding templates, RTS transcoding templates allow you to configure the B-frame Removal and Opus Transcoding parameters for RTS playback.
Default transcoding templates
NoteApsaraVideo Live preserves the aspect ratio of a video during transcoding. The video width is automatically adapted to the video height. For more information, see the Adaptive width section of this topic.
Narrowband HDTM transcoding templates
Template name
Template ID
Resolution (width × height)
Bitrate (Kbit/s)
Output specification for billing
Low definition
ld
360
≤ 420
LD
Standard definition
sd
432
≤ 580
SD
High definition
hd
648
≤ 1,100
SD
Ultra-high definition
ud
1080
≤ 1,900
HD
Custom transcoding templates
You can configure parameters in a custom transcoding template based on your business requirements.
NoteA custom Narrowband HDTM transcoding template cannot transcode streams to the H.265 codec. If you want to use the H.265 codec, contact your Alibaba Cloud account manager or consult Alibaba Cloud by other means.
RTS transcoding templates
You can configure parameters in an RTS transcoding template based on your business requirements.
Multi-bitrate transcoding templates
You can configure parameters in a multi-bitrate transcoding template based on your business requirements.
Live stream transcoding
Configure live stream transcoding
You can configure the transcoding feature by using one of the following methods:
Use the ApsaraVideo Live console
For more information, see Configure default transcoding, Configure custom transcoding, and Configure multi-bitrate transcoding.
Call API operations
You can call the following API operations:
The following sample code shows how to use the server SDK for Java to configure default transcoding:
// Replace the placeholder values with actual values. DefaultProfile profile = DefaultProfile.getProfile("<regionId>", "<ALIBABA_CLOUD_ACCESS_KEY_ID>", "<ALIBABA_CLOUD_ACCESS_KEY_SECRET>"); IAcsClient client = new DefaultAcsClient(profile); AddLiveStreamTranscodeRequest addLiveStreamTranscodeRequest = new AddLiveStreamTranscodeRequest(); addLiveStreamTranscodeRequest.setDomain("<DomainName>"); addLiveStreamTranscodeRequest.setApp("<AppName>"); addLiveStreamTranscodeRequest.setTemplate("<Template>"); // // Code for other features. // try { AddLiveStreamTranscodeResponse addLiveStreamTranscodeResponse = client.getAcsResponse(addLiveStreamTranscodeRequest); System.out.println(new Gson().toJson(addLiveStreamTranscodeResponse)); // todo something. } catch (ServerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientException e) { // TODO Auto-generated catch block e.printStackTrace(); }
NoteIf changes are made to the transcoding configuration, you must re-ingest a stream for the configuration to take effect.
For more information about the server SDK for Java, see Use the server SDK for Java.
View the transcoded streams
After you complete the transcoding configuration, multiple streaming URLs at different bitrates are provided for a newly ingested stream. To view the streaming URLs, log on to the ApsaraVideo Live console and click Streams in the left-side navigation pane. On the Active Streams tab of the Stream Management page, find the ingested stream that you want to view and click View URLs in the Actions column. The URLs of the source stream at the original bitrate and the URLs of the transcoded stream are displayed.
NoteIf the URLs of the transcoded stream are not displayed, check whether Trigger Transcoding is turned on in your transcoding template and the stream is not pulled.
To generate the URL of a transcoded stream, add the "_Transcoding template ID" after the stream name in the URL of the source stream. For more information, see Generate ingest and streaming URLs.
Transcoding rules
ApsaraVideo Live supports delayed transcoding. This feature allows ApsaraVideo Live to start transcoding a live stream only when a viewer joins the live stream and stops transcoding if no viewers are detected for 5 minutes.
Each stream can be transcoded only once.
Transcoding is only optional. Configure the feature based on your business requirements.
You can transcode streams in the Flash Video (FLV), Real-Time Messaging Protocol (RTMP), HTTP Live Streaming (HLS), and RTS formats.
Adaptive width
ApsaraVideo Live preserves the aspect ratio of a video during transcoding. The video width is automatically adapted to the video height.