Write a DirectShow video capture application with VideoLab or VisionLab using C#, VB.NET, J# or C++/CLI


This is a step by step tutorial for writing a simple DirectShow video capture application in .NET by using VideoLab or VisionLab. The steps are exactly identical in C#, Visual Basic .NET, C++/CLI and J#.

Using the application created by following the tutorial, you will be able to capture from Webcam, Camcorder, Camera, TV Tuner, DVR, VCR, DVD Player, or any other video source.

WARNING: In order to run the application in this example you must have DirectX 9.0 or higher installed on your system!

There is no code writing necessary to complete this application.

There is no need to know C#, Visual Basic, J# or C++ in order to create this application.


 

SimpleVideoCapture

The tutorial covers the following steps, which should take less than two minutes:

1. Add a DSCapture Component to Your Application's Form:

DSVideoCapturePalette

2. Add a DSImageDisplay Control to Your Application's Form:

dsImageDisplayPalette

3. Add a DSVideoLogger Component to Your Application's Form:

DSVideoLoggerPalette

4. Set the DSImageDisplay Control's Properties:

4.1 Arrange you form to look similar to this:

Fim1ImageDisplay

4.2. Set the DSImageDisplay Control’s Anchor property to “Top, Bottom, Left, Right”:

dsImageDisplayAnchor

5. Select video capture device for the DSCapture Component:

5.1. Click on the ComponentEditorsButton button on the dsCapture1 component, and then click “Select Video Device ...”:

Form1DSCapture1Editors

5.2. In the dialog select a video capture device:

DSVaptureVideoDeviceSelect

5.3. Optionally select audio capture device. If you do not select the device the component will use the default device for your system.

6. Connect the DSCapture.OutputPin to DSImageDisplay.InputPin and DSVideoLogger.InputPin:

6.1. In the dsCapture1 Properties select OutputPin and click on the DottedButton button:

DSCapturePropertiesOutputPin

6.2. In the connection editor check the InputPin of the dsImageDisplay1 and the InputPin of the dsVideoLogger1, then click OK:

DSCaptureOutputPinEdit

7. Connect the DSCapture.AudioOutputPin to DSVideoLogger.AudioInputPin:

6.1. In the dsCapture1 Properties select AudioOutputPin and click on the DottedButton button:

DSCapturePropertiesAudioOutputPin

7.2. In the connection editor check the AudioInputPin of the dsVideoLogger1 and click OK:

DSCaptureAudioOutputPinEdit

8. Specify file to record in the DSVideoLogger Component:

8.1. Select the dsVideoLogger1 component:

Form1DSVideoLogger1

8.2. In the dsVideoLogger1 Properties select the FileName property and enter the path and the name of the file where you want to record the captured video:

DSVideoLoggerFileName

9. Run the Application:

9.1 Press (F5) to run the application. You should see the captured video:

CapturedVideo