-2

I am running a server application that accepts video uploads from an iOS app. The app uploads a .mov to the server and the server converts it to .mp4 (this is for future Android compatibility). The problem is that the .mov format uses a rotation flag in the metadata that doesn't work very well with the conversion and videos frequently end up in the wrong orientation. The command I'm using,

avconv -i iosvideo.mov -c:v libx264 -b:v 1250k -vf scale=trunc(oh*a/2)*2:480,transpose=1 -metadata:s:v:0 rotate=0 -t 20 -c:a libvo_aacenc -b:a 192k output.mp4

seems to only rotate a fixed amount. How would I go about having avconv read the rotation flag from the .mov and rotate the video stream accordingly?

optlink
  • 55
  • 1
  • 3
  • I think you probably want to think of it as a two-step thing, first find some way to read the rotation metadata (using e.g. ffprobe or exiftool or so), then use that to set the correct rotate/transpose/vflip/hflip parameters in your ffmpeg commandline. – Ronald S. Bultje Jul 26 '15 at 02:52

1 Answers1

1

Download or compile a recent build of ffmpeg. It will automatically rotate your video, so your command could look like:

ffmpeg -i input.mov -c:v libx264 -vf scale=-2:480 -t 20 -c:a libvo_aacenc -b:a 192k \
-movflags +faststart output.mp4
  • Disable this behavior with -noautorotate.
  • For scale, you can use -2 instead of trunc(oh*a/2)*2.
  • Use -crf instead of -b:v. If you must target a specific output file size, then use -b:v, but with two passes; not one. Default is -crf 23.
  • libvo_aacenc is a poor encoder. Consider using an alternative AAC encoder if possible.
  • You will probably want -movflags +faststart so the video may begin playing back before it is completely downloaded by the client.
  • I'm not sure if any of this info will apply to avconv; I don't use that.
  • Next time ask at Super User; your question is offtopic here since it is not programming related. Stack Overflow is not a general computing help resource.
llogan
  • 121,796
  • 28
  • 232
  • 243