Skip to content

AudioDeviceIndexFromVideoDevice

function

Delphi
function AudioDeviceIndexFromVideoDevice (VideoDeviceIndex: LongInt): LongInt;

Returns the index of the audio capture device of the same USB device as a video capture device.

Remarks

Returns the index, in the AudioDevices list, of the audio capture device that belongs to the same USB device as the video capture device specified by its index (in the VideoDevices list), e.g. the microphone of a webcam.

The devices are matched on their USB device path, not on their names: this works with several cameras of the same brand and model.

Returns -1 if the video capture device has no audio interface on the same USB device (PCI / PCIe capture cards, virtual cameras, webcams without microphone), if this audio interface is not listed in AudioDevices (e.g. microphone disabled in the Windows sound settings), and if VideoDeviceIndex is out of range.

The index is returned even when the device is unplugged: to know whether the audio capture device is currently plugged in, use IsAudioDeviceConnected.

E.g. to record the video and the audio of the webcam i: VideoDevice := i; AudioDevice := AudioDeviceIndexFromVideoDevice (i); AudioRecording := AudioDevice >= 0.

When AudioDevice = -1 and the audio is recorded or rendered, the audio capture device of the current video capture device is selected automatically when the preview or the recording starts.

See the Audio capture devices chapter for more information.