Open H264 videos in VirtualDub

At first glance, this article may appear complete out of place, but with more and more portable MPEG4 video recorders available at cheaper prices, I thought it would be a good idea to present an easy way to edit footage from such cameras. Besides, this article contains a number of links to useful free software to either playback or edit video.. now that everyone wants to be a youtube star :3
Now before I get started, there are a few things that I must clarify. VirtualDub is one of the most powerful video editors/processing tools available for free. And while it will not replace a dedicated video editing program, it will allow you to convert the footage from your shiny new camera into something your regular video editor will understand and work without a problem.
Most newer cameras compress video into either MJPEG or H.264 formats, and the containers used to ‘encapsulate’ these formats tend to be AVI, MOV, or MTS. The important thing to notice is that MJPEG is a very ‘editing-friendly’ format that almost any video editor will ingest and work without much effort. With MJPEG, there is no need to have a really fast and powerful super computer in order to work with 720P or 1080P videos, because the Motion-JPEG codec (as the name implies) is simply a series of JPG images, that when played back in rapid succession (at 30 or 60 images per second), give the impression of motion.
The important thing to remember is that in MJPEG, every frame/image is not dependent from the previous one. Each frame stands on its own, making video editing (scrubbing, seeking, rewinding, forwarding, slicing, frame accurate cuts) extremely simple for the computer.
H.264 on the other hand is a completely different story. Yes, the video filesizes are much smaller (due to a greater compression and lower data rate), but H.264 is more of a ‘delivery format’.. meaning, once all of your editing is completely done, it’s a good idea to export a copy of your video to this format for online distribution (youtube, your own site). Every frame of video on this format is an incomplete image, depending on the neighbouring frames to create a full image, and every now and then there are keyframes (frames that contain a complete image). This makes editing much more difficult.
But enough! The idea of this article is to convert your MOV, MP4 or MTS videos into an editing friendly format, and such format will be a simple AVI with MJPEG compression for video and uncompressed PCM audio. Even Windows Movie maker has no problems working with 1080P files in this format!
If your file is 60fps or 50fps, you may wish to convert it to 30fps (or 25fps) without losing sync with the audio, in order to distribute it online or playback in a number of hardware devices (PS3, WD TV media player, etc).
The run down is: Opening the MP4 (or MTS or MOV) in virtualdub in order to ‘decimate’ every other frame, exporting the results and re-compressing them in avidemux. Fairly simple. However, virtualdub won’t take MP4 videos, so support software must be installed to do this.
VirtualDub needs to be installed in the system, and it doesn’t matter if the installation of this program is performed before or after the following.
First I installed aviSynth. This allows me to ‘feed’ different types of video into virtualdub.
Still, for virtualdub to open any kind of video, the appropriate codecs must be installed on the system. So to keep things moving along the freeware realm, I then installed FFDShow. During installation I selected the following:
- on the ’select components’ window, check everything but ‘DScaler’ (see image).
- Leave the rest of the settings as default and finish installation.
However, a codec is not all that’s needed to playback a video… something else called a ’splitter’ is also needed. So next step was installing the Haali Media Splitter using default settings.
With just these steps, one is able to open MP4 files in virtualdub. To do this, an avisynth script is needed (it’s just a simple text file with .avs extension). So go to the directory where your 60fps file is at, and create a new text file (I called mine ‘loadvideo.txt’) and type the following:
DirectShowSource("video.MP4")
Or if you wish to create the text file in a different directory, specify the absolute path for the video files like this:
DirectShowSource("C:\Directory\Location\video.MP4")
Replace “video.MP4″ with the filename of your video (include the quotation marks).
Save your text file and rename it from .txt to .avs (mine is now called ‘loadvideo.avs’).
Open VirtualDub and select ‘file – open video file’. Select the .avs file to open your video. You will notice that your video opens in virtualdub, but if you select ‘File – File information’, the audio stream could be empty since is not decoded 
So to fix that, two things need to be done. The first one is to disable the AAC decoding from FFDShow. So from the programs menu on the ffdshow folder, select ‘audio decoder configuration’. On the section ‘CODECS’ on the left, you will see ‘AAC’ format on the list on the right.
From the column ‘Decoder’ for AAC, click and change from ‘libfaad2′ to ‘disabled’. Hit ‘APPLY’and ‘OK’ at the bottom.
Now you must install a free AAC decoder. My choice for this was CoreAAC DirectShow filter. There is nothing about the installation of this software really.
Now Open virtualdub again, load the AVS file and check the file information to see that the audio shows up as a PCM stream.
From here is fairly simple. ‘Video – framerate’ then ‘process every other frame’ (Do this ONLY if you wish to convert 60 or 50fps to 30 or 25fps). Save as MJPEG 90% quality with uncompressed audio. For this, select ‘video – full processing mode’ then again ‘video – compression’ select ‘FFDShow’ hit ‘Configure’. From the ‘Encoder’ tab, select ‘MJPEG’ as the encoder, then in ‘Mode’ select ‘One pass quality’ and set it to 90 on ‘Quality’. Hits ‘Apply – Ok’ and ‘OK’ to close all dialog boxes.
For the audio, simply select ‘Audio – full processing mode’, ‘Audio – compression’ and select ‘no compression PCM’ and hit ‘OK’. Finally just select ‘File – Save as AVI..’ and select a location. The resulting video (be it 720P or 1080P) will be a breeze to edit with any software.
Something I tend to do, is to open the resulting file in Avidemux and encode to x264 video with AAC audio in an MP4 container. Depending on the video resolution, specify a bitrate of something like 6megabits (640×480), 12megabits (1280×720), or even 22 to 24megabits (1920×1080). The audio can remain at 128kbps in AAC format.
Free software used in this tutorial:
http://avisynth.org/mediawiki/Main_Page
http://haali.cs.msu.ru/mkv/
http://www.free-codecs.com/download/FFDshow.htm
http://www.free-codecs.com/download/CoreAAC_Directshow_filter.htm
Installation instructions
- Install aviSynth
- Install ffdshow
- Install the Haali Media Splitter using default settings.
- Install the CoreAAC DirectShow Filter using default settings.
- on the ’select components’ window, check everything but ‘DScaler’ (see image).
- Leave the rest of the settings as default and finish installation.
If anything seems confusing, feel free to leave a comment with your question. Enjoy!





