Click here to Skip to main content
14,124,595 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


34 bookmarked
Posted 23 Nov 2012
Licenced CPOL

Easy AVI

, 5 Dec 2012
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.

You may also be interested in...

Comments and Discussions

GeneralMy missing vote Pin
imagiro11-Jun-14 21:43
memberimagiro11-Jun-14 21:43 
GeneralMy vote of 5 Pin
Michael Haephrati3-Mar-13 5:32
mvpMichael Haephrati3-Mar-13 5:32 
GeneralMy vote of 5 Pin
Mihai MOGA14-Dec-12 6:12
professionalMihai MOGA14-Dec-12 6:12 
GeneralMy vote of 5 Pin
Michael Haephrati6-Dec-12 2:20
mvpMichael Haephrati6-Dec-12 2:20 
GeneralRe: My vote of 5 Pin
Andy Bantly6-Dec-12 5:25
memberAndy Bantly6-Dec-12 5:25 
QuestionAwesome Pin
DeepCodeTech28-Nov-12 21:38
memberDeepCodeTech28-Nov-12 21:38 
Questiongreat article Pin
jamseyang24-Nov-12 4:38
memberjamseyang24-Nov-12 4:38 
AnswerRe: great article Pin
Andy Bantly24-Nov-12 5:56
memberAndy Bantly24-Nov-12 5:56 
GeneralRe: great article Pin
Pushpraj Barick24-Nov-12 15:34
memberPushpraj Barick24-Nov-12 15:34 
GeneralRe: great article Pin
Andy Bantly24-Nov-12 16:13
memberAndy Bantly24-Nov-12 16:13 
QuestionDIVX Pin
Andy Bantly24-Nov-12 3:38
memberAndy Bantly24-Nov-12 3:38 

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

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

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