The bitrate of an ingested stream may be too high or too low for a streaming client. As a result, the playback effect is affected. To resolve this issue, you can use live stream transcoding. This topic describes the scenarios and limits of live stream transcoding. It also describes the transcoding features, template parameters, transcoding rules, and width adaption features of live stream transcoding.

Scenarios

  • If a high bitrate is set on the stream ingest client but the bandwidth resources of the streaming client are insufficient, the stream playback stutters. If a low bitrate is set on the stream ingest client, the stream playback effect is poor. 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 among multiple bitrates, you must provide multiple streaming URLs at different bitrates for the same ingested stream. You can use the live stream 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 template for a specific application name in each domain name.
  • A maximum of 10 transcoded streams can be generated at the same time for each domain name. If an input live stream in high definition (HD) is transcoded into streams in standard definition (SD) and low definition (LD) at the same time, the SD stream and LD stream are counted as two transcoded streams.
  • If the live stream transcoding service cannot meet your business requirements, submit a ticket to describe your requirements or contact your service manager.
Note You cannot transcode streams to the H.265 encoding in regions outside China. If you need to transcode streams to the H.265 encoding in regions outside China, submit a ticket to seek help.

Template parameters

ApsaraVideo Live provides various transcoding templates for you, such as the default transcoding templates, custom transcoding templates, Real-Time Streaming (RTS) transcoding templates, and multi-bitrate transcoding templates. The multi-bitrate transcoding templates are supported only for some live centers of ApsaraVideo Live.

The default transcoding templates are system preset templates. The template ID, output resolution, and output bitrate of a default transcoding template are preset and 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, trigger, and template ID.

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 HD TM transcoding templates, RTS transcoding templates allow you to set the B-frame Removal and Opus Transcoding parameters for RTS playback.

  • Default transcoding templates
    Narrowband HD TM transcoding templates
    Template name Template ID Resolution with an adaptive aspect ratio Bitrate (Kbit/s)
    Low definition ld 360 ≤ 420
    Standard definition sd 432 ≤ 580
    High definition hd 648 ≤ 1,100
    Ultra high definition ud 1080 ≤ 1,900
  • Custom transcoding templates

    You can set parameters in a custom transcoding template as needed.

    Note A Narrowband HD TM transcoding template cannot transcode streams to the H.265 encoding. If you want to use this encoding format, submit a ticket to seek help.
  • RTS transcoding templates

    You can set parameters in an RTS transcoding template as needed.

  • Multi-bitrate transcoding templates

    You can set parameters in a multi-bitrate transcoding template as needed. Multi-bitrate transcoding is supported only for streaming domains of the live centers in the Singapore, Japan (Tokyo), and Indonesia (Jakarta) regions.

Transcoding feature

  • Configure the transcoding feature

    You can configure the transcoding feature by using one of the following methods:

    • Use the ApsaraVideo Live console to configure the transcoding feature.

      For more information, see Configure default transcoding, Configure custom transcoding, Configure RTS transcoding, and Configure multi-bitrate transcoding.

    • Use the API or SDKs to configure the transcoding feature.
      You can use the API or ApsaraVideo Live SDKs to perform the following operations: The following code provides an example on how to use ApsaraVideo Live SDK for Java to configure the transcoding feature:
          IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou","<AccessKeyId>", "<AccessKeyScret>");
          IAcsClient client = new DefaultAcsClient(profile);
          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 streams again for the configuration to take effect.
  • 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 Stream Management > Ingest Endpoints. Find the ingested stream that you want to play and view the streaming URLs of the ingested stream. The streaming URLs in the Original Quality section provide streams of the original bitrate, whereas the streaming URLs in other resolution sections provide transcoded streams. You can move the pointer over a URL and click Copy to copy the URL or click Play to play the stream for testing. To use a URL of a transcoded stream in the business code, add the URL after the StreamName parameter of the original bitrate.

    Streaming URLs

Transcoding rules

  • ApsaraVideo Live supports delayed transcoding. When no playback of a live stream is detected, ApsaraVideo Live does not perform transcoding on the live stream. When the playback of the live stream is detected, ApsaraVideo Live starts to transcode the live stream. In the transcoding process, ApsaraVideo Live stops the transcoding if no playback is detected within 5 minutes.
  • Each stream can be transcoded only once.
  • You can enable the transcoding feature as needed.
  • You can transcode streams in the Flash Video (FLV), Real-Time Messaging Protocol (RTMP), HTTP Live Streaming (HLS), and RTS formats.

Width adaption

ApsaraVideo Live provides algorithms to adjust the width of video images proportional to the height during transcoding. Height-based width adaption