The first thing that might pop-up in the reader’s mind is that why would anyone ever want to rotate a video? Well this need arose when I recorded videos using iPad (which always auto rotate the screen according to the user orientation). But when I transferred those to my PC, I realized that some needed to be rotated 90 degrees and some 180 or vertically flipped.
Ubuntu always has the answers to my questions. In a previous post in which I shared the commands on how to record screencasts in Ubuntu, I mentioned about avconv tool and how to install it with codecs. The same nice tool can be used to flip and rotate videos also.
To vertically flip a video:
avconv -i input_video.mov -c:v libx264 -c:a copy -vf "vflip" output_video.mov
To horizontally flip a video:
avconv -i input_video.mov -c:v libx264 -c:a copy -vf "hflip" output_video.mov
To rotate it 90 degree clock-wise:
avconv -i input_video.mov -c:v libx264 -c:a copy -vf "transpose=1" output_video.mov
The copy parameter means to keep the same audio encoding.
For further reading visit the official documentation: http://libav.org/libavfilter.html