A while ago, after flickr launched the ability to upload “long photos”, I shot a clip of waves crashing on the beach, and wanted to share it. But there was a catch: being taken on a compact camera, it felt perfectly natural to turn it upright, and shoot the video in a “portrait” orientation. So, like a lot of my photos, it needed turning 90° clockwise – but unlike a photo, there was no obvious way to do this.
I hunted around at the time, and found that while plenty of players can transform video during playback (my copy of VLC seems to have got stuck, and now rotates everything!), few video editing tools could save a rotated video. I finally managed it with a power-utility which required me to import the video, tweak a large number of output options I didn’t understand, and hope the result wasn’t too mangled. Hardly ideal.
But while reading up on it, I discovered that most digital cameras – including my Casio Ezilim EX-Z1050 – shoot videos in a format called “Motion JPEG” or “MJPEG”, which is basically a bunch of JPEG pictures stuck together. So if I could extract the images from the video, they should be easy to rotate, and all I’d need to do was stick them together again…
Well, yesterday I was playing with lossless image rotation using jpegtran, and then managed to find MJPEG tools – a bunch of commandline tools for manipulating MJPEG data, actually designed for video capture utilities. And guess what? It works! I can split the AVI file from my camera into a bunch of JPEGs, rotate them, and stitch them back together, with minimal loss of quality!
Oddly, the biggest sticking point was sound – the mjpegtools utilities can’t see the sound stream in my source files. In fact, the only utility I could was FFmpeg, which at over 10 times the size of all the other tools put together is like the proverbial sledgehammer to the sound streams nut.
So, with my meagre Windows batch-scripting skills, I’ve put together something which might, just about, be useful, and called it VidRotate. Go forth, download! But beware – I make absolutely no guarantee that it won’t blow your computer up at this stage…