Search code examples
amazon-web-servicesaws-lambdaaws-media-convert

AWS MediaConvert Rotate Aspect Ratio Changed


I am using the VOD (video on demand) template in AWS for media conversion. It creates a Lambda function that in turn pushes a Job into AWS MediaConvert. Recently, AWS added support for a Rotate property, which when set to AUTO reads the meta data from the source file and applies the appropriate rotation to the video during conversion. It is rotating the video, however, it appears to shrink the video in the process. See below.

video rotation example

You can see that rather than the overall video being rotated, it rotates it to fit inside a wide aspect ratio container. The source file is a .mov from an iPhone.

Looking for help on how to get MediaConvert to rotate the full video rather than trying to rotate it, and then shrink to fit inside the original source video dimensions.


Solution

  • As it turns out, @Kumar Swaminathan's answer was mostly correct. The Video on Demand template from AWS does not include a MediaConvert template for portrait resolutions, and the steps leading up to conversion do not handle rotation at all. The right way to solve the problems appears to be to:

    1. Update the media-encode step to use the latest AWS SDK (by using layers), and pass the Rotate flag as AUTO through to MediaConvert when creating the conversion ("Rotate": "AUTO")
    2. Add MediaConvert profiles for portrait resolutions
    3. Enhance the media-profiler step to look for the rotate mediainfo property, and choose one of the new portrait profiles for encoding

    Update

    I implemented support for portrait videos and submitted a PR to AWS. https://github.com/awslabs/video-on-demand-on-aws/pull/29