1

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?

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
  • It isn't easy to talk to two audio devices at the same time, but someone says Audacity can do it (https://www.howtogeek.com/61037/how-to-record-from-multiple-audio-devices-simultaneously/). Keep in mind, though, these devices are running on different clocks, so even if you can have two different audio inputs you would have to do a lot of work synchronizing the signals. I imagine this is why the MediaCapture object doesn't allow this. You are better off using a single audio hardware device with multiple inputs, if that is possible. – dmedine Jul 13 '21 at 01:52
  • Thanks for the feedback! These two inputs do not need to be 100% in sync. One input is from a game (webcam), the other is just typical microphone from the gamer. Further on, the same type of application is no problem on MacOS with Swift. – GreenDragon Jul 13 '21 at 06:30
  • We are consulting other engineers about your issue, there might be some delay. – dear_vv Jul 14 '21 at 02:24

1 Answers1

0

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.

dear_vv
  • 2,350
  • 1
  • 4
  • 13