All Products
Search
Document Center

ApsaraVideo Live:Live stream transcoding

Last Updated:Aug 01, 2023

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.

Note

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.

Template parameters

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

    Note

    ApsaraVideo Live preserves the aspect ratio of the video during transcoding. The video width is automatically adapted to the video height. For more information, see Adaptive width.

    Narrowband HDTM transcoding templates

    Template name

    Template ID

    Resolution (width × height)

    Bitrate (Kbit/s)

    Output specification in transcoding bills

    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.

    Note

    A 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.

Transcoding feature

  • Configure the transcoding feature

    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, Configure RTS transcoding, and Configure multi-bitrate transcoding.

    • Call API operations or use the SDK

      You can call the following API operations:

      The following sample code provides an example on how to use the server SDK for Java to configure the transcoding feature:

      AddLiveStreamTranscodeRequest addLiveStreamTranscodeRequest = new AddLiveStreamTranscodeRequest();
      addLiveStreamTranscodeRequest.setDomain("<DomainName>");
      addLiveStreamTranscodeRequest.setApp("<AppName>");
      addLiveStreamTranscodeRequest.setTemplate("hd");
      addLiveStreamTranscodeRequest.setSnapshot("no");
      addLiveStreamTranscodeRequest.setRecord("no");
      try {
          AddLiveStreamTranscodeResponse addLiveStreamTranscodeResponse = client.getAcsResponse(addLiveStreamTranscodeRequest);
          System.out.println(addLiveStreamTranscodeResponse.getRequestId());
          // todo something.
      } catch (ServerException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (ClientException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }           
    Note
    • If changes are made to the transcoding configuration, you must ingest a stream again for the configuration to take effect.

    • For more information about the server SDK for Java, see Use the server SDK for Java.

  • Use the transcoding feature

    After you complete the transcoding configuration, multiple streaming URLs at different bitrates are provided for a newly ingested stream. You can log on to the ApsaraVideo Live console and choose Streaming Management > Streams. Find the ingested stream and view its streaming URLs. The streaming URLs for original quality point to streams of the original bitrate, whereas the streaming URLs for custom transcoding point to transcoded streams. For a streaming URL, you can click Copy to copy the URL or click Play to play the stream. To construct a URL of a transcoded stream in the business code, add the transcoding template ID after the StreamName field in the URL of the source stream.

Transcoding rules

  • ApsaraVideo Live supports delayed transcoding. If the system detects that a live stream has no audience, ApsaraVideo Live does not perform transcoding on the live stream. If the system detects that someone is watching the live stream, ApsaraVideo Live transcodes the live stream. During an active transcoding job, ApsaraVideo Live stops the transcoding if no audience is 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 the video during transcoding. The video width is automatically adapted to the video height. 高度自适应