Code sample - Select video and audio capture devices

Delphi and C# (ActiveX) sample code.

Select video source

Get 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 device 

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

Get 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 best video format

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

Get 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 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 device 

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

Get 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 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));
VideoCapture1.Audio_CaptureLine := cbAudioInputLine.Items[cbAudioInputLine.ItemIndex];
VideoCapture1.Audio_CaptureLine = cbAudioInputLine.Text;

VisioForge © 2006-2019

  • GitHub-Mark-64px
  • Twitter Социальные Иконка
  • VisioForge Facebook page
  • YouTube channel