Batch Convert AVI and MP4 files into MKV format

Convert AVI MP4 to MKV Continuing to get your movie collection in order you may find yourself wanting to change order encodes such as AVI or MP4 files into an MKV format. For instance, the easiest way to bypass the new Windows Media Foundation framework inside of Media Center is to use a non-native format such as MKV. Of course, this will also break support on Media Center Extenders as most often they will not support the MKV format.

Converting each movie from it’s current format to another using traditional means can be a task that many would give up before even starting. The idea of converting each file one by one can be daunting for those with large collections. That’s where these files and guide can come in handy. This will enable you to do a batch processing of AVI and MP4 files into MKV files.

Get the tools

Before we get started you will need a couple of items downloaded and installed. The first of which is MKVToolnix, this set of tools will provide the command line program used by the .bat file to convert any AVI or MP4 files which don’t include WMA audio. Install the program using the installer provided on the MKVToolnix website.

Second, this zip file, which includes a .bat file and a directory which should be placed in your movies directory. Also, these files are marked “Hidden” by default and necessity, you’ll need to enable hidden items which you can find instructions for here.

Getting Started

Once you have installed MKVToolnix and extracted the zip file to your movies directory you will need to move all your AVI and MP4 files to the main directory if they aren’t there already. The simplest way to accomplish this is to enter a search in Windows Explorer for .avi/.mp4 and cut/paste into the main directory.

Windows Explorer Search

This is done due to the fact that the .bat file doesn’t use recursive directory codes. There are four different versions of the batch file included in the zip.

  1. Just Convert – Will convert any AVI and MP4 files to MKV
  2. Convert and Move - Will convert to MKV then move to a directory with the same name as the file's name
  3. Convert and Delete - Wil convert to MKV then delete the original AVI/MP4 files
  4. Convert, Move and Delete - Will convert to MKV, move to folders then delete the originals

During conversion, if the file is able to be converted by MKVToolnix’s MKVMerge it will be. This is the fastest method of converting the files to the MKV format as it simply re-muxes the file into an MKV. If the original file uses WMA for audio, however, the conversion will not occur with current versions of MKVToolnix. Support for these files is planned for later versions.

Also, included is a version named simply “avitomkv.bat”. This version includes the ability to convert files encoded with WMA audio by using the HandbrakeCLI from Handbrake.fr. This version is the most robust as it will re-encode all files, however, during this process the original files are deleted. This isn’t optional in this version and is irreversible, use with extreme care!

Stick with Hack7MC

Hopefully, this guide will get anyone looking to do a batch conversion of their media where they need to go. This little .bat file saved me much time recently converting a sizable collection of AVIs to MKV in order to circumvent Windows Media Foundation in Media Center.

Check out more Tips to Organizing Your Movie Collection on Hack7MC!

Windows Media Foundation and Windows 7

Windows 7 Logo Windows 7 introduces some additional functionality to a feature that was added in Windows Vista, Windows Media Foundation. The goal of the Windows Media Foundation is to ease control of media playback for developers. The idea is to remove the need for individual codecs and instead rely on a single Windows package for media playback, much like DirectX does for game platforms.

In Windows 7, as noted on Microsoft MSDN, there have been some additional changes made to the Windows Media Foundation framework.

What's New in Windows 7

Microsoft Media Foundation was introduced in Windows Vista as the replacement for DirectShow. Of course, DirectShow is still supported in Windows 7, but developers are encouraged to use Media Foundation in their new digital media applications.

The improvements to Media Foundation can be summarized as follows:

  • Better format support, including MPEG-4
  • Support for capture devices and hardware codecs
  • A simplified programming model
  • Improvements to the platform

We are all fairly well aware that Windows 7 includes native support for certain formats, such as H.264, and it does this through the use of Windows Media Foundation. Media Center and Windows Media Player have both been updated to use this new framework in Windows 7. The benefit is added support for a number of codecs out of the box.

There is, however, a downside to this new implementation. The protected pipeline used in this new framework doesn’t allow outside access to user installed codecs for native formats by default. For instance, if you wanted to use FFDShow to decode avi files, which are natively supported by WMF. This means much like the (often indefinite) wait for x64 codecs and splitters users will once again be put to the sidelines to wait for updated decoders that use WMF.

Media Foundation Process Chart

Current work-arounds for this situation have led users to renaming system files and other chicanery in order to get their favorite codecs working through Media Center. In more recent versions of Windows 7’s beta, however, the ability to accomplish this hack has been crippled. The consensus seems to be that as of beta 7057, the rename hack no longer works.

It seems that once again users may be forced to wait on new solutions to the codec problem that have already been hard suffered for Windows Vista Media Center users. It seems we may once again be at the whim of those gracious programs who take it upon themselves to better Microsoft’s meager implementations and give us a little more control of our media.

Expect updates on Windows Media Foundation and Windows 7 Media Center in the near future. Keep up to date on the situation by subscribing to the Hack7MC RSS Feed or by following on Twitter.

Hack7MC Has Moved!

Hack7MC has left Blogspot for a new home. Following the original address @ http://www.hack7mc.com will take you to the new home page.