Converting .mov files to .avi in Microsoft Windows

Over the christmas, I got a present of a Nikon Coolpix AW100. It's a compact camera and so it's limited in flexibility and image quality compared to my DSLR, however it has some unusual features that I'm enjoying experimenting with. It's waterproof (!), does geotagging (example here) and shoots video at 1080p, and can also shoot video at 240 frames per second (at low resolution).

Video captured on this device is stored as .mov files, which is a bummer as this is an Apple Quicktime format and although there are plenty of other tools which support playback of these files, there's very little support for editing this type of file outside of Quicktime. And I hate Quicktime. And Apple. Converting these files to the more Windows friendly .avi format would allow the use of VirtualDub which is a really fast and reliable, heavily optimised video editing tool written in C++.

There are two types of reasons for wanting editing a short video clip: A) to trim bad parts of the shot, to grade colour or apply filters, to patch several trimmed clips together to make a scene or B) to compress the clip for storage or publication (e.g. host on your website or upload to Vimeo or YouTube). I'm interested in doing both of these things, and I spent quite a while today figuring out how to allow this under Windows, and before I forget how it all works, I thought I should describe it here.

Download and "install" MPlayer


First, you need to get your hands on the MPlayer and MEncoder tools. They come packaged together here. Get the Windows builds, and download the version compiled for your computer's CPU (e.g. I got the version compiled for Intel Pentium 4 or better). Extract the folder from the archive you've dowloaded and move it to a sensible place on your hard-drive. I renamed the folder to "MPlayer" and moved it to "C:\MPlayer", which will crop up later in these instructions.

Create a batch script for converting .mov to x264 .avi



.avi files are much more widely accepted as input for video editing software, and x264 is a good, modern video compressor (or codec), similar to that used in high-definition BluRay videos.

Using notepad, create an empty text file called MPConvertx264.bat in your MPlayer directory (e.g. C:\MPlayer). The extension .bat indicates that this is a Windows batch file which lets you automate actions in Windows, like a shell script in Linux. Copy the text below into it, save and close the file. If your MPlayer files are in a folder other than C:\MPlayer, you will need to adjust the text to reflect that.


Title %~n1 -- pass 1
"C:\MPlayer\mencoder.exe" %1 -oac pcm -ovc x264 -x264encopts pass=1:turbo:bitrate=6000:frameref=1:analyse=all:me=umh:subme=4:trellis=1:bframes=1:subq=4:mixed_refs:weight_b:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200 -vf harddup -oac pcm -o NUL

Title %~n1 -- pass 2
"C:\MPlayer\mencoder.exe" %1 -oac pcm -ovc x264 -x264encopts pass=2:bitrate=6000:frameref=4:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:mixed_refs:weight_b:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200 -vf harddup -oac pcm -o "%~1_x264.avi" %1
\\@pause
del *.log


If you drag one of your 1080p .mov files and drop it on the .bat file you've just created in the MPlayer folder, it will automatically convert it to a compressed .avi file.

Create a batch script for converting .mov to HuffyUV .avi



If you want to continue to edit the clip, for instance trim it and append it to other clips to make a short movie, then it doesn't really make much sense to take a file that your camera has already compressed (with a slight loss in image quality) and recompress it (incurring another slight loss in image quality) to allow editing in Windows, since after editing you will surely compress the video again (incurring yet another loss in image quality). To avoid all of these so-called lossy steps, we can immediately convert to a lossless type of .avi: for instance using the HuffyUV codec instead of the x264 codec. The disadvantage of the HuffyUV codec is that the files are very large, but that's probably ok since they will only be temporary files which you will trim and edit before compressing your final masterpiece with a more efficient (but lossy) codec such as x264. Once the final video is complete (after editing with VirtualDub for instance), you can delete the temporary, intermediate HuffyUV files to free up space.

To convert .mov files to HuffyUV .avi files, just create an empty text file called MPLossless.bat in the MPlayer folder, as before and add the text below to it:


Title %~n1 -- Lossless encoding
"C:\MPlayer\mencoder.exe" %1 -oac pcm -ovc lavc -lavcopts vcodec=ffvhuff:vstrict=-1:vhq:psnr -noskip -o "%~1_huff.avi" %1
\\@pause


Again, dragging and dropping a .mov file onto this .bat file will perform the appropriate conversion.

Windows tricks to make conversion easier



We can allow instant conversion of files by right-clicking on them by adding these files to the "Send To" menu. Simply copy both files to:

C:\Users\[USER NAME]\AppData\Roaming\Microsoft\Windows\SendTo

replacing [USER NAME] with the appropriate Windows user name.

We can also write some batch files to carry out batch conversion of many .mov files in series, freeing you to do other things while your computer is busy converting your files.

As above, simply create a .bat file (e.g. Makex264.bat) containing the following text and place it into a folder containing .mov files, in order to convert each one to an x264 .avi:

for /f %%1 IN ('dir /b *.MOV') do call C:\MPlayer\MPConvertx264.bat %%1

Similarly, create a .bat file (e.g. MakeLossless.bat) with the following text for lossless conversion of all .mov files:

for /f %%1 IN ('dir /b *.MOV') do call C:\MPlayer\MPLossless.bat %%1

Simply double-click on either .bat file to convert all clips in the folder.

Credits



I patched these instructions together, adjusting handy example scripts from these three sources.