Hax264 Logo 
Project Page
 Latest README


HAX264 is a DirectShow Video Transform Filter for decoding H264(AVC) video. It also includes a VFW driver. It only registers for the "H264" FourCC, and the drivers are installed with "normal" priority, so it should coexist with other codecs peacefully. YMMV

This filter wraps the libavcodec portion of the FFMpeg project. Only the H264 codec from ffmpeg is exposed, and only the decoder is enabled. This is by design for patent liability reasons. However, this does expose the guts of a working DS filter - it could be easily modified to handle other underlying codecs. It was very difficult to find example code for a working filter that uses ffmpeg, so I hope that this may assist other developers who face the same issues I faced when this had to be written. It ain't perfect, as they say, but it works! And I'm always open to hearing from those who have a better idea/implementation.

The base filter was created by DSWizard, and some portions were deduced by looking at the ffdshow project. Note that this is an early version of ffdshow - I found the original much easier to understand than the newer, "tryouts" version.


You'll need to adjust your pathing to the DirectShow baseclasses library for sure. The pathing on my primary development machine can get a bit arcane, to say the least. Some folks include the baseclasses as part of the project to keep the build options in order, but I don't feel comfortable mixing M$ and the GPL that closely.

Mind that the actual ".ax" (DLL) file is built with static linkage to the runtime libs - be sure your baseclasses library is built that way too (or change them both to dynamic) or you'll have a slew of very peculiar unresolved externals. The compiler used for the filter is Microsoft Visual Studio 2003 dot Net. I can't seem to get the solution ported to anything newer, but that's probably just due to my unfamiliarity with Microsoft compiler environments. If you have expertise in this area by all means get in touch and let's work in a newer solution!

The ffmpeg portions (libavcodec) MUST be built using Msys and gcc. There is a solution file included (and it actually builds the blasted thing) but it'll be way too slow, especially in debug mode. It is useful for integrated debugging with Visual Studio, however, which is why it's still in there. For more instructions on how to build libavcodec see: http://ffmpeg.arrozcru.org/wiki/index.php?title=Main_Page

Bear in mind that you should NOT run the configure script that comes with ffmpeg - it doesn't exist in the hax264 directories - because config.h has been prebuilt for a Windows system. It's not that difficult to figure out how to do.

The reason that config.h has been prebuilt is that this is one of the places you select which codec(s) to enable/disable for ffmpeg. The other is in the libavcodec source directory and is called, appropriately enough, allcodecs.c Those are about the only files I modified from an off the shelf ffmpeg distribution. It would be relatively easy to rework this filter to decode any video codec supported by ffmpeg simply by changing these files and plugging in the correct FourCC codes into the filter itself.

I also added the following definition to the MSVC project files to prevent mass errors when using avcodec.h as an include in an MSVC project:

Those are the only changes to ffmpeg/libavcodec. So it should be relatively easy to grab the latest ffmpeg distribution, extract the libavcodec and libavutils directories, and rebuild Hax264. The ffmpeg source here is from SVN r14342

The installer uses the excellent InnoSetup. The installer now supports 32 and 64 bit systems. Note that libavcodec is placed into the same directory with the executables in a probably vain attempt to avoid DL Hell.


The flip option is implemented BY DEFAULT whenever the output is RGB - this handles DirectShow or VFW getting a thumbnail. Unchecking the configuration option simple prevents this reversal, which may be needed for some graphics cards that do the flip in hardware.

Aspect ratios are now implemented for image display in both the DS filter and the VFW codec. One peculiarity is exposed: most camcorders store 1080p images as 1440 x 1080, which is the incorrect aspect ration (4:3) for HD video. The real width should be 1920, and the DirectShow filter will normally render a 1440x1080 bitmap as 1920x1080, as it can detect the image size on the way in. The VFW decoder is not so cut and dried - the system lies and says the incoming is 1920 pixels wide, when it's not! This caused some problems (and confusion) to say the least. The only solution is the assume that any incoming bitmap that says it's 1920 is really 1440 and act accordingly. If the VFW decoder gets ahold of a real 1920 pixel wide bitmap, this will cause some interesting pictures at the least, or a crash at the worst! So there's a new config variable - Maintain Aspect Ratio. And I'll still be looking for a better solution. If you've got one, let me know!

Get Hax264 at SourceForge.net. Fast, secure and Free Open Source software downloads