Updated on 2024-12-06 GMT+08:00

Transcoding

You can transcode livestreams into video streams with different resolutions and bitrates to meet a broad range of requirements.

Figure 1 Transcoding architecture

Function Overview

The transcoding function allows you to:

  • Transcode source audio and video into one or more formats for playback on a wide range of devices.
  • Adapt the output bitrate to different network bandwidths.
  • Reduce the costs of distributing livestreams. H.265 codec and low-bitrate HD can reduce the bitrate by about 20% at the same resolution.
  • Customize a transcoding template, including ID, resolution, bitrate, and frame rate.

Notes

  • You can configure multiple transcoding templates for one domain name. After a transcoding request is received, a transcoding template in which AppName is the same as that in the request URL takes effect. If you do not need transcoding, delete the transcoding template before stream push.
  • The transcoding rule of the live stream takes effect when the live stream is started. If the transcoding configuration is modified, the modification does not take effect for the ongoing live stream. The modification takes effect only for the live stream that is pushed after the modification.
  • Low-bitrate HD is disabled by default. If you enable it, you will be charged based on the rates of low-bitrate HD.
  • Upsampling is not supported. If the resolution set in a transcoding template is higher than source resolution, the video can be played, but the resolution of the played video is source resolution.

Prerequisites

Pricing Notes

The transcoding function is a billing item. You are charged based on a combination of the codec, output resolution, and length of an output video. Standard transcoding and low-bitrate HD transcoding are billed differently. For details about the transcoded output resolution, see the Output Resolution column in the Live Transcoding area in Live Pricing Details. If you use live transcoding frequently, buy a live transcoding package.

Creating a Transcoding Template

You can customize a template on the Live console or by calling a Live API. If you want to play transcoded live TV streams, obtain a transcoded streaming URL. For details, see Transcoded Streaming URL.

  1. Log in to the Live console.
  2. In the navigation pane, choose Domains.
  3. Click Manage in the Operation column of the desired ingest domain name.

    Set Subservice Type of the domain name to Cloud Live.

  4. In the navigation pane, choose Templates > Transcoding to view the transcoding template information.
  5. Click Create Transcoding Template. A page like Figure 2 is displayed.

    Configure transcoding parameters as instructed by Table 1.

    Figure 2 Creating a transcoding template
    Table 1 Transcoding template parameters

    Parameter

    Description

    Template Name

    Name of a transcoding template.

    App Name

    Application name. The default value is live.

    You can customize the application name. Only letters, digits, underscores (_), and hyphens (-) are allowed.

    Triggered By

    Indicates how live transcoding is triggered. When a transcoding request is received, the transcoding template whose name is the same as the value of AppName in the request address takes effect and transcoding starts.

    • Stream pull: The transcoding task of the corresponding template is triggered only when a transcoded stream is played.
    • Stream push: The transcoding task of the corresponding template is triggered only when a stream is pushed. This mode means longer transcoding duration and increasing fees.

    Default value: Stream pull

    CAUTION:

    The transcoding templates under an AppName support only one triggering mode. If there are multiple transcoding templates, exercise caution when changing the value of Triggered By for the transcoding templates. For example, if the value of Triggered By of a template is changed from Stream push to Stream pull, the value of Triggered By of all transcoding templates under the AppName will be changed to Stream pull.

    Transcoding Type

    Live transcoding type.

    Options:

    • Standard transcoding
    • Low-bitrate HD

    For the same resolution, low-bitrate HD transcoding consumes 20% less bitrate than standard transcoding but costs more.

    Low-bitrate HD means that the output bitrate is lower at a given image quality. If you enable this option, you will be billed based on the rates of low-bitrate HD.

    Video Encoding

    H.264 and H.265 are supported.

    Recommended Resolution

    Screen resolution.

    After the resolution level is selected, the Video Bitrate and Resolution (W x H) parameters are automatically set and the recommended values are provided. You can also change the values as needed.

    Video Bitrate

    Average bitrate of the transcoded video, in kbit/s.

    Value range: 40 to 30,000

    Bitrate Control

    Bitrate control policy.

    Options:

    • Disabled: Bitrate adaptation is disabled. The target bitrate is output as specified.
    • Not higher than source stream: The target bitrate is the smaller value between the specified bitrate and the bitrate of the source file. That is, the bitrate does not increase.
    • Adaptive to source stream: The target bitrate is adaptive to the bitrate of the source file.

    Resolution (W x H)

    Width and height of the video, in pixel.

    If both the width and height are set to 0, the output resolution is the same as that of the source. If only the width or height is set to 0, the output resolution will be scaled based on the value of the side that is not set to 0.

    Value range:

    • Width: The value must be 0 or a multiple of 2 from 32 to 3,840.
    • Height: The value must be 0 or a multiple of 2 from 32 to 2,160.

    Video Frame Rate

    Frame rate of the transcoded video.

    Options:

    • Retain the original
    • Set a new one: If you select this option, you need to enter the frame rate. The value ranges from 0 to 60. If the value is set to 0, the frame rate is adaptive.

    Use Source I-Frame

    Policy for outputting I-frames during encoding.

    • If this function is disabled, I-frames are output based on the configured GOP duration.
    • If this function is enabled, the output I-frames are the same as those of the source. That is, if the source contains I-frames, I-frames are output after encoding. If the source does not contain I-frames, non-I-frames are output after encoding.

    If this function is enabled, the GOP duration setting is invalid. For multi-bitrate transcoding, you are advised to enable Use Source I-Frame so that videos of different bitrates can have the same I-frame.

    GOP Duration

    I-frame interval by time, in second.

    The value ranges from 0 to 10 and defaults to 2.

    If the value is not 0, the I-frame interval is set based on the GOP duration. If the value is 0, the default value is used.

    A larger GOP duration value indicates a longer livestreaming latency. A smaller GOP duration value indicates a higher probability of frame freezing.

    B-Frame Removal

    After this function is enabled, the transcoded video does not contain B-frames.

  6. Click OK.

    A transcoding template is added on the live transcoding page.

  7. Obtain a transcoded streaming URL if you need to stream your video via a transcoded streaming URL. For details, see Transcoded Streaming URL.

Transcoding Template Management

You can perform the following operations on your transcoding template:

  • Edit a transcoding template.

    Click Edit in the Operation column to modify parameters in the template. The value of AppName cannot be changed.

    The transcoding rule of the live stream takes effect when the live stream is started. If the transcoding configuration is modified, the modification does not take effect for the ongoing live stream. The modification takes effect only for the live stream that is pushed after the modification.

  • Delete a transcoding template.

    Click Delete in the Operation column.