All Products
Search
Document Center

ApsaraVideo Media Processing:Create a transcoding template

Last Updated:Mar 06, 2024

If the preset transcoding templates of ApsaraVideo Media Processing (MPS) cannot meet your business requirements, you can create a custom transcoding template and configure the settings of the template, such as the encoding format, frame rate, and resolution. This topic describes how to create a custom transcoding template.

Limits

By default, up to 10 transcoding templates can be created in a region within an Alibaba Cloud account, including custom and customized transcoding templates. To create more custom transcoding templates, submit a ticket to contact Alibaba Cloud technical support.

Use the MPS console

  1. Log on to the MPS console.

  2. In the top navigation bar, select the region in which you want to use MPS.地域

  3. In the left-side navigation pane, choose Template Management > Transcoding Templates.

  4. On the Custom Template tab, click Add Template.

  5. Configure the parameters in the Basic Parameters, Video Parameters, and Audio Parameters sections.

    1. Basic Parameters

      Parameter

      Description

      Transcoding Template name

      The name of the transcoding template. The name can contain letters, digits, and special characters such as hyphens (-), and can be up to 128 bytes in size. The name cannot start with a special character.

      Transcoding Type

      The type of transcoding. Valid values: Regular Transcoding and Audio Transcoding.

      Note

      If you select Audio Transcoding, only audio streams are generated as the output. The audio transcoding feature is applicable if you want to extract audio from videos or transcode audio.

      Encapsulation Format

      The container format of the output file.

    2. Video Parameters

      Note

      If you want to convert a high dynamic range (HDR) file into a standard dynamic range (SDR) file, you can submit a ticket to contact Alibaba Cloud technical support for adaptive conversion. This can prevent overexposure or underexposure.

      Parameter

      Description

      Encoding Format

      The encoding format of the output video.

      Bitrate Control

      1. The bitrate of the output video. Select a bitrate control mode from the drop-down list. Valid values: Bitrate of Input Video, Fixed Bitrate, Average Bitrate, and CRF.

      Note

      Bitrate control determines the bitrate of the output video.

      • Bitrate of Input Video: The bitrate of the output video is the same as that of the input video.

      • Fixed Bitrate: The bitrate of the output video is fixed regardless of whether a scene is complex or simple. If you select Fixed Bitrate, the size of the output video is large.

      • Average Bitrate: The average bitrate of the output video is fixed. The bitrate of each scene varies based on the complexity of the scene. More bits are allocated to complex scenes and fewer bits are allocated to simple scenes. This ensures that the bitrate of the output video is within the expected range and that bits are appropriately allocated.

      • CRF: The bitrate of the output video varies based on the quality of the output video. You can specify an integer in the range of 0 to 51 to control the quality of the output video. A value of 0 specifies a lossless output. A value of 51 specifies an output of the worst quality possible. The constant rate factor (CRF) ensures that the quality of the output video is stable. However, the bitrate of the output video varies based on the complexity of the scene and is unpredictable.

      1. Configure the parameters related to the bitrate.

      Peak Bitrate

      Optional. The peak bitrate of the output video. Valid values: 10 to 50000. Unit: Kbit/s.

      Bitrate Check

      Optional. The transcoding method that is used if the bitrate of the input video is lower than the specified bitrate.

      Valid values: Transcode Based on Bitrate of Input Video, Transcode Based on Specific Bitrate, and Do Not Transcode.

      Resolution

      1. The resolution of the output video. Valid values: Resolution of Input Video, Set by Long and Short Sides, and Set by Width and Height.

      2. If you select Set by Long and Short Sides, specify the long side and short side of the output video. If you select Set by Width and Height, specify the width and height of the output video. You must enter even integers. Valid values: 128 to 4096. Unit: pixel.

      Resolution Check

      Optional. The transcoding method that is used if the resolution of the input video is lower than the specified resolution.

      Valid values: Transcode Based on Resolution of Input Video, Transcode Based on Specific Resolution, and Do Not Transcode.

      Frame Rate

      The frame rate of the output video. Valid values: Frame Rate of Input Video and Custom Frame Rate. Default value: Frame Rate of Input Video.

      If you select Custom Frame Rate, enter a value in the field. Valid values: (0,60]. Unit: frames per second. Commonly used values: 23.976, 24, 25, and 30.

      Note

      If the frame rate of the input video exceeds 60 frames per second, a value of 60 is used.

      Segment Duration

      Optional. The segment duration of the output video. You must enter an integer. Valid values: 1 to 60. Unit: seconds. If you do not specify this parameter, the default value 10 is used.

      Note

      A segment must contain at least one keyframe. Set the segment duration to a multiple of the group of pictures (GOP) value. If the segment duration is less than the GOP value or is not a multiple of the GOP value, the GOP value is adapted during transcoding.

      Gop

      Optional. The GOP value. Valid values: Maximum Time Interval between Keyframes and Maximum Number of Frames between Keyframes.

      You must enter an integer. Valid values: 1 to 100000. Unit: seconds. In streaming media scenarios, we recommend that you set this parameter to an integer within the range from 2 to 7.

      Note

      A greater GOP value indicates a higher compression ratio, a lower encoding speed, a longer duration of a single segment of streaming media, and a longer response time to seeking.

      Encoding Profile

      Optional. The devices on which the output video is played. Valid values: For High-Resolution Devices, For Standard-Resolution Devices, and For Mobile Devices. This parameter is displayed only if you set the Encoding Format parameter to H.264.

      If you want to play the output video in multiple definitions, we recommend that you select For Mobile Devices to ensure normal playback on low-end devices. In other scenarios, select For High-Resolution Devices or For Standard-Resolution Devices.

      Buffer

      Optional. The buffer size for bitrate control. Valid values: 1000 to 128000. Unit: KB. Default value: 6000.

      Note

      The buffer size is used to control the bitrate fluctuation. A larger buffer size indicates a greater fluctuation in the bitrate and higher video quality.

      Scan Mode

      Optional. The scan mode of the output video. Valid values: Scan Mode of Input Video, Automatic Deinterlacing, Interlaced Scan, and Sequential Scan. Default value: Scan Mode of Input Video.

      Color Format

      Optional. The color format of the output video. Default value: Format of Input Video.

    3. Audio Parameters

      Parameter

      Description

      Disable Audio Parameters

      Optional. Specifies whether to disable audio parameters. If you turn on this switch, you cannot configure audio parameters.

      This way, the output file does not contain audio streams or relevant media information. You can turn on this switch if you want to extract only videos.

      Encoding Format

      The encoding format of the output audio. Default value: AAC.

      Note

      If you set the Encapsulation Format parameter to HLS and set the Encoding Format parameter in the Video Parameters section to H.264, you must select AAC for the Encoding Format parameter in the Audio Parameters section. Otherwise, the input file can be transcoded but the output file cannot be played.

      Encoding Profile

      The encoding profile of the output audio. This parameter is displayed only if you set the Encoding Format parameter to AAC.

      • If the input audio uses the surround sound format such as 5.1 or 7.1, we recommend that you set this parameter to aac_low.

      • If you want to play the output audio on general playback devices, we recommend that you set this parameter to aac_he. This reduces the bitrate by half compared with the bitrate that is used when this parameter is set to aac_low. A commonly used low bitrate is 64 Kbit/s.

      • If you want to play the output audio on high-end playback devices, we recommend that you set this parameter to aac_he_v2. This way, audio files are encoded in smaller sizes and with higher sound quality. Commonly used low bitrates range from 32 Kbit/s to 48 Kbit/s.

      Sampling Rate

      The sample rate of the output audio. Unit: Hz. Default value: 44100.

      The supported sample rates of audio vary based on the encoding format or container format. For more information, see Audio sample rates.

      Audio Bitrate

      The bitrate of the output audio. Valid values: Bitrate of Input Audio and Average Bitrate.

      If you select Average Bitrate, enter an integer in the field. Valid values: 8 to 1000. Unit: Kbit/s. Default value: 128. Commonly used values: 64, 128, and 256.

      Audio Channels

      The number of sound channels. You can select Audio Channels of Input Audio. Default value: 2.

      Volume Normalization

      Specifies whether to enable volume normalization. If you enable this feature, the volumes of output files generated by the transcoding template tend to be the same. This resolves the issue of unstable volume due to the volume differences of input files. This parameter takes effect if only one output audio stream is configured. This parameter does not take effect if multiple output audio streams are configured.

  6. Click Submit.

Use MPS SDKs

SDK

References

SDK for Java

Manage transcoding templates

SDK for Go

Manage transcoding templates

Use the API

For more information, see AddTemplate.

What to do next