How to record two audio inputs and one video input?

221 Views Asked by At

I am trying to record two audio input (webcam + microphone) and one video input (webcam) via MediaCapture from C#. Just 1 audio and 1 video input works like a charm but the class itself does not allow to specify two audio input device ids.

An example:

var captureDeviceSettings = new MediaCaptureInitializationSettings
{
 VideoDeviceId = videoDeviceId, #Webcam video input
 AudioDeviceId = audioDeviceId, #Webcam audio input
 StreamingCaptureMode = StreamingCaptureMode.AudioAndVideo,
}

I thought about using audio graph and using a submix node but, I need to specify a device ID for the media capture, the submix node does not give that. Further on, using the output device of audio graph seems not like the solution, I do not want to play microphone to default output device. Tried that but sounds horrible. I thought about creating a virtual audio device but I don't know how.

Any suggestions on that?

1

There are 1 best solutions below

1
dear_vv On

MediaCapture won't be able to do this, WASAPI maybe possibile, but it is not trivial to do.

Best option may be to utilize https://learn.microsoft.com/en-us/windows/win32/coreaudio/loopback-recording. You will still have to mux in video stream though if you get loopback recording to work.