Thursday, January 19, 2012

How to rotate videos on ubuntu!

Using mencoder:

  • To rotate by 90 degree clockwise
    • mencoder -vf rotate=1 -o output.mp4 -oac pcm -ovc lavc -fps 30 -ofps 30 input.mp4
      • It is important to specify both input and output frame rate (with fps, ofps), else you will get the  error.
  • To flip horizontally
    • mencoder -vf flip -o output.mp4 -oac pcm -ovc lavc -fps 30 -ofps 30  input.mp
Using ffmpeg
  • To rotate the video by 90 degrees, we can use the following command
    • ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
      • "transpose=1" => 90 degree clockwise
      • "transpose=2" => 90 degree anti-clockwise
    • You may get the following error while running the command-"No such filter: 'transpose'". In this case, you should you need to install Libavfilter.
  • To vertically flip the video 
    • ffmpeg -i input.mp4 -vf  vflip output.mp4
  • To horizontally flip the video
    • ffmpeg -i input.mp4 -vf  hflip output.mp4

2 comments: