Live stream transcoding

更新时间:
复制 MD 格式
A["Live stream pushed to ApsaraVideo Live"]-->B["ApsaraVideo Live transcodes stream based on template"]; B-->C["Output streams with different bitrates and resolutions"]; C-->D("End users play the most suitable stream");

Live stream transcoding prevents playback issues caused by high or low ingest bitrates. This topic covers scenarios, limits, features, template parameters, transcoding rules, and adaptive width.

Use cases

  • When the ingest bitrate is high but client bandwidth is limited, video playback can stutter. Conversely, a low ingest bitrate results in poor playback quality. Live stream transcoding resolves these issues.

  • Player plugins must support multi-bitrate switching. To enable this, provide the player with multiple streaming URLs for the same ingest stream, each with a different bitrate. ApsaraVideo Live's real-time transcoding feature generates these URLs.

    • You can ingest a stream with H.264 encoding and transcode it into an H.265 live stream in real-time to reduce bandwidth.

    • 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 browser incompatibility with H.265, you can transcode the stream into an H.264 live stream in real-time.

Important

The live stream transcoding feature incurs transcoding fees. Fees are based on the transcoding standard, resolution, and total transcoding duration. For more information about the billing rules, see Live stream transcoding fees.

Limitations

  • When you configure transcoding templates for a domain name and AppName, you cannot set the Template Type for a single template to both Standard Transcoding and Narrowband HDTM template.

  • When you configure a transcoding template for a specific AppName, it is applied only if the AppName in the ingest URL matches the one in the template. Sub-streaming domains inherit transcoding templates from the primary streaming domain, so any configurations specific to sub-streaming domains are ignored.

  • For live centers in China (Beijing), China (Shanghai), and China (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 live stream is ingested and transcoded into standard-definition and low-definition streams for playback, this counts as two concurrent transcoded streams. When the limit is reached, connections that exceed the limit will play the original stream. To view your current usage and request a quota increase, go to basic configuration > Basic Information for your streaming domain.

  • If the live streaming service does not meet your business requirements, please contact your Alibaba Cloud account manager or reach out to us through other channels.

Features

The transcoding feature includes Default Transcoding, Custom Transcoding, Multi-bitrate Transcoding, and HTML5 Auto Transcoding.

Default Transcoding: You can use system-preset templates, which include the template ID and the output resolution. The system presets the output bitrate, and it cannot be modified.

Custom Transcoding: You can configure the encoding format, resolution, bitrate, frame rate, video GOP, transcoding trigger, and 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

Template details>>

  • Standard templates

Template

Quality ID (H.264)

Quality ID (H.265)

Latency ID (H.264)

Latency ID (H.265)

Resolution

Bitrate

LD (Landscape)

lld

lld265

lld-ll

lld265-ll

Adaptive width, height: 360

≤470

SD (Landscape)

lsd

lsd265

lsd-ll

lsd265-ll

Adaptive width, height: 432

≤680

HD (Landscape)

lhd

lhd265

lhd-ll

lhd265-ll

Adaptive width, height: 648

≤1500

UHD (Landscape)

lud

lud265

lud-ll

lud265-ll

Adaptive width, height: 1080

≤2500

SD (Landscape)

lsd540

lsd265-540

lsd540-ll

lsd265-540-ll

Adaptive width, height: 540

≤680

LD (Portrait)

lld-v

lld265-v

lld-v-ll

lld265-v-ll

Width: 360, adaptive height

≤470

SD (Portrait)

lsd-v

lsd265-v

lsd-v-ll

lsd265-v-ll

Width: 432, adaptive height

≤680

HD (Portrait)

lhd-v

lhd265-v

lhd-v-ll

lhd265-v-ll

Width: 648, adaptive height

≤1500

UHD (Portrait)

lud-v

lud265-v

lud-v-ll

lud265-v-ll

Width: 1080, adaptive height

≤2500

SD (Portrait)

lsd540-v

lsd265-540-v

lsd540-v-ll

lsd265-540-v-ll

Width: 540, adaptive height

≤680

Original quality - Audio-only transcoding

oriopus

Original quality - Audio-only transcoding

oriaac

  • Narrowband HD templates

Template

Quality ID (H.264)

Quality ID (H.265)

Latency ID (H.264)

Latency ID (H.265)

Resolution

Bitrate

LD (Landscape)

ld

ld265

ld-ll

ld265-ll

Adaptive width, height: 360

≤450

SD (Landscape)

sd

sd265

sd-ll

sd265-ll

Adaptive width, height: 432

≤480

HD (Landscape)

hd

hd265

hd-ll

hd265-ll

Adaptive width, height: 648

≤1200

UHD (Landscape)

ud

ud265

ud-ll

ud265-ll

Adaptive width, height: 1080

≤1300

SD (Landscape)

sd540

sd265-540

sd540-ll

sd265-540-ll

Adaptive width, height: 540

≤480

LD (Portrait)

ld-v

ld265-v

ld-v-ll

ld265-v-ll

Width: 360, adaptive height

≤450

SD (Portrait)

sd-v

sd265-v

sd-v-ll

sd265-v-ll

Width: 432, adaptive height

≤480

HD (Portrait)

hd-v

hd265-v

hd-v-ll

hd265-v-ll

Width: 648, adaptive height

≤1200

UHD (Portrait)

ud-v

ud265-v

ud-v-ll

ud265-v-ll

Width: 1080, adaptive height

≤1300

SD (Portrait)

sd540-v

sd265-540-v

sd540-v-ll

sd265-540-v-ll

Width: 540, adaptive height

≤480

Important
  • The Template ID does not necessarily correspond to the transcoding specification on your bill. The actual transcoding specification on your bill depends on the resolution of the transcoded video. For example, if you configure LD (ld) transcoding and the transcoded video has a short side ≤ 480 and a long side ≤ 640, you are billed based on the LD specification. If you configure LD (ld) transcoding but the resolution of the transcoded video is 700 × 360, you are billed based on the SD specification. For more information, see Live stream transcoding fees.

  • The system adapts the resolution of the transcoded video based on whether the video is in landscape or portrait mode. For more information, see Adaptive resolution.

Transcoding rules

  • ApsaraVideo Live supports on-demand transcoding by default. The system monitors transcoded live streams. If a stream has no viewers, the system does not perform transcoding. Transcoding starts when the first viewer begins to watch the stream. If the system detects no viewers for five minutes during the transcoding process, transcoding stops.

  • The system transcodes each stream 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 orientation.

  • For adaptive landscape transcoding, the system adapts the width of the transcoded video based on the template height.

  • For adaptive portrait transcoding, the system adapts the height of the transcoded video based on the template width.

The system calculates the adaptive width as follows:

高度自适应

For example, if you transcode a 1920 × 1080 video using the LD (Landscape) template (template ID: ld), the template sets the height to 360, and the adaptive width results in a final resolution of 640 × 360.

For example, if you transcode a 1920 × 1080 video using the LD (Portrait) template (template ID: ld-v), the template sets the width to 360, and the adaptive height results in a final resolution of 360 × 203.

Important

Currently, only Default Transcoding and Custom Transcoding support adaptive resolution.

Configuration

Default transcoding

You can configure Default transcoding in ApsaraVideo Live in two ways:

Configure Default transcoding on the console

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Feature Management > Transcoding.

  3. Select the domain name that you want to configure, click the Default Transcoding tab, and then click Add to configure a transcoding template.

    image

    The following table describes the parameters for the transcoding template.

    Parameter

    Description

    Application Name

    The system first attempts to match a transcoding template with the same AppName as the ingest URL. If no match is found, the system uses a template where AppName is set to an asterisk (*).

    Trigger Transcoding

    • Enabled: Transcoding starts only when the transcoded stream is pulled for the first time.

    • Disabled: Transcoding starts upon stream ingest, even if the stream is not being pulled.

    Template Type

    • Offers two template types: Standard Transcoding and Narrowband HD™ Transcoding. These types differ in quality, performance, and price. The Standard Transcoding includes an Original quality - Audio-only transcoding option.

    • You can select multiple transcoding templates.

    • When you use a transcoding template, the Template ID is a parameter used to construct the transcoding URL. For instructions on how to construct the URL, see Generate live streaming URLs. For more information about template IDs, see System-preset templates. Transcoding modes include quality-priority and latency-priority. In latency-priority mode, the latency of the transcoded stream is lower.

    • For the same domain name, the combination of AppName and Template ID serves as a composite primary key.

    Encryption

    After you enable this feature, you can configure Alibaba Cloud Proprietary Cryptography or DRM Encryption.

    Note

    DRM Encryption is supported only in the Shanghai and Singapore live centers.

    • Alibaba Cloud Proprietary Cryptography

      • Alibaba Cloud video encryption supports only HLS and FLV output formats.

      • KMS CMK ID: The region of the Key Management Service (KMS) key must be the same as the live center of the domain name. If you do not have a key, go to the KMS console to create one. For more information, see Purchase and enable a KMS instance.

      • CMK Rotation Period: An integer from 60 to 3600.

      • For more information about using Alibaba Cloud video encryption, see Alibaba Cloud video encryption.

    • DRM Encryption

      • Before you enable this feature, you must configure a DRM key. For more information, see Configure DRM encryption.

      • DRM Encryption is supported for Widevine and FairPlay over HLS. For FairPlay, you must upload the certificate that you obtained from Apple in DRM Certificate Management. For more information, see Request a FairPlay certificate.

  4. Click OK.

Configure Default transcoding by using an API

// This file is auto-generated, don't edit it. Thanks.
package demo;

import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.core.http.HttpClient;
import com.aliyun.core.http.HttpMethod;
import com.aliyun.core.http.ProxyOptions;
import com.aliyun.httpcomponent.httpclient.ApacheAsyncHttpClientBuilder;
import com.aliyun.sdk.service.live20161101.models.*;
import com.aliyun.sdk.service.live20161101.*;
import com.google.gson.Gson;
import darabonba.core.RequestConfiguration;
import darabonba.core.client.ClientOverrideConfiguration;
import darabonba.core.utils.CommonUtil;
import darabonba.core.TeaPair;

//import javax.net.ssl.KeyManager;
//import javax.net.ssl.X509TrustManager;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.io.*;

public class AddLiveStreamTranscode {
    public static void main(String[] args) throws Exception {

        // HttpClient Configuration
        /*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
                .connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
                .responseTimeout(Duration.ofSeconds(10)) // Set the response timeout time, the default is 20 seconds
                .maxConnections(128) // Set the connection pool size
                .maxIdleTimeOut(Duration.ofSeconds(50)) // Set the connection pool timeout, the default is 30 seconds
                // Configure the proxy
                .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<YOUR-PROXY-HOSTNAME>", 9001))
                        .setCredentials("<YOUR-PROXY-USERNAME>", "<YOUR-PROXY-PASSWORD>"))
                // If it is an https connection, you need to configure the certificate, or ignore the certificate(.ignoreSSL(true))
                .x509TrustManagers(new X509TrustManager[]{})
                .keyManagers(new KeyManager[]{})
                .ignoreSSL(false)
                .build();*/

        // Configure Credentials authentication information, including ak, secret, token
        StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
                // Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
                .accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                .accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
                //.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token
                .build());

        // Configure the Client
        AsyncClient client = AsyncClient.builder()
                .region("<Your RegionId>") // Region ID
                //.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)
                .credentialsProvider(provider)
                //.serviceConfiguration(Configuration.create()) // Service-level configuration
                // Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.
                .overrideConfiguration(
                        ClientOverrideConfiguration.create()
                                  // For more information about endpoints, see https://api.aliyun.com/product/live.
                                .setEndpointOverride("live.aliyuncs.com")
                        //.setConnectTimeout(Duration.ofSeconds(30))
                )
                .build();

        // Parameter settings for API request
        AddLiveStreamTranscodeRequest addLiveStreamTranscodeRequest = AddLiveStreamTranscodeRequest.builder()
                .regionId("<Your RegionId>")
                .domain("<Your Domain>")
                .app("<Your App Name>")
                .template("<Your Template>")
                .encryptParameters("<Your EncryptParameters>")
                // Request-level configuration rewrite, can set Http request parameters, etc.
                // .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
                .build();

        // Asynchronously get the return value of the API request
        CompletableFuture<AddLiveStreamTranscodeResponse> response = client.addLiveStreamTranscode(addLiveStreamTranscodeRequest);
        // Synchronously get the return value of the API request
        AddLiveStreamTranscodeResponse resp = response.get();
        System.out.println(new Gson().toJson(resp));
        // Asynchronous processing of return values
        /*response.thenAccept(resp -> {
            System.out.println(new Gson().toJson(resp));
        }).exceptionally(throwable -> { // Handling exceptions
            System.out.println(throwable.getMessage());
            return null;
        });*/

        // Finally, close the client
        client.close();
    }

}
Note
  • The preceding example shows how to configure transcoding for a live stream with the AppName <AppName>. The transcoding parameters use the system-preset template <ld>. For more information about system-preset templates, see System-preset templates in this topic.

  • setLazy("<true>") indicates that transcoding is triggered only during stream pulling. To trigger transcoding during stream ingest, you can set setLazy("false").

  • For more information about the API, see AddLiveStreamTranscode.

