Skip to main content

Enumerate and select video capture devices

Products: Video Capture SDK .Net

Video Capture SDK .Net can use any video capture device supported by OS. The code sample shows you how to list available video capture devices and choose one of them.

Enumerate video capture devices

foreach (var device in VideoCapture1.Video_CaptureDevices())
{
// add to some combobox
cbVideoInputDevice.Items.Add(device.Name);
}

Enumerate available video formats and frame rates

// find device by name
var deviceItem = VideoCapture1.Video_CaptureDevices().FirstOrDefault(device => device.Name == "Some device name");

// enumerate video formats
foreach (var format in deviceItem.VideoFormats)
{
cbVideoInputFormat.Items.Add(format);

// enumerate frame rates for a specified format
foreach (var frameRate in format.FrameRates)
{
cbVideoInputFrameRate.Items.Add(frameRate.ToString(CultureInfo.CurrentCulture));
}
}

Set the video capture device as a source

// find the device by name
var deviceItem = VideoCapture1.Video_CaptureDevices().FirstOrDefault(device => device.Name == "Some device name");
VideoCapture1.Video_CaptureDevice = new VideoCaptureSource(deviceItem.Name);
VideoCapture1.Video_CaptureDevice.Format = deviceItem.VideoFormats[0].ToString();
VideoCapture1.Video_CaptureDevice.FrameRate = deviceItem.VideoFormats[0].FrameRates[0];

Use the VideoPreview or VideoCapture mode to preview or capture video from the device.


Visit our GitHub page to get more code samples.