Click here to Skip to main content
Click here to Skip to main content

Easy AVI

, 5 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
A class to aid in creation of AVI files


This article presents a class that encapsulates the creation of AVI files. It also presents a small sample demonstrating how to use it to record the desktop at 15 FPS. Currently it doesn't support audio.

Using the code

The AVI object is very minimal and simple to use. One limitation is that the frames must all be the same size and the palette can't change. The sample code records the desktop using a 32 BPP DIB section and thus stays within the requirements.

The AVI class

class CAVI
    BOOL Open(DWORD FPS = 30);
    CString Close();
    BOOL AddFrame(CDIBFrame & DIBFrame);
    BOOL IsOpen() const {return m_bOpen;}

    void Init();
    void Term();
    BOOL CreateStream(CDIBFrame & DIBFrame);
    void ReleaseStream();

    BOOL m_bInit,m_bOpen,m_bStream;
    CString m_csFileName;
    DWORD m_dwFPS,m_dwFrame;
    PAVIFILE m_pAVIFile;
    PAVISTREAM m_pAVIStream,m_pAVICompressedStream;

Instantiate the class by declaring a CAVI object:


Get it ready for recording by opening it and setting the desired FPS.


Add a frame by using AddFrame that takes a bitmap created from a DIB section.


Finish up recording by calling Close. This gives back the location of the temporary AVI file in the user's temp directory.

CString csFile = Avi.Close();


  • 11/23/2012 - Article submission.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Andy Bantly
United States United States
Working as a software developer since 1989. Started out with Basic, FORTRAN and JCL, moved into Visual Basic 1.0, C, then C++, and now I work mainly in C++ using MFC, Win32, and ATL/COM. I use Microsoft Products only because that is what gives me gainful employment. Through work, I have a lot of experience with HTML, JavaScript, XSL transformations, the XMLHTTP object, PHP 4.x, and simple COM object integrations.
I've worked for the University of Oklahoma in the school of meteorology (Go SOONERS!), consulting, and now as a Senior Software Engineer. These things keep my lights on and electricity going. My dream job is to own a bowling alley and rub elbows with pro-bowlers! I'm also an avid pedicab driver and have my own cab. I like the hustle of picking up people in downtown and biking them to their destination.
Follow on   Google+   LinkedIn

Comments and Discussions

GeneralMy missing vote Pinmemberimagiro11-Jun-14 22:43 
GeneralMy vote of 5 PinmvpMichael Haephrati3-Mar-13 6:32 
GeneralMy vote of 5 PinmemberMihai MOGA14-Dec-12 7:12 
GeneralMy vote of 5 PinmemberMichael Haephrati מיכאל האפרתי6-Dec-12 3:20 
GeneralRe: My vote of 5 PinmemberAndy Bantly6-Dec-12 6:25 
QuestionAwesome PinmemberDeepCodeTech28-Nov-12 22:38 
Questiongreat article Pinmemberjamseyang24-Nov-12 5:38 
AnswerRe: great article PinmemberAndy Bantly24-Nov-12 6:56 
GeneralRe: great article PinmemberPushpraj Barick24-Nov-12 16:34 
GeneralRe: great article PinmemberAndy Bantly24-Nov-12 17:13 
QuestionDIVX PinmemberAndy Bantly24-Nov-12 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 5 Dec 2012
Article Copyright 2012 by Andy Bantly
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid