{"id":45,"date":"2009-09-20T21:37:25","date_gmt":"2009-09-20T20:37:25","guid":{"rendered":"https:\/\/rwec.co.uk\/blog\/?p=45"},"modified":"2010-03-01T18:29:45","modified_gmt":"2010-03-01T18:29:45","slug":"rotating-digital-camera-videos","status":"publish","type":"post","link":"https:\/\/rwec.co.uk\/blog\/2009\/09\/rotating-digital-camera-videos\/","title":{"rendered":"A script for rotating digital camera videos!"},"content":{"rendered":"<p>A while ago, after flickr launched the ability to <a href=\"http:\/\/www.flickr.com\/help\/video\/\">upload &#8220;long photos&#8221;<\/a>, 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 &#8220;portrait&#8221; orientation. So, like a lot of my photos, it needed turning 90\u00b0 clockwise &#8211; but unlike a photo, there was no obvious way to do this.<\/p>\n<p>I hunted around at the time, and found that while plenty of players can transform video <em>during playback<\/em> (my copy of <a href=\"http:\/\/www.videolan.org\/\">VLC<\/a> seems to have got stuck, and now rotates <em>everything<\/em>!), 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&#8217;t understand, and hope the result wasn&#8217;t too mangled. Hardly ideal.<\/p>\n<p>But while reading up on it, I discovered that most digital cameras &#8211; including my Casio Ezilim EX-Z1050 &#8211; shoot videos in a format called &#8220;Motion JPEG&#8221; or &#8220;MJPEG&#8221;, 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&#8217;d need to do was stick them together again&#8230;<\/p>\n<p>Well, yesterday I was playing with lossless image rotation using <a href=\"http:\/\/jpegclub.org\/jpegtran\/\">jpegtran<\/a>, and then managed to find <a href=\"http:\/\/mjpeg.sourceforge.net\/\">MJPEG tools<\/a> &#8211; a bunch of commandline tools for manipulating MJPEG data, actually designed for video capture utilities. And guess what? <strong>It works!<\/strong> 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!<\/p>\n<p>Oddly, the biggest sticking point was sound &#8211; the mjpegtools utilities can&#8217;t see the sound stream in my source files. In fact, the only utility I could was <a href=\"http:\/\/ffmpeg.org\/\">FFmpeg<\/a>, which at over 10 times the size of all the other tools put together is like the proverbial sledgehammer to the sound streams nut.<\/p>\n<p>So, with my meagre Windows batch-scripting skills, I&#8217;ve put together something which might, just about, be useful, and called it <strong><a href=\"https:\/\/rwec.co.uk\/vidrotate\/\">VidRotate<\/a><\/strong>. <strong>Go forth, download!<\/strong> But beware &#8211; I make absolutely <em>no<\/em> guarantee that it won&#8217;t blow your computer up at this stage&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while ago, after flickr launched the ability to upload &#8220;long photos&#8221;, I shot a clip of waves crashing on the beach, and wanted to share it. But it seems there is no easy way of rotating a video to sit upright &#8211; so, to cut a long story short, I wrote one: welcome to VidRotate!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[41,44,43,45,40,42,39,38],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-avi","tag-digital-camera","tag-flickr","tag-longphoto","tag-mjpeg","tag-photography","tag-script","tag-video","post-preview"],"_links":{"self":[{"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":5,"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/posts\/45\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rwec.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}