Skip to main content

Select video and audio capture devices

Products: Video Capture SDK .Net

You can download the sample project from GitHub.

Sample code

Select video source

1. Get a list of available video capture devices, and fill combo-box

foreach (var device in VideoCapture1.Video_CaptureDevices)
{
cbVideoInputDevice.Items.Add(device.Name);
}

2. Create video source device settings

VideoCapture1.Video_CaptureDevice = new VideoCaptureSource(cbVideoInputDevice.Text);

3. Get a list of available video formats and frame rates, fill combo-box

var deviceItem = VideoCapture1.Video_CaptureDevices.First(device => device.Name == cbVideoInputDevice.Text);
if (deviceItem == null)
{
return;
}

cbVideoInputFormat.Items.Clear();
foreach (string format in deviceItem.VideoFormats)
{
cbVideoInputFormat.Items.Add(format);
}

cbFramerate.Items.Clear();
foreach (string frameRate in deviceItem.VideoFrameRates)
{
cbVideoFrameRate.Items.Add(frameRate);
}

4. Select the video format

VideoCapture1.Video_CaptureDevice.Format = cbVideoInputFormat.Text;

or automatically choose the best video format

VideoCapture1.Video_CaptureDevice.Format_UseBest = true;

5. Select the frame rate

VideoCapture1.Video_CaptureDevice.FrameRate = Convert.ToDouble(cbVideoFrameRate.Text);

6. Select needed video input (configure crossbar) if needed

Select audio source

1. Get a list of available audio capture devices, and fill combo-box

foreach (var device in VideoCapture1.Audio_CaptureDevices)
{
cbAudioInputDevice.Items.Add(device.Name);
}

2. Create audio source device settings

VideoCapture1.Audio_CaptureDevice = new AudioCaptureSource(cbAudioInputDevice.Text);

3. Get a list of available audio formats, and fill combo-box

var deviceItem = VideoCapture1.Audio_CaptureDevices.FirstOrDefault(device => device.Name == cbAudioInputDevice.Text);

if (deviceItem != null)
{
foreach (string format in deviceItem.Formats)
{
cbAudioInputFormat.Items.Add(format);
}
}

2. Select the format

VideoCapture1.Audio_CaptureDevice.Format = cbAudioInputFormat.Text;

or automatically choose the best audio format

VideoCapture1.Audio_CaptureDevice.Format_UseBest = true;

3. Select input (line)

VideoCapture1.Audio_CaptureDevice.Line = cbAudioInputLine.Text;

Required redists

How to install the required redists or deploy them to the user's PC?


Visit our GitHub page to get more code samples.