Dion Moult Seriously who ever reads this description.

Tech Tip #5: Rotate a video by 90 degrees with mencoder

I was recently doing some video editing work where the workflow was something like this: film in portrait, transfer to computer, rotate videos by 90 degrees, sequence together several videos, strip out background noise from entire video. Filming was done with a camera, sequencing was done by Kdenlive (I’ve previously only had experience with Blender’s VSE and I must say I was very happy with this new application), and the noise-stripping was done with Audacity. I must say I’m surprised at how fast this was all accomplished and kudos to all those developers who created these apps.

However one thing I didn’t know how to do was how to rotate the video by 90 degrees. Kdenlive can do it but it ends up being awkwardly stretched and I couldn’t figure out how to unstretch it. Luckily mencoder, which comes with the mplayer package, has got a few tricks up its sleeve.

More for my own records than for anybody else, here’s the command I used:

mencoder -vf rotate=2 -o output.avi -oac pcm -ovc lavc input.mov

As my input file was a .mov some of the sound wasn’t synchronised well after rotating, which was easily fixed by this option `-demuxer mov`. If you want to rotate clockwise instead of anticlockwise change `rotate=2` to `rotate=1`.

No related posts.


4 Comments

lefty.crupps says: (9 April 2010)

Great little tip, I have videos that have been shot sideways and its always frustrating when I realize that is the case. I’ll have to note this page for later! Thanks.

Yeah, KDEnlive is a nifty app eh? Its come a long way over the years. I remember its pre-0.5 days, it was almost unusable…. now at 0.7.1 or something, it is doing quite well.

Dion Moult says: (10 April 2010)

Cheers, yeah I’ve also heard that KDEnlive has really improved. I did stumble upon a showstopper bug though, it turns out that <0.7.7 when compiled against Qt 4.6 doesn’t work at all.

For those interested, here is the command I used to strip audio from the file (should be codec independent I think):
mplayer input.avi -vo null -ao pcm:file=audio.wav:fast

… and then after noise removing in Audacity and exporting as an mp3, you can replace the original audio track of the avi with your improved mp3 with this command:
ffmpeg -i input.avi -i audio.mp3 -map 0.0:1 -map 1:0 -f avi -vcodec copy -acodec copy output.avi

Wonderful stuff, all this ffmpeg, mplayer and mencoder. ‘Cept I can never really be bothered to RTFM for all these options.

Fitzcarraldo says: (20 September 2010)

Just wanted to say a belated “thanks” for your really useful Tech Tip #5. I’d been looking for a way to do this in Linux for a long time.

Michael says: (30 March 2012)

AWESOME THANK YOU! After trying to figure out how to do this with KDEnlive for who knows how long, this simple terminal command did the trick nicely!

Leave a Comment