3

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.

a432511
  • 1,907
  • 4
  • 26
  • 48

3 Answers3

3

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

a432511
  • 1,907
  • 4
  • 26
  • 48
1

If you have a 1920x1080 video with a metadata of 90 degrees and you are using a job that specifies an output resolution of 1920x1080, then this results in the video being rotated first to a 1080x1920 video which is then pillar-boxed + scaled to form an output resolution of 1920x1080. This will look rotated, pillar-boxed, and somewhat shrunk in the vertical dimension - just like this picture.

In order to prevent this, it is best to leave the width and height of the output unspecified so that it follows the dimensions of the rotated source.

1

I don't have the reputation to comment to your answer but I found your code modifications to handle portrait videos super useful. Surprisingly, even the most recent version of their code in the main repo does not handle portrait videos well, and your PR should have been accepted. I forked your code and made a few more changes, which includes:

  • lambda node version upgrade to 12.x
  • handling silent videos
  • passing on the rotate meta flag of the video to MediaConvert

Working well for me with all video formats! Link to my forked github repo

Rajath Kedilaya
  • 731
  • 5
  • 4