You can log on to the ApsaraVideo Live console, choose Stream Management, find the corresponding ingest record, and click Ingest/Streaming URLs in the Actions column to view the transcoded stream URL.

Note
  • The streaming URLs include the original streaming URL and the transcoded stream URLs.

  • You can create a custom transcoded stream URL by taking the StreamName from the original streaming URL and appending _<Template ID>. For more information, see Generate live streaming URLs.

Custom transcoding

If the Default transcoding templates do not meet your requirements, you can use Custom Transcoding configurations. Custom Transcoding configurations allow you to set the encoding format, resolution, bitrate, frame rate, video GOP, transcoding trigger, and transcoding template ID.

You can configure Custom Transcoding in ApsaraVideo Live in two ways:

Configure Custom transcoding on the console

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Feature Management > Transcoding.

  3. Select the domain name that you want to configure, click the Custom Transcoding tab, and then click Add to configure a transcoding template.image.png

    The following table describes the parameters for the transcoding template.

    Parameter

    Description

    Application Name

    The system first attempts to match a transcoding template with the same AppName as the ingest URL. If no match is found, the system uses a template where AppName is set to an asterisk (*).

    Template ID

    • When you use a transcoding template, the Template ID is a parameter used to construct the transcoding URL. For instructions on how to construct the URL, see Generate live streaming URLs.

    • Do not set a template ID that is identical to a system-preset template ID. For more information about system-preset template IDs, see System-preset templates.

    • For the same domain name, the combination of AppName and Template ID serves as a composite primary key.

    Template Type

    • The options are Standard Transcoding, Narrowband HD™ Transcoding, and Audio-only Transcoding. The quality, performance, and price of standard and Narrowband HD™ templates differ.

    • The Audio-only Transcoding removes the video and outputs only the audio stream.

    Encoding Format

    H.264 and H.265 are supported.

    Recommend Parameter Settings

    Four recommended parameter sets are available: LD, SD, HD, and UHD. When you select a preset, the corresponding frame rate, bitrate, and resolution are automatically filled with default system values. You can then adjust these values as needed.

    Resolution

    The output resolution of the video in pixels. You can select a fixed resolution or have the resolution follow the source.

    Follow source: If the width and height of the source stream are smaller than the adaptive dimensions, the output resolution matches the source. If the width and height are larger, the output resolution uses the adaptive dimensions. You can select one of the following adaptation methods:

    • Adaptive short side

    • Adaptive long side

    • Adaptive landscape/portrait

    Fixed resolution: The output has a specified resolution. Different resolution tiers have different prices. The resolution tiers are as follows:

    • LD: (640 × 480) and below.

    • SD: (1280 × 720) and below.

    • HD: (1920 × 1080) and below.

    • 2K: (2560 × 1440) and below.

    • 4K: (3840 × 2160) and below.

    Note

    • Transcoding is billed based on the resolution tier (LD, SD, HD, 2K, or 4K). The resolution tier is independent of the template IDs for standard templates (including lld, lsd, lhd, and lud) and Narrowband HD™ templates (including ld, sd, hd, and ud). The template IDs are used only as identifiers in API calls and should not be confused with billing tiers.

    • The console does not support custom settings for resolutions higher than 1080p. If your scenario requires 2K or 4K resolution, you can submit a ticket to request it.

      For information about how to submit a ticket, see Contact Us.

    Resolution tier determination rule: The output specification is determined by whether the long and short sides of the output video resolution fall within the range defined for that tier.

    For example, for the SD (1280 × 720) tier:

    • If the long side of the output video resolution is less than or equal to 1280 and the short side is less than or equal to 720, the video belongs to this output specification.

    • If the long side of the output video is greater than 1280 or the short side is greater than 720, the output video belongs to a higher output specification.

    Video Frame Rate

    Follow source: If the source frame rate is within the allowed range, the output frame rate matches the source. If it exceeds the upper limit, the upper limit is used. If it is below the lower limit, the lower limit is used.

    Fixed frame rate: The output has a specified video frame rate in FPS. The value must be less than or equal to the input frame rate.

    Video Bitrate

    Follow source: If the source bitrate is within the allowed range, the output bitrate matches the source. If it exceeds the upper limit, the upper limit is used. If it is below the lower limit, the lower limit is used. Output by ratio is also supported.

    Fixed bitrate: Use the specified bitrate in kbps. The bitrates specified for each resolution tier are as follows:

    • LD: 100 to 800.

    • SD: 200 to 1500.

    • HD: 500 to 4000.

    • 2K: 2000 to 8000.

    • 4K: 4000 to 30000.

    Video GOP (frames)

    Specifies the Group of Pictures (GOP), the interval between two I-frames. The value must be less than or equal to the source stream's GOP and cannot exceed 3 seconds to ensure low latency.

    Audio Bitrate (audio-only transcoding)

    This parameter is displayed when you set Template Type to Audio Only. The unit is kbps. The value ranges from 8 to 1,000.

    Profile (audio-only transcoding)

    This parameter is displayed when you set Template Type to Audio Only.

    • LC-AAC: Low Complexity-Advanced Audio Coding. Offers high transcoding efficiency.

    • HE-AAC: High-Efficiency Advanced Audio Coding. Offers better audio quality than LC-AAC at low audio bitrates, typically below 128 kbps.

    Sampling Rate (audio-only transcoding)

    This parameter specifies the audio sampling rate and is displayed when you set Template Type to Audio Only. Valid values: 22050, 32000, 44100, 48000, and 96000.

    Sound Channels (audio-only transcoding)

    This parameter specifies the number of audio tracks and is displayed when you set Template Type to Audio Only. Valid values: 1 or 2.

    Transcoding Mode (Advanced Configuration)

    Supports quality-priority and latency-priority. In latency-priority mode, the latency of the transcoded stream is lower.

    Trigger Transcoding (Advanced Configuration)

    • Enabled: Transcoding starts only when the stream is pulled for the first time.

    • Disabled: Transcoding starts upon stream ingest, even if the stream is not being pulled.

    Video Encryption (Advanced Configuration)

    After you enable this feature, you can configure Alibaba Cloud Proprietary Cryptography or DRM Encryption.

    Note

    DRM Encryption is supported only in the Shanghai and Singapore live centers.

    • Alibaba Cloud Proprietary Cryptography

      • Alibaba Cloud video encryption supports only HLS and FLV output formats.

      • KMS CMK ID: The region of the KMS key must be the same as the live center of the domain name. If you do not have a key, go to the KMS console to create one. For more information, see Purchase and enable a KMS instance.

      • key rotation period: An integer from 60 to 3600.

      • For more information about using Alibaba Cloud video encryption, see Alibaba Cloud video encryption.

    • DRM Encryption

      • Before you enable this feature, you must configure a DRM key. For more information, see Configure DRM encryption.

      • DRM Encryption is supported for Widevine and FairPlay over HLS. For FairPlay, you must upload the certificate that you obtained from Apple in DRM Certificate Management. For more information, see Request a FairPlay certificate.

    All SEI Passed-through (Advanced Configuration)

    If enabled, all types of SEI messages are passed through. If disabled, SEI messages are not passed through.

    Source-based Keyframe (Advanced Configuration)

    If enabled, the keyframes of the transcoded output stream are aligned with the keyframes of the source stream.

    Source-based PTS (Advanced Configuration)

    If enabled, the Presentation Timestamp (PTS) of the transcoded output stream is aligned with the PTS of the source stream.

  4. Click OK.

