When you create a video transcoding task, how do you set the resolution parameter to achieve the desired effect? This document describes the configuration methods for setting transcoding parameters and provides combinations of parameters for common scenarios, enabling users to efficiently use the video transcoding functionality as needed.
Resolution-related Parameters
When you create a transcoding task, the parameters related to resolution are as follows:
Long Short Mode: Video.LongShortMode (using the longer side of the input video as width and the shorter side as height). Resolution Adjustment Mode: TransConfig.AdjDarMethod (includes maintaining source video aspect ratio, scaling, cropping and scaling, and filling black edges as options).
Steps of Configuring Parameters
You can refer to the following steps when configuring parameters:
Step One: Establishing the Width and Height of Resolution
Specific parameters for the resolution width and height are detailed as follows:
Parameter | Description |
Width: Video.Width
Height: Video.Height | When both width and height are empty, the resolution of the source video is adopted. If you do not want to change the original video resolution, use this setting. If one side is empty, the other side is proportionally scaled according to the source video resolution. If the dimensions of the input videos vary and you do not want to change the original aspect ratio, use this setting. When both width and height are not empty, transcoding is performed according to the specified width and height. If you need to constrain the video to a fixed width and height, use this setting. |
The template parameter settings are as follows:
If you do not want to change the video resolution, you do not need to input the width and height.
If you want to set the width/height, the setup is as follows:
Step Two: Whether to Enable Long Short Mode (Optional)
Note:
Step two is optional: If both the width and height of the specified resolution are empty (using the resolution of the source video), this step is not required.
If there may be vertical videos in the input video, you need to enable the long short mode. The following details the long short mode parameter:
Parameter | Description |
Video.LongShortMode | If it is enabled, the length of the corresponding input video will be automatically identified as the width, and the shorter side as the height. |
The template parameter settings are as follows:
If there may be vertical videos in the input video (vertical videos are clips where the height is greater than the width), you need to enable Long Short Mode. The setup is as follows:
Note:
1. A video displayed in the vertical direction does not indicate that the content is vertically formatted. It may be a horizontal video centrally displayed on the screen, with black edges filling the top and bottom by the player, implying that the core video remains in vertical mode.
2. A video displayed in vertical mode may have horizontal content, with a rotational angle of 90 added to the video information to display it vertically.
Step Three: Checking Whether the Source Resolution Is Lower than the Target Resolution (Optional)
Note:
Step three is optional: If the width and height of the specified resolution are both empty (applying the source video resolution), you do not need to perform this step.
If the resolutions of the input video vary, and you only want to reduce the resolution of high-resolution videos during transcoding, without increasing the resolution of low-resolution videos, it is recommended that you activate the detection feature. The following details the detection parameters:
Parameter | Description |
TransConfig.IsCheckReso | By default, it is disabled, indicating: The relationship between the source resolution and target resolution is not detected. If it is enabled, when a source video resolution is detected to be lower than the set resolution, ResoAdjMethod can be used to specify the processing method. The specific logic for resolution comparisons is as follows: If only the width is set, whether the width of the source video is smaller than the set width is checked. If only the height is set, whether the height of the source video is smaller than the set height is checked. If both width and height are set, whether the width and height of the source video are smaller than the set width and height are checked, respectively. |
TransConfig.ResoAdjMethod | If IsCheckReso is enabled, the following two processing methods are supported: Use source video resolution (default): The set resolution becomes ineffective, and the transcoding is performed according to the source video resolution. Return failure: The transcoding process is stopped. |
The template parameter settings are as follows:
When the source video resolution is detected to be lower than the target resolution, you can choose either to Use source video resolution or Return failure, to avoid stretching low-resolution videos. The setup of video resolution is as follows:
Step Four: Setting the Resolution Adjustment Mode (Optional)
Note:
Step four is optional: This step is only required when both the width and height of the specified resolution are not empty (transcoding according to the specified width and height).
When both width and height are set, it is recommended that you use resolution adjustment parameters to specify the adjustment method if the aspect ratio of the source video is different from the specified one. The following details the parameters of resolution adjustment method:
Parameter | Description |
TransConfig.AdjDarMethod | The default value is Source Video Aspect Ratio: Scaling is performed according to the aspect ratio of the source video. If the aspect ratio of the source video does not match the set resolution aspect ratio, sample_aspect_ratio (SAR) is kept the same with the source video, and display_aspect_ratio (DAR) is kept the same with the resolution set by the parameter. The API is none. Scaling: The video is forcibly stretched according to set width and height. The API is scale. Cropping and scaling: The video is scaled according to the aspect ratio of the source video, with the excess area cropped. The API is crop. Filing black edges: The video scaled according to the aspect ratio of the source video, with the inconsistent aspect ratio area filled with black edges. The API is pad. |
The template parameter settings are as follows:
The resolution adjustment methods include maintaining source video aspect ratio, scaling, cropping and scaling, and filling black edges, and their effects are as follows:
Note:
By default, the setting of AdjDarMethod is to maintain the source video aspect ratio, where the SAR is set to be consistent with the source video aspect ratio (if the source video SAR is valid), but the actual width and height of the video are the same as the set width and height.
When a player is used to play the output video, if the player supports parsing SAR, the playback image aspect ratio has the same aspect ratio as the source video; if the player cannot parse SAR, the playback image has the same aspect ratio as the specified aspect ratio, which may cause image distortion.
When you check the output video resolution, the width and height are the same as those of the specified resolution.
Common Scenarios
Scenario One: All Videos Are Transcoded to 720p
Specific scenario: The aspect ratio of the input video varies and there are both horizontal and vertical videos, and you want to transcode all videos to 720p without extra processing for the input short videos.
Recommended settings: Set the resolution width to empty, and height to 720px, and enable the long short mode and video resolution detection. Enable Return failure to be displayed if the source resolution is lower than the set resolution.
Scenario Two: Forcibly Setting the Video Resolution to 1280×720
Specific scenario: You need to transcode all videos to a consistent resolution in order to add visual effects, and the content in the images cannot be lost. In addition, the videos must be compatible with all players for playback.
Recommended settings: Set the width of the resolution to 1280px, and the height to 720px, enable the long short mode, disable video resolution detection by default, and set the resolution adjustment method to filling black edges.
Was this page helpful?