Skip to main content

Code sample - How to select video and audio capture devices?

Delphi and C# (ActiveX) sample code

Select video source

Get a list of available video capture devices

for i := 0 to VideoCapture1.Video_CaptureDevices_GetCount - 1 do
cbVideoInputDevice.Items.Add(VideoCapture1.Video_CaptureDevices_GetItem(i));
for (int i = 0; i < VideoCapture1.Video_CaptureDevices_GetCount(); i++)
cbVideoInputDevice.Items.Add(VideoCapture1.Video_CaptureDevices_GetItem(i));

Select video input device

VideoCapture1.Video_CaptureDevice := cbVideoInputDevice.Items[cbVideoInputDevice.ItemIndex];
VideoCapture1.Video_CaptureDevice = cbVideoInputDevice.Text;

Get a list of available video formats

VideoCapture1.Video_CaptureDevice_Formats_Fill;
for I := 0 to VideoCapture1.Video_CaptureDevice_Formats_GetCount - 1 do
cbVideoInputFormat.Items.Add(VideoCapture1.Video_CaptureDevice_Formats_GetItem(i));
VideoCapture1.Video_CaptureDevice_Formats_Fill();
for (int i = 0; i < VideoCapture1.Video_CaptureDevice_Formats_GetCount(); i++)
cbVideoInputFormat.Items.Add(VideoCapture1.Video_CaptureDevice_Formats_GetItem(i));

Select video format

VideoCapture1.Video_CaptureFormat := cbVideoInputFormat.Items[cbVideoInputFormat.ItemIndex];
VideoCapture1.Video_CaptureFormat = cbVideoInputFormat.Text;

or

Automatically choose the best video format

VideoCapture1.Video_CaptureFormat_UseBest := cbUseBestVideoInputFormat.Checked;
VideoCapture1.Video_CaptureFormat_UseBest = cbUseBestVideoInputFormat.Checked;

Get a list of available frame rates

VideoCapture1.Video_CaptureDevice_FrameRates_Fill;
for I := 0 to VideoCapture1.Video_CaptureDevice_FrameRates_GetCount - 1 do
cbFrameRate.Items.Add(VideoCapture1.Video_CaptureDevice_FrameRates_GetItem(i));
VideoCapture1.Video_CaptureDevice_FrameRates_Fill();
for (int i = 0; i < VideoCapture1.Video_CaptureDevice_FrameRates_GetCount(); i++)
cbFramerate.Items.Add(VideoCapture1.Video_CaptureDevice_FrameRates_GetItem(i));

Select frame rate

VideoCapture1.Video_FrameRate := StrToFloat(cbFrameRate.Items[cbFrameRate.ItemIndex]);
VideoCapture1.Video_FrameRate = Convert.ToDouble(cbFrameRate.Text);

Select needed video input (configure crossbar) if needed.

Select audio source

Use video capture device as audio source

VideoCapture1.Video_CaptureDevice_IsAudioSource := true;
VideoCapture1.Video_CaptureDevice_IsAudioSource = true;

or

Get a list of available audio capture devices

for I := 0 to VideoCapture1.Audio_CaptureDevices_GetCount - 1 do
cbAudioInputDevice.Items.Add(VideoCapture1.Audio_CaptureDevices_GetItem(i));
for (int i = 0; i < VideoCapture1.Audio_CaptureDevices_GetCount(); i++)
cbAudioInputDevice.Items.Add(VideoCapture1.Audio_CaptureDevices_GetItem(i));

Select audio input device

VideoCapture1.Audio_CaptureDevice := cbAudioInputDevice.Items[cbAudioInputDevice.ItemIndex];
VideoCapture1.Audio_CaptureDevice = cbAudioInputDevice.Text;

Get a list of available audio formats

VideoCapture1.Audio_CaptureDevice_Formats_Fill;
for I := 0 to VideoCapture1.Audio_CaptureDevice_Formats_GetCount - 1 do
cbAudioInputFormat.Items.Add(VideoCapture1.Audio_CaptureDevice_Formats_GetItem(i));
VideoCapture1.Audio_CaptureDevice_Formats_Fill();
for (int i = 0; i < VideoCapture1.Audio_CaptureDevice_Formats_GetCount(); i++)
cbAudioInputFormat.Items.Add(VideoCapture1.Audio_CaptureDevice_Formats_GetItem(i));

Select format

VideoCapture1.Audio_CaptureFormat := cbAudioInputFormat.Items[cbAudioInputFormat.ItemIndex];
VideoCapture1.Audio_CaptureFormat = cbAudioInputFormat.Text;

or

Automatically choose the best audio format

VideoCapture1.Audio_CaptureFormat_UseBest := cbUseBestAudioInputFormat.Checked;
VideoCapture1.Audio_CaptureFormat_UseBest = cbUseBestAudioInputFormat.Checked;

Get list of available audio inputs (lines)

VideoCapture1.Audio_CaptureDevice_Lines_Fill;
for I := 0 to VideoCapture1.Audio_CaptureDevice_Lines_GetCount - 1 do
cbAudioInputLine.Items.Add(VideoCapture1.Audio_CaptureDevice_Lines_GetItem]](i));
VideoCapture1.Audio_CaptureDevice_Lines_Fill();
for (int i = 0; i < VideoCapture1.Audio_CaptureDevice_Lines_GetCount(); i++)
cbAudioInputLine.Items.Add(VideoCapture1.Audio_CaptureDevice_Lines_GetItem(i));

Select audio input

VideoCapture1.Audio_CaptureLine := cbAudioInputLine.Items[cbAudioInputLine.ItemIndex];
VideoCapture1.Audio_CaptureLine = cbAudioInputLine.Text;

Please contact support to get help with this tutorial. Visit our GitHub page to get more code samples.