I last year I had a 2TB disk fail so I used dd to recover them to another disk well that disk failed so I was left to recover the files again. Which I’ve done so I’ve been uploading frantically to Flickr as a backup now but I have many videos that have been recorded where the camera was rotated 90 degrees causing neck ache whilst watching them! However digging around there were solutions using ffmpeg, avidemux and mencoder. I first tried avidemux as I use that a great deal, however on loading the file to rotate avidemux reported an error “No audio decoder found for this file” and there was no sound. I then tried ffmpeg which stopped with an error so that left me with mencoder, which worked without a hitch.
to do it with the files from my old nikon camera I had to use vcodec=mjpeg you will need to change this accordingly. I used VLC to get the codec information.
The rotation is a parameter after -vf and takes an argument of 0-7. as my images had to be rotated 270 degrees I had to use rotate=3 the command I used was similar to the following you will need to change the names of the input and output files accordingly
mencoder -ovc lavc -lavcopts vcodec=mjpeg -vf rotate=3 -oac copy inputfile -o outputfile
Older versions of mencoder used to use -vop instead of -vf
One of the other things I had to do was trim the video as some of the videos started off with the camera rotated 90 degrees but then somebody realized and then rotated it back without stopping the video.
However mencoder can trim video files down too. so to trim the file down one needs to use the endpos which will extract the video from the start of the file to the time identified by endpos. I found using avidemux the easiest way to get the time by going to the point just before where the camera gets rotated back and copying the time displayed in a box at the bottom of the window. Then pasting this into the command line for mencoder. Here is an example where I am trimming the video clip to 18 seconds. the endpos takes the format hh:mm:ss
mencoder -endpos 00:00:18 -oac copy -ovc copy tmp1.avi -o tmp2.avi
After this I then went to the point in the video where the camera was now orientated the right way and used the -ss parameter to extract the video from this point to the end to another video file. Here I’m extracting the video from 21 seconds to the end.
mencoder -ss 00:00:21 -oac copy -ovc copy tmp1.avi -o tmp3.avi
It worked very well. I left the two files as separate video files otherwise it would have looked odd on the screen.
Mencoder should be in your distributions repository. if not then try installing mplayer.