Skip to content

Rotate Video

Did you take a video on your Iphone and when you viewed the .mov file it is flipped 90 degrees.  This happens often and there is many ways to fix it.  Just viewing with quicktime or VLC could work but VLC the aspect was way off.  So I had myself swinging a golf club and looking like I am 3 feet tall.  Windows Movie Maker can flip the video 90 degrees but then I have to export in different format.  Not too mention I had 20 videos and it is very cumbersome to do.

Instead a quick Linux command line can do all 20 videos quickly.

Using avconv (ffmpeg successor):

# apt-get install libav-tools
# avconv -filters 2>/dev/null | grep transpose
transpose        Transpose input video.

# apt-get install libavcodec-extra-53
# avconv -codecs | grep 264
avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
built on Nov  6 2012 16:51:11 with gcc 4.7.2
D V D  h264            H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
D V D  h264_vdpau      H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)
EV    libx264         libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10

# avconv -i 838.MOV -vf transpose=1 -c:v libx264 -crf 23 -c:a copy 838.m4v

Or use mencoder (quality might be worse):

# apt-get install mencoder

# mencoder 827.MOV -vf rotate=1 -oac pcm -ovc x264 -o 827.MP4

The rotate / transpose settings:
** rotate 1 =  90 degrees clockwise


Is there a good way to tell the video is flipped without looking at it.  Probably looking at the width and height dimensions (1280x720) but I have not looked into it further.

# avconv -i 838.MOV 2>&1 | grep Video:
Stream #0.0(und): Video: h264 (Baseline), yuv420p, 1280x720, 10722 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc

# avconv -i 838.m4v 2>&1 | grep Video:
Stream #0.0(und): Video: h264 (Main), yuv420p, 720x1280, 1184 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc

Published inLinuxVideo Encoding