Chromium and Chrome refus to list or capture monitor devices on Linux
- Issue 931749: DOMException: could not start audio source when trying to access audioinput
- Issue 1155954: Add --allow-monitor-inputs flag
- Issue 865799 in chromium: A way for enumerateDevices() to show audiooutput devices with labels when user has no cam or mic
Virtual microphone using GStreamer and PulseAudio includes a section that describes a workaround using PulseAudio to create a virtual microphone where the source is a monitor device
While the null sink automatically includes a "monitor" source, many programs know to exclude monitors when listing microphones. To work around that, the module-remap-source module lets us clone that source to another one not labeled as being a monitor:
pactl load-module module-remap-source \master=virtmic.monitor source_name=virtmic \source_properties=device.description=Virtual_Microphone
After we run
$ pactl load-module module-remap-source master="$(pactl list | grep -A2 '^Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)" source_name=virtmic source_properties=device.description=Virtual_Microphone
we can call navigator.mediaDevices.getUserMedia({audio: true}) to get permission to access device labels, filter the devices from navigator.mediaDevices.enumerateDevices() to get the device 'Virtual_Microphone' then call
navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact: deviceId}}}) again, deviceId is the deviceId of 'Virtual_Microphone' with the source of theat virtual microphone set to the monitor device that we want to capture.
Yes. https://github.com/guest271314/AudioWorkletStream.
To unambiguously set the exact
deviceIdhttps://w3c.github.io/mediacapture-main/#constrainable-properties. Monitor devices are not listed by default on Chromium on Linux. We are sure to not get the 'Default' device, or other microphone.What is the result of your test?
Note, I have found using a
Blobto store data to be far faster than usingArray.prototype.reduce(), see https://bugs.chromium.org/p/chromium/issues/detail?id=1260519.