Configure Custom transcoding by using an API

Call the AddCustomLiveStreamTranscode API to add Custom Transcoding configuration information for a specific domain name and AppName.

Because the parameter settings for Custom Transcoding are complex, we recommend that you use the console in combination with the API to configure Custom Transcoding.

First, add a Custom Transcoding configuration on the console.

Note

The console provides a preview of the resolution effect and allows you to quickly fill in template parameters for LD, SD, HD, and UHD.

After you adjust the parameters, call the DescribeLiveStreamTranscodeInfo API to query the transcoding configuration information.

Multi-bitrate transcoding

You can use Multi-bitrate Transcoding to configure multiple transcoding profiles within a single template group. In regions with significant variations in network conditions, network fluctuations can impact the playback experience. By configuring multiple bitrates, you allow the player to adapt to the user's bandwidth. After you configure Multi-bitrate Transcoding, the player can automatically select the most appropriate bitrate for the client's network, improving the playback experience.

You can configure Multi-bitrate Transcoding only on the ApsaraVideo Live console.

Configure Multi-bitrate Transcoding on the console

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Feature Management > Transcoding.

  3. Select the domain name that you want to configure, click the Multi-bitrate Transcoding tab, and then click Add to add a Multi-bitrate Transcoding template group.

    1. Click Basic Information to edit the basic information of the Multi-bitrate Transcoding template group.

      多码率转码模板组-基本信息

      The following table describes the parameters:

      Parameter

      Description

      Application Name

      The transcoding template applies only if this AppName matches the AppName in the ingest URL. For the same domain name, the combination of AppName and Template Group ID serves as a composite primary key.

      Template Group ID

      The ID of the transcoding template group. This ID is a parameter used to construct the Multi-bitrate Transcoding URL. It can contain up to 10 characters, including digits, uppercase letters, lowercase letters, and hyphens (-).

      Container Format

      Currently, only HLS is supported.

      Trigger Transcoding

      Currently, transcoding can be triggered only by stream ingest. This action incurs transcoding fees. Triggering transcoding by stream pulling is not supported.

      Timestamp Alignment

      If enabled, this setting overrides the GOP setting in individual templates and uses the source video's GOP.

    2. Click + Add to add a template.image

      Click the added template to edit its parameters. The required parameters may vary depending on the template type. The following table describes the parameters:

      Parameter

      Description

      Template ID

      The ID of an individual template within the transcoding template group. Template IDs within the same template group must be unique.

      Template Type

      Standard Transcoding, Narrowband HD™ Transcoding, and Audio-only Transcoding.

      The Audio-only Transcoding removes the video and outputs only the audio stream.

      Encoding Format

      H.264 and H.265 are supported.

      Resolution

      The output resolution of the video in pixels. Different resolution tiers have different prices. The resolution tiers are as follows:

      • LD: (640 × 480) and below.

      • SD: (1280 × 720) and below.

      • HD: (1920 × 1080) and below.

      • 2K: (2560 × 1440) and below.

      • 4K: (3840 × 2160) and below.

      Note

      Transcoding is billed by resolution tier (LD, SD, HD, 2K, or 4K). These billing tiers are distinct from template IDs of standard templates (such as lld, lsd, lhd, and lud) and Narrowband HD™ template IDs (such as ld, sd, hd, and ud), which are used only as identifiers. Do not confuse the two.

      Resolution tier determination rule: The output specification is determined by whether the long and short sides of the output video resolution fall within the range defined for that tier.

      Take the SD (1280 × 720) output specification as an example:

      • If the long side of the output video resolution is less than or equal to 1280 and the short side is less than or equal to 720, the video belongs to this output specification.

      • If the long side of the output video is greater than 1280 or the short side is greater than 720, the output video belongs to a higher output specification.

      Video Bitrate

      The bitrate used for the specified Resolution, in kbps. The bitrates specified for each resolution tier are as follows:

      • LD: 100 to 800.

      • SD: 200 to 1500.

      • HD: 500 to 4000.

      • 2K: 2000 to 8000.

      • 4K: 4000 to 30000.

      Video Frame Rate

      The output video frame rate in FPS. The value must be less than or equal to the input frame rate.

      Video GOP (frames)

      Specifies the Group of Pictures (GOP), the interval between two I-frames. The value must be less than or equal to the source stream's GOP and cannot exceed 3 seconds to ensure low latency.

      Encoding Format

      Currently, only the AAC encoding format is supported.

      Profile (audio-only transcoding)

      • LC-AAC: Low-Complexity Advanced Audio Coding. Offers high transcoding efficiency.

      • HE-AAC: High-Efficiency Advanced Audio Coding. Offers better audio quality than LC-AAC at low audio bitrates, typically below 128 kbps.

      Bitrate (audio-only transcoding)

      The audio bitrate. The value ranges from 8 to 1,000.

      Sound Channels (audio-only transcoding)

      The number of audio tracks. Valid values: 1 or 2.

      Maximum Bandwidth

      An integer or decimal from 100 Kbps to 100 Mbps, with up to two decimal places. We recommend setting this value to 1.2 to 1.5 times the video bitrate.

  4. Click OK.

