Video Saving Example
WHAT DOES THIS EXAMPLE DO?
  Live video frames are captured from your camera (USB or via a framegrabber) and saved to disk in AVI - format. Before starting to save, VideoOCX will display two dialog boxes: The first lets you enter the name of the avi file you wish to save to and the second will let you choose your desired compression algorithm (or no compression at all, if you wish).

HOW DOES IT WORK?
  First, a number of necessary initializations are done in part (1) of the example. This involves initialization of the control, starting of the internal capture process, allocation of memory and the initalization of the saving mode. In Part (2), 25 frames are captured in a loop and, if possible, displayed and saved afterwards. Last but not least, the video connection is closed and the used memory freed in Part (3).
VISUAL BASIC (see below for C++)
1 ' Counter for the loop
Dim i As Integer

' image handle
Dim image As Long

' Init Control
VideoOCX.Driver = 0
VideoOCX.Init
VideoOCX.Start

' Allocate memory for handle
image = VideoOCX.GetColorImageHandle

' Start save mode
VideoOCX.AVISaveFrameInit "", image, True
2 ' Loop for 25 frames
For i = 1 To 25

  ' Try to capture
  If (VideoOCX.Capture(image)) Then

    ' Show and save
    VideoOCX.Show image
    VideoOCX.AVISaveFrameAdd image
  End If
Next i
3 ' End save mode
VideoOCX.AVISaveFrameClose

' Free memory
VideoOCX.ReleaseImageHandle image

' Close control
VideoOCX.Stop
VideoOCX.Close
C++
1 // Counter for the loop
int i;

// image handle
long image;

// Init Control
m_VideoOCX.SetDriver(0);
m_VideoOCX.Init();
m_VideoOCX.Start();

// Allocate memory for handle
image = m_VideoOCX.GetColorImageHandle();

// Start save mode
m_VideoOCX.AVISaveFrameInit("", image, TRUE);
2 //Loop for 25 frames
for(i = 0; i < 25; i++)
{
  // Try to capture
  if (m_VideoOCX.Capture(image))
  {
    // Show and save
    m_VideoOCX.Show(image);
    m_VideoOCX.AVISaveFrameAdd(image);
  }
}
3 // End save mode
m_VideoOCX.AVISaveFrameClose():

// Free memory
m_VideoOCX.ReleaseImageHandle(image);

// Close control
m_VideoOCX.Stop();
m_VideoOCX.Close();
WHAT ELSE DO I NEED?
  You will need no more commands than the ones used in this example to implement this application. But, of course, it makes little sense to save only 25 frames !? We did this only to keep the example short and easy to understand. In order to save continiously in your own application, you will want to implement Part (2) of this example in some kind of a loop.