aws-samples / aws-media-services-vod-automation

Sample code and CloudFormation scripts for automating Video on Demand workflows on AWS
Apache License 2.0
136 stars 112 forks source link

Video Rotation #23

Open stevebanik opened 4 years ago

stevebanik commented 4 years ago

Is automatic video rotation a setting that's controlled in job.json?

https://docs.aws.amazon.com/mediaconvert/latest/ug/auto-rotate.html

aburkleaux-amazon commented 4 years ago

Yes, the video rotation setting is part of the VideoSelector attribute on Inputs block of the MediaConvert job settigs JSON.

...
"Inputs": [
      {
        "AudioSelectors": {
          "Audio Selector 1": {
            "Offset": 0,
            "DefaultSelection": "DEFAULT",
            "ProgramSelection": 1
          }
        },
        "VideoSelector": {
          "ColorSpace": "FOLLOW",
          "Rotate": "AUTO"
        },
...

An easy way to figure out MediaConvert API job setting options is to use the console to configure and test your job, then use the Show job JSON option on the job setting menu to show the JSON that will be passed in to the MediConvert API.

This is a screen shot from the MediaConvert -> Create job -> Inputs form in the AWS console.

image

stevebanik commented 4 years ago

Thanks for your help. I have this block in the .json:

"VideoSelector": { "ColorSpace": "FOLLOW", "Rotate": "AUTO" },

but videos recorded on iPad do not rotate properly.

My understanding is that a newer AWS SDK is required for auto-rotation, and I have added the AWSLambda-Python-AWS-SDK layer to my function, but videos still aren't auto-rotating properly (the playback video is upside down.) The input video is .webm which is a format not specified here. Perhaps that is the issue?

If .webm should work, do I instead need to source the layer in the function code, or perhaps adjust the function code differently to get it to observe the auto-rotation feature? How can I confirm the function code is using the layer?

Thanks in advance.

aburkleaux-amazon commented 4 years ago

Auto rotation only works for .mov or .mp4 inputs. For other input formats (including .webm) you need to specify a specific degree of rotation in the InputRotate property:

DEGREE_0
DEGREES_90
DEGREES_180
DEGREES_270

Regarding the SDK versons: the lambda function in this tutorial is using the version of boto3 that is supplied by the default lambda environment. This gets updated frequently, but is not always the latest version. To check what version of a package you are running in a Python lambda, just add this code to print the package version:

print(boto3.__version__)

I tested this lambda today with an upside-down video (.mov) using inputRotate set to AUTO and DEGREES_180.

The boto version was 1.12.49 Both AUTO and DEGREES_180 worked as expected for my input

Another way to verify the job you ran had the rotation set as you expectedis to check the MediaConvert console Job details page for the job.

image

stevebanik commented 4 years ago

It seems there have been some changes to MediaConvert recently. Is .webm autorotate now supported?