9

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.

Aravind
  • 550
  • 7
  • 17

6 Answers6

10

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.

Naveen S
  • 141
  • 1
  • 2
8

AWS Elemental Media Convert has now added support for rotation.

Aravind
  • 550
  • 7
  • 17
4

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.

Mike S.
  • 185
  • 2
  • 9
  • Thanks for your answer Mike. I decided to go back to Elastic Transcode. But I still wonder why it is auto-rotating the video? Does it have something to do with the resolution? The mp4 captured on the mobile is correctly oriented but after the transcode it is rotated by 90 degrees. – Aravind Aug 09 '18 at 16:04
  • Aravind, Which platform is not provided the correctly oriented video? I'd expect ElasticTranscoder to do this because they support auto-rotate. – Mike S. Aug 10 '18 at 19:18
  • I've added some additional detail to my post about where the Rotation information is stored. – Mike S. Aug 10 '18 at 19:28
1

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.

doug
  • 11
  • 1
  • Thanks for the reply @doug. Could you please share more information on how you're reading "rotation according to iOS"? Are you reading the meta-data of the video? – Aravind Aug 10 '18 at 11:35
0

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
smp
  • 985
  • 5
  • 10
0

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.

Ravi Singh
  • 1,049
  • 1
  • 10
  • 25