This topic describes how to create a custom transcoding template and configure its parameters in the MPS console.
Background information
If the system preset templates do not meet your business needs, you can create custom templates in the console or by using an API and configure the required parameters. Use these custom templates when you create a transcoding job or create a workflow and set the Transcoding Template. For more information about preset templates, see Preset Template Details.
If a custom template still cannot meet your requirements, you can configure template parameters in the Output object when you call the SubmitJobs operation. For more information, see Output.
Limitations
By default, each Alibaba Cloud account can create up to 10 custom transcoding templates in each region. To increase this limit, submit a ticket.
Create a transcoding template
Log on to the ApsaraVideo Media Processing console, select the region in which you want to use MPS in the top navigation bar.
In the navigation pane on the left, choose , and go to the Custom Template tab.
Click Add Template.
Set parameters in the Basic Parameters, Video Parameters, and Audio Parameters sections.
Basic Parameters.
Parameter
Description
Transcoding Template Name
Enter a name for the transcoding template. The name can contain Chinese characters, letters, digits, and hyphens (-). It cannot start with a special character. The maximum length is 128 bytes.
Transcoding Type
The type of transcoding. You can create a regular transcoding template or an audio transcoding template.
NoteIf you select audio transcoding, only an audio stream is generated. This feature is suitable for scenarios where you need to extract the audio stream from a video file or transcode an audio file.
Container Format
Select a container format for the output file from the drop-down list.
Video Parameters.
NoteIf the source file is a High Dynamic Range (HDR) file and you want to convert it to a Standard Dynamic Range (SDR) file, submit a ticket to request an adaptive configuration. This helps prevent overexposure or underexposure.
Parameter
Description
Encoding Format
Select an encoding format.
Bitrate Control
Select a control mode from the drop-down list. The following modes are supported: Source Bitrate, Constant Bitrate, Average Bitrate, and CRF Quality.
NoteBitrate control is the process of determining the output bitrate during video encoding:
Source Bitrate: The output bitrate is the same as the source video bitrate.
Constant Bitrate: A single bitrate is used for the entire file, regardless of scene complexity. This mode produces larger files.
Average Bitrate: The average output bitrate is fixed. The bitrate is allocated based on scene complexity. More bits are allocated to complex scenes and fewer bits to simple scenes. This mode ensures the output bitrate is within the expected range and that bits are allocated reasonably.
CRF Quality: Video quality is quantized into different levels. 0 is lossless and 51 is the worst quality. Setting a Constant Rate Factor (CRF) value keeps the subjective video quality constant. However, the bitrate fluctuates with scene complexity, and the output bitrate is unpredictable.
Enter the related bitrate parameters.
(Optional) Peak Bitrate
Enter the peak bitrate in the text box. The value must be an integer from 10 to 50,000. The unit is Kbps.
(Optional) Bitrate Check
The action to take if the source video bitrate is lower than the specified bitrate.
The following modes are supported: Transcode at Source Bitrate, Transcode at Specified Bitrate (upsampling), and Do Not Transcode.
Resolution
Select a resolution mode from the drop-down list. The following modes are supported: Source Resolution, Set by Long and Short Sides, and Set by Width and Height.
Enter the long (width) and short (height) side lengths. The value must be an even integer from 128 to 4,096.
(Optional) Resolution Check
The action to take if the source video resolution is lower than the specified resolution.
The following modes are supported: Transcode at Source Resolution, Transcode at Specified Resolution, and Do Not Transcode.
Frame Rate
You can use the source video frame rate or a custom frame rate. The default is the source video frame rate.
If you select a custom frame rate, enter a value from (0, 60] in the text box. The unit is fps. Common values are 23.976, 24, 25, and 30.
NoteIf the source video frame rate exceeds 60 fps, it is capped at 60 fps.
(Optional) Segment Duration
Enter the segment duration in the text box. The value must be an integer from 1 to 60. The unit is seconds. If you leave this empty, the default value is 10 seconds.
NoteA segment must contain at least one keyframe. Set the segment duration to a multiple of the GOP duration. If the segment duration is less than the GOP duration or is not a multiple, the transcoding service adapts the keyframe interval.
(Optional) GOP
You can set the maximum time interval or the maximum number of frames between keyframes.
The value must be an integer from 1 to 100,000. For streaming media playback, a value between 2 and 7 seconds is recommended.
NoteA larger Group of Pictures (GOP) value results in a higher compression ratio but a lower encoding speed. It also increases the duration of a single streaming media segment and the player's seek response time.
(Optional) Encoding Profile
Supported profiles: For High-Resolution Devices, For Standard-Resolution Devices, and For Mobile Devices. This parameter is available only for H.264.
When a video has multiple definition outputs, set the lowest definition to For Mobile Devices (baseline) to ensure playback on low-end devices. Set other definitions to For Standard-Resolution Devices (main) or For High-Resolution Devices (high).
(Optional) Buffer
Enter a value in the text box. The value must be an integer from 1,000 to 128,000. The unit is KB. The default value is 6,000.
NoteThe buffer size (Bufsize) controls bitrate fluctuation. A larger Bufsize value allows for greater bitrate fluctuation and results in higher video quality.
(Optional) Scan Mode
Supported modes: Source Mode, Automatic Deinterlacing, Interlaced Scan, and Progressive Scan. The default is Source Mode.
(Optional) Color Format
Select the desired encoding format from the drop-down list. The original video format is the default.
Audio Parameters.
Parameter
Description
(Optional) Disable Audio
If you check Disable audio, you cannot set the parameters below.
The output file will not contain an audio stream or related media information. This feature is suitable for scenarios where you need to extract only the video stream from a video file.
Encoding Format
Select an audio coding format from the drop-down list. The default format is AAC.
NoteIf the container format is HLS and the video encoding format is H.264, the audio coding format must be set to AAC. Otherwise, the transcoding job may succeed, but the output file will be unplayable.
Encoding Profile
You can set the encoding profile when the encoding format is AAC.
If the audio source has 5.1, 7.1, or more channels, set the profile to `aac_low`.
For general playback devices, set the profile to `aac_he`. This can save half the audio bitrate compared to `aac_low` for the same audio quality. A common low bitrate is 64 Kbps.
For high-end playback devices, set the profile to `aac_he_v2`. This provides smaller file sizes and better audio quality. Common low bitrates range from 32 to 48 Kbps.
Sample Rate
Select a sample rate from the drop-down list. The unit is Hz. The default value is 44,100.
Different container and encoding formats support different sample rates. For more information, see Supported sample rates.
Audio Bitrate
You can retain the original video frame rate and average bitrate.
If you select average bitrate, enter an integer from 8 to 1,000 in the text box. The unit is Kbps. The default value is 128. Common values are 64, 128, and 256.
Number of Channels
Select the number of sound channels from the drop-down list. You can keep the original number of channels. The default is 2.
Volume Normalization
If you enable this feature, the volume of files processed by the template will be consistent. This prevents large volume differences between files. This can be set only when there is a single output audio stream. It is not supported for multiple audio streams.
Click Submit to create the transcoding template.
Manage transcoding templates
Query a transcoding template
Log on to the MPS console.
In the top navigation bar, select a region from the drop-down list.
In the navigation pane on the left, choose Template Management > Transcoding Templates.
Select Template Title or Template ID and enter the corresponding value to query for the template.
Modify a transcoding template
Log on to the MPS console.
In the top navigation bar, select a region from the drop-down list.
In the navigation pane on the left, choose Template Management > Transcoding Templates, and then click the Custom Templates tab.
In the Actions column, click Modify.
Copy a transcoding template
Log on to the MPS console.
In the top navigation bar, select a region from the drop-down list.
In the navigation pane on the left, choose Template Management > Transcoding Templates, and then click the Custom Templates tab.
In the Actions column, click Copy. A new template is created based on the parameters of the selected template.
If you copy a custom template, its backend custom parameters are also copied.
Delete a transcoding template
Log on to the MPS console.
In the top navigation bar, select a region from the drop-down list.
In the navigation pane on the left, choose Template Management > Transcoding Templates, and then click the Custom Templates tab.
In the Actions column, click Delete.
NoteIf you delete a transcoding template, transcoding jobs and workflows that use the ID of the deleted template will fail. Perform this operation with caution.
Next steps
When you create a transcoding job or create a workflow, select your custom transcoding template.