AVI Screen Capture Tech Info
AVI Screen Capture
Home
AVI Screen Capture - Technical Information For Developers

This page is for program developers who wish to write their own AVI screen capture programs but don't really know where to start. There is no demo code on this page; download the project's source code to see how it really works internally. This page is just to tell you what is needed to make a screen capture program and hopefully will let you know "where to look" for further technical information, if the project source code is not making sense to you.

First let's start by summarizing the tasks that an AVI screen capture program must do.

  1. Have some way to "capture" the image of the screen
  2. Create and write to AVI files, with the ability to use existing codecs on the user's machine
  3. Have a "hotkey" termination, so the user can stop the capture by pressing ESC, or some other key
Task 1 - Capturing the screen image into memory
This is done by first getting a handle to the device context of the window you wish to capture, then creating a memory bitmap to store the contents of the screen image. The MSDN pages contain an example of how to do this: Capturing an Image. You may also want to see Storing an Image too, since this describes how to save your bitmap to a file. Look at these two pages and see if you can write a program to capture the screen image to a bitmap file. This is a good primer before we go to capturing screen activity to a video file.

Task 2 - Writing the AVI File
I wish I could say this was a simple step, but writing an AVI file is going to be much more difficult than just writing a bitmap file. Start by looking here: AVIFile Functions. The AVIFile library is a library designed to let you read and write AVI files without dealing with low level file I/O or video compression/decompression. I may add more information on this later, but for now, look at how the source code and observe how it uses the AVIFile functions to write the AVI file.

Task 3 - Stopping Capture when ESC is Pressed
Since the AVI capture application window(s) dissapear during the capture, your application will not have focus when the user hits the escape key. Therefore we need a way to capture key presses that will be processed by other applications. This can be done with a keyboard hook. See SetWindowsHookEx for a starting point on hooks. I may add more information on this topic later, but for now look at the DLL project source code. There are two separate projects included in the ZIP file and the Microsoft Visual C++ one is the one that deals with the hook.