Saving an AVI File

Short source code snippet that illustrates how to save an image data stream as an AVI file.

Language:.NET C#/Visual Basic
Version:3.3
Author:IC Imaging Control Support Department

Requirements:
Software:IC Imaging Control 3.3, Visual Studio™ 2010
Hardware:Camera, converter or grabber with WDM Stream Class drivers.
Download C# sampleSave AVI - C#

The window of the resulting application looks as follows:

The Testdialog of IC Imaging Control,

First of all, IC Imaging Control and two buttons to start and stop video are dragged onto the form.

The program starts by activating a built-in dialog that allows the end user to select a video capture device (.ShowDeviceSettingsDialog). Then, live image data stream of the the video capture device is displayed, using LiveStart:

C#
      
private void Form1_Load(object sender, System.EventArgs e)
{
    icImagingControl1.ShowDeviceSettingsDialog();

    if( !icImagingControl1.DeviceValid )
    {
        Close();
        return;
    }

    btnStopCapture.Enabled = false;
    icImagingControl1.LiveStart();
}

        

When the end user clicks on "Start Capture AVI", the device's image data stream(.LiveStop) is stopped and the creation of the AVI file is started (.AviStartCapture).

Clicking on "Stop Capture AVI" closes the AVI file(.AviStopCapture) and starts the image data stream (.LiveStart):

C#
      
private void btnStartCapture_Click(object sender, System.EventArgs e)
{
    icImagingControl1.LiveStop();
    icImagingControl1.AviStartCapture( "video.avi", "DV Video Encoder" );

    btnStartCapture.Enabled = false;
    btnStopCapture.Enabled = true;
}

private void btnStopCapture_Click(object sender, System.EventArgs e)
{
    icImagingControl1.AviStopCapture();
    icImagingControl1.LiveStart();

    btnStopCapture.Enabled = false;
    btnStartCapture.Enabled = true;
}