Important
  • Currently, Multi-bitrate Transcoding streams are available only as HLS transcoded stream URLs.

  • To play Multi-bitrate Transcoding streams, you must add the aliyunols=on parameter. The aliyunols=on parameter is required and has a fixed value.

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, add a Multi-bitrate Transcoding configuration as shown in the following figure.

image

Note

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, start the stream ingest and use the web-based Alibaba Cloud Player SDK for playback. During debugging, you will find that the player automatically selects the transcoded stream with the appropriate bitrate based on the client's network bandwidth.

image

Note

To use the Alibaba Cloud player, see Player SDK.

H5 automatic transcoding

Real-Time Streaming (RTS) uses the WebRTC protocol. Because native browsers often do not support video B-frames or AAC encoding for WebRTC, H5 automatic transcoding handles these incompatibilities to ensure smooth playback.

You can enable H5 automatic transcoding when you activate RTS. For more information, see Step 5: Activate the RTS feature.

Note
  • H5 automatic transcoding resolves compatibility issues, such as B-frames and AAC encoding, for Real-Time Streaming (RTS) playback in native browsers. To transcode video content, such as by adjusting the bitrate, frame rate, or resolution, you still need to use Default transcoding or Custom Transcoding.

  • H5 automatic transcoding can be used together with Default transcoding or Custom Transcoding.

  • When you use H5 automatic transcoding, fees are incurred for audio-only transcoding. For more information, see Live stream transcoding fees.

Video encryption

The Default transcoding and Custom Transcoding settings include options for video encryption. You can configure Alibaba Cloud Proprietary Cryptography directly within these settings. For details and setup instructions, see Alibaba Cloud video encryption.

References

To learn more about the transcoding configuration APIs, see live stream transcoding.

To use the Java SDK, see the Java SDK guide.