All Products
Search
Document Center

:Transcoding templates

Last Updated:Jun 20, 2023

This topic describes how to create a custom transcoding template and configure relevant parameters in the ApsaraVideo Media Processing (MPS) console.

Background information

MPS provides preset templates for transcoding. If the preset templates do not meet your business requirements, you can create a custom template in the MPS console or by calling the AddTemplate operation. You can use a custom transcoding template when you create a transcoding job or create a workflow. For more information about preset templates, see Preset template details.

Note

If the custom template that you create still cannot meet your business requirements, you can configure the parameters related to the output file when you call the SubmitJobs operation to submit a job. For more information, see the "Output" section in Output.

Limits

You can create up to 10 custom transcoding templates in a region within an Alibaba Cloud account. To create more custom transcoding templates, submit a ticket to contact Alibaba Cloud custom service.

Procedure

  1. Log on to the MPS console.

  2. In the top navigation bar, select a region. region

  3. In the left-side navigation pane, choose Template Management > Encoding Templates. The Encoding Template page appears.

  4. Click Create Transcoding Template.

  5. Configure the parameters in the Basic Parameters section. The following table describes the parameters.

    Parameter

    Description

    Template Name

    Enter the name of the transcoding template.

    Encapsulation Format

    Select a container format from the drop-down list. Default value: mp4.

    Note

    If you set the Encapsulation Format parameter to m3u8, you need to configure the Segment Length parameter in the Video Parameters section. For more information, see the next step in this topic.

  6. Configure the parameters in the Video Parameters section. If you select Disable Video, you do not need to configure other parameters in this section.

    Note

    If you select Disable Video, an output file does not include the video stream or the corresponding video information. This option is applicable if you want to extract the audio stream from a video file. If the input file is a high dynamic range (HDR) video, enable the HDR2SDR conversion feature. This helps prevent overexposure or underexposure in the output video when the output video is played on devices that do not support HDR. To enable the HDR2SDR conversion feature, submit a ticket to contact Alibaba Cloud customer service.

    Parameter

    Description

    Encoding Format

    Select an encoding format from the drop-down list. Default value: H.264.

    Encoding Level

    Select an encoding profile from the drop-down list. Default value: For High-Resolution Devices. For more information, see the "Codec" section in Terms.

    Note

    iOS devices provide poor compatibility with the For High-Resolution Devices encoding profile. If you want to play the output video on iOS devices, we recommend that you select For Standard-Resolution Devices.

    Bitrate

    Optional. Enter a bitrate. Unit: Kbit/s. Valid values: 10 to 50000. If you do not configure the parameter, the output video has the same bitrate as the input video.

    Constant Rate Factor (CRF)

    Optional. Valid values: 0 to 51. Default value when the Encoding Format parameter is set to H.264: 23. Default value when the Encoding Format parameter is set to H.265: 26.

    Note

    If you configure the parameter, the setting of the Bitrate parameter does not take effect. The higher the value of this parameter, the lower the compression ratio, and the lower the quality of the output video. Recommended values: 23 to 29.

    Video Width (px)

    Optional. Unit: pixel. Valid values: 128 to 4096. If you do not configure the parameter, the output video has the same width as the input video.

    Video Height (px)

    Optional. Unit: pixel. Valid values: 128 to 4096. If you do not configure the parameter, the output video has the same height as the input video.

    Auto-Rotate Screen

    Optional. Specify whether to automatically rotate the output video.

    Note

    If you need to transcode both videos in landscape mode and videos in portrait mode, we recommend that you turn on Auto-Rotate Screen. For more information about resolution settings, see How do I set the resolution for an output video?.

    Frame Rate (fps)

    Optional. Unit: frames per second. Valid values: 0 to 60, excluding 0. If you do not configure the parameter, the output video has the same frame rate as the input video except when the frame rate of the input video exceeds 60. In that case, the frame rate of the output video is set to 60.

    Maximum Frames between Keyframes

    • Optional. Enter the maximum number of frames between two consecutive keyframes. Valid values: 1 to 100000.

    • If you do not configure the parameter, a keyframe is specified in the output video every 10 seconds.

    Scan Mode

    Optional. Select a scan mode from the drop-down list. Valid values: interlaced and progressive. If you do not configure the parameter, the output video adopts the same scan mode as the input video.

    Buffer Size

    Optional. Unit: KB. Valid values: 1000 to 128000. Default value: 6000.

    Note

    The larger the buffer size, the higher the quality of the output video, and the greater the variation in the bitrate.

    Peak Bitrate

    Optional. Unit: Kbit/s. Valid values: 10 to 50000.

    Segment Length

    Optional. This parameter is available only if the Encapsulation Format parameter is set to m3u8. Unit: seconds. Valid values: 1 to 60. Default value: 10. If you do not configure the parameter, the default value is used.

  7. Click Next to configure the audio parameters. If you select Disable Audio, you do not need to configure other parameters in this section.

    Note

    If you select Disable Audio, an output file does not include the audio stream or the corresponding audio information. This option is applicable if you want to extract the video stream from a video file. For more information about the audio parameters involved in video transcoding, see Parameter details.

    Parameter

    Description

    Encoding Format

    Select an encoding format from the drop-down list. Default value: AAC.

    Note
    • If you set the Encoding Format parameter to MP3, you cannot set the Sampling Rate parameter to 96000.

    • If you set the Encapsulation Format parameter to mp3, you must set this parameter to MP3. Otherwise, a transcoding job that uses this template fails.

    Sampling rate

    Select a sampling rate from the drop-down list. Unit: Hz. Default value: 44100.

    Note
    • If you set the audio codec to MP3, you cannot set this parameter to 96000.

    • If you set the Encapsulation Format parameter to flv and the audio codec to MP3, you cannot set this parameter to 32000, 48000, or 96000.

    Output Bitrate

    Unit: Kbit/s. Valid values: 8 to 1000. Default value: 128.

    Audio Channels

    Select the number of audio channels that the output video has from the drop-down list. Default value: 2.

    Note
    • If you set the audio codec to MP3, you can set this parameter only to 1 or 2.

    • If you set the audio codec to AAC, you can set this parameter only to 1, 2, 4, 5, 6, or 8.

  8. Click Next to configure the advanced parameters.

  9. Configure the parameters in the Advanced Parameters step. The following table describes the parameters.

    Parameter

    Description

    Video Resolution Detection

    Optional. To enable this feature, turn on Video Resolution Detection.

    Set the Original Audio Bitrate Lower Than Template Setting parameter to Encode with Original Video or Do Not Encode.

    Video Bitrate Detection

    Optional. To enable this feature, turn on Video Bitrate Detection.

    Set the Original Video Bitrate Lower Than Template Setting parameter to Encode with Original Video or Do Not Encode.

    Audio Bitrate Detection

    Optional. To enable this feature, turn on Audio Bitrate Detection.

    Set the Original Audio Bitrate Lower Than Template Setting parameter to Encode with Original Video or Do Not Encode.

  10. Click Submit.

What to do next

  • You can view the created template on the Encoding Template page. If you need to modify or delete the template, click Edit or Delete in the Actions column.

  • You can use the custom transcoding template when you create a transcoding job or a workflow. For more information, see Create a transcoding job and Create a workflow.

Related API operation

AddTemplate