Some applications need to create an AVI file from a series of bitmaps, one frame at time. The VfW (Video for Windows) AviFile API provides a method for doing this, but it can't create files larger than 2 GB, which makes it useless for uncompressed video. The only way to avoid the 2 GB limit is by writing a DirectShow source filter, which is a royal pain, but the good news is, you don't have to do it! You can just download this FREE project instead.
Note that this project is also available as a DLL. The advantage of the DLL is that you don't need to have the SDK installed! Finding the right version of the SDK and DirectShow source objects and getting them to compile correctly is a major hassle. With the DLL, you can skip all of that. In most cases you will be much better off with the DLL! However if for some reason you prefer the library, proceed...
If you want an application that converts a folder containing bitmaps to an AVI file, that's available here.
Download library project
The project includes the following items:
If you need the filter source, e.g. to license it for non-exclusive commercial use, please contact the developer (Chris Korda) here.
To build BmpToAviTest, you must have the DirectX 8.1 (or higher) header files in your include path. In particular, you need DShow.h and the headers that it includes. Typically the path you want is x:\foo\DXF\DXSDK\include, where x:\foo is the folder you unzipped the SDK into.
To run BmpToAviTest, you must have previously registered the BmpToAvi filter, otherwise you will get the error, "Can't create BmpToAvi filter, Class not registered". Use the batch file reg.bat to register the filter, and use unreg.bat to unregister it. Note that your application's installer would typically handle registering and unregistering COM objects.
The test application displays a dialog which allows you to select a compressor and configure it. The compression dialog is backwardly compatible with the dialog displayed by AVISaveOptions in the legacy VfW interface, though it offers a superset of the VfW dialog's capabilities.
The application's main loop is the Test function, in BmpToAviTest.cpp. This function generates a test video with attributes as specified by the Parms structure (Width, Height, BitCount, and FrameRate), as well as FrameCount and Path. The function creates a bitmap, using CreateFrame, repeatedly writes a moving test pattern to it, using DrawFrame, and adds each frame to the output video by passing the bitmap handle to CAviToBmp::AddFrame.
Note that the example only creates a single bitmap and then reuses it. This is more efficient than creating and destroying a bitmap for each frame.
The video attributes can be changed by editing the values in main. To test the application's ability to generate videos larger than 2 GB, simply change the frame count to a sufficiently large number, and select "Uncompressed" in the compression dialog. At the default settings (640 x 480, 16 bit, 25 FPS), the application generates 614KB per frame, so a frame count of 4000 (160 seconds) would exceed 2 GB.