All Products
Search
Document Center

ApsaraVideo Media Processing:How do I specify a resolution for an output video?

Last Updated:Jan 29, 2024

When you use ApsaraVideo Media Processing (MPS) to transcode videos, you can specify a resolution for output videos by using a transcoding template. If the images of an output video appear stretched, it is generally because the aspect ratio of the input video does not match the specified resolution. This topic describes how to specify a resolution for an output video.

Enable auto-orientation

If you transcode videos in both landscape and portrait modes, you can define the output resolution by specifying the pixel value of the longer or shorter side. This prevents the images of the output videos from being stretched.

Configuration methods

  • When you create a transcoding template in the MPS console, set the Resolution parameter to Set by Long and Short Sides. For more information, see Create a transcoding template.

  • When you call the SubmitJobs or AddTemplate operation, set the LongShortMode parameter to true.

Enable proportional scaling

If the input videos are in different aspect ratios and you want to retain the original aspect ratios after transcoding, you can enable proportional scaling.

  • When you configure a transcoding template, specify either the output width or height and leave the other dimension empty. The unspecified dimension is proportionally scaled to match the aspect ratio of each input video.

  • If you transcode videos in both landscape and portrait modes and enable proportional scaling, we recommend that you also define the output resolution by specifying the pixel value of the longer or shorter side. This prevents excessively large or small frame sizes.

    Note

    If you enable proportional scaling by specifying either the output width or height, you may be charged for a higher tier than the one that you specify. For example, if you set the output height to 720 pixels and the aspect ratio of an input video exceeds 16:9, the output resolution exceeds the 1280 × 720-pixel range. In this case, you are charged additional fees.

Configuration methods

  • When you create a transcoding template in the MPS console, specify only one of the output width and height. For more information, see Create a transcoding template.

  • When you call the SubmitJobs or AddTemplate operation, specify only one of the Width and Height parameters.

Specify an aspect ratio conversion method

If you specify both the output width and height or both the longer and shorter sides and the aspect ratio of an input video does not match the specified resolution, you can perform aspect ratio conversion. You can adjust the display aspect ratio (DAR) of the output video by stretching the images, adding black bars to the images, or cropping the images. You can also choose to retain the original DAR of the input video.

Note

The sample aspect ratio (SAR) is the width-to-height ratio of a video frame and essentially represents the resolution of a video. The DAR is the width-to-height ratio at which a video is displayed. When you play a video, it appears in the DAR. If the DAR is incorrectly set, the video images may be distorted. Generally, the DAR and SAR of a video represent the same proportional relationship between the width and height. However, in some cases, they may differ.

Configuration methods

  • When you create a transcoding template in the MPS console, specify an aspect ratio conversion method. For more information, see Create a transcoding template.

  • When you call the SubmitJobs operation, configure the AdjDarMethod parameter. For more information, see TransConfig.