AWS elemental media convert auto rotating video?

3.5k Views Asked by At

I'm converting an mp4 video to HLS using AWS elemental media convert. Everything works well but the output video is rotated by 90 degrees. Is there a setting that I can use to stop this from happening. I'm shooting the video on an iPhone.

6

There are 6 best solutions below

0
On BEST ANSWER

AWS Elemental Media Convert has now added support for rotation.

3
On

Per an AWS blog post (https://aws.amazon.com/blogs/media/how-to-migrate-workflows-from-amazon-elastic-transcoder-to-aws-elemental-mediaconvert/), auto-rotation is not supported.

I can't find an option for a Manual Rotation either, but that may exist without my knowledge.

Why should you stay on Amazon Elastic Transcoder?

For the small set of features listed below, you still need to use Amazon Elastic Transcoder.

These features are:

  • WebM (VP8/VP9) input and output
  • Animated GIF output
  • MP4 auto-rotation flag support
  • MP3, FLAC, Vorbis, and WAV audio-only output
  • Encryption support using KMS integration

Where is the Rotation Information?

Video files have embedded metadata in them that can be extracted. I've used MediaInfo (https://mediaarea.net/en/MediaInfo), ffprobe I think does the same thing as well (https://ffmpeg.org/ffprobe.html).

The file metadata has plenty of information, one of which is the "Rotation" details. ("Rotation": "90.000",). I assume ElasticTranscoder automatically utilizes this to put your file in the right orientation.

I'd like to see MediaConvert, at the very least, have this option as an input parameter. That way we could pass it in to the job call. It requires the step of pulling this metadata, but at least the option would be there.

1
On

AWS is using metadata in your video file to determine camera rotation. The transcoders then automatically use this information to "right" the video during transcoding. The easiest method we've found to counter this non-intuitive process is to feed elastic transcoder the rotation information - if the rotation according to iOS for example is 270 degrees, feed the transcoder 270 as the rotation - your resulting video will be correct.

0
On

Under Inputs->Video Selector, You will find an option called Rotate (clockwise)(InputRotate) to specify how to rotate your video. You can choose automatic rotation or specify a rotation. You can specify a clockwise rotation of 0, 90, 180, or 270 degrees.

If your input video container is .mov or .mp4 and your input has rotation metadata, you can choose Automatic to have the service rotate your video according to the rotation specified in the metadata. The rotation must be within one degree of 90, 180, or 270 degrees. If the rotation metadata specifies any other rotation, the service will default to no rotation. Use Rotate (InputRotate) to specify how the service rotates your video. You can choose automatic rotation or specify a rotation. You can specify a clockwise rotation of 0, 90, 180, or 270 degrees.

By default, media convert does no rotation, even if your input video has rotation metadata. The service doesn't pass through rotation metadata.

0
On

Though MediaConvert doesn't support auto-rotation today, you can still process the content in MediaConvert and then add the rotation metadata to the resulting file.

If you'd like to add the rotation information back into a MediaConvert output, try using ffmpeg or exiftool to do so. Here's a few example commands:

ffmpeg -i EMC_OUTPUT.MOV -metadata:s:v rotate="-90" -c copy rotated.mov

Or

exiftool "-Rotation=90” rotated.mov
0
On

I also face the same issue. After a lot of time, we noticed that ios set a Rotation meta key in the video itself. As its not always 90. it varies from which camera it's recorded with (front/back) maybe

So to check the rotation value in the video meta you can use mediainfo.js

By using the library. you can fetch the video information and pass the same rotation value to AWS media convert / elastic transcoder JSON whatever service you are using. By doing this it solves the problem for me.