ShayBox / Mon2Cam

Workaround for multi-monitor Discord screensharing
MIT License
338 stars 33 forks source link

Sound not working on Ubuntu 20.04 (with pulseaudio) #77

Open tprei opened 3 years ago

tprei commented 3 years ago

Hey everyone, I want to use the sound feature but it doesn't seem to be working. When it asks for applications to route none of them seem to work, it always throws the same error.

mon2cam -f 60 -r 1920:1080 -s -v

DEBUG Starting Mon2Cam with the following options: Options {
  hwEncoder: undefined,
  framerate: 60,
  device: 50,
  monitor: undefined,
  resolution: "1920:1080",
  verboseFile: undefined,
  ffmpeg: [],
  border: false,
  sound: true,
  wayland: false,
  loggerOptions: { verbose: true },
  execOptions: { verbose: true, output: 3 }
}
DEBUG Checking if V4L2 device exists
DEBUG V4L2 device found with id 50

Exec Context: ce6acb10-637c-4f5a-9367-85e2d448433e
    Exec Options:  { verbose: true, output: 3 }
    Exec Command: pactl list sink-inputs
    Exec Command Splits:  [pactl,list,sink-inputs]
    Exec Result:  { code: 0, success: true },
 output: "Sink Input #25
    Driver: module-ladspa-sink.c
    Owner Module: 30
    Client: n/a
    Sink: 3
    Sample Specification: float32le 2ch 48000Hz
    Channel Map: front-left,front-right
    Format: pcm, format.sample_format = "\"float32le\""  format.rate = "48000"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
    Corked: no
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Buffer Latency: 0 usec
    Sink Latency: 1449 usec
    Resample method: copy
    Properties:
        media.name = "LADSPA Stream"
        media.role = "filter"
        module-stream-restore.id = "sink-input-by-media-role:filter"

Sink Input #26
    Driver: module-loopback.c
    Owner Module: 31
    Client: n/a
    Sink: 4
    Sample Specification: s16le 1ch 44086Hz
    Channel Map: mono
    Format: pcm, format.sample_format = "\"s16le\""  format.rate = "44100"  format.channels = "1"  format.channel_map = "\"mono\""
    Corked: no
    Mute: no
    Volume: mono: 65536 / 100% / 0,00 dB
            balance 0,00
    Buffer Latency: 18506 usec
    Sink Latency: 1429 usec
    Resample method: speex-float-1
    Properties:
        media.role = "abstract"
        module-stream-restore.id = "sink-input-by-media-role:abstract"
        media.name = "Loopback from Usb Audio Device Mono"
        media.icon_name = "audio-card-usb"

Sink Input #59
    Driver: protocol-native.c
    Owner Module: 13
    Client: 86
    Sink: 1
    Sample Specification: float32le 2ch 44100Hz
    Channel Map: front-left,front-right
    Format: pcm, format.sample_format = "\"float32le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
    Corked: yes
    Mute: no
    Volume: front-left: 30301 /  46% / -20,10 dB,   front-right: 30301 /  46% / -20,10 dB
            balance 0,00
    Buffer Latency: 2000680 usec
    Sink Latency: 100813 usec
    Resample method: copy
    Properties:
        media.role = "music"
        media.name = "Spotify"
        application.name = "Spotify"
        native-protocol.peer = "UNIX socket client"
        native-protocol.version = "33"
        application.process.id = "288524"
        application.process.user = "preischadt"
        application.process.host = "prschdt"
        application.process.binary = "spotify"
        application.language = "en_US.UTF-8"
        window.x11.display = ":0"
        application.process.machine_id = "cbeafece9dea4b8f8ad49097943f1e2f"
        application.icon_name = "spotify-client"
        module-stream-restore.id = "sink-input-by-media-role:music"

Sink Input #132
    Driver: protocol-native.c
    Owner Module: 13
    Client: 58
    Sink: 1
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Format: pcm, format.sample_format = "\"s16le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
    Corked: no
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Buffer Latency: 100702 usec
    Sink Latency: 100850 usec
    Resample method: n/a
    Properties:
        media.name = "playStream"
        application.name = "WEBRTC VoiceEngine"
        native-protocol.peer = "UNIX socket client"
        native-protocol.version = "33"
        application.process.id = "204586"
        application.process.user = "preischadt"
        application.process.host = "prschdt"
        application.process.binary = "Discord"
        application.language = "en_US.UTF-8"
        window.x11.display = ":0"
        application.process.machine_id = "cbeafece9dea4b8f8ad49097943f1e2f"
        module-stream-restore.id = "sink-input-by-application-name:WEBRTC VoiceEngine"

Sink Input #167
    Driver: protocol-native.c
    Owner Module: 13
    Client: 209
    Sink: 1
    Sample Specification: float32le 2ch 44100Hz
    Channel Map: front-left,front-right
    Format: pcm, format.sample_format = "\"float32le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
    Corked: no
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Buffer Latency: 115351 usec
    Sink Latency: 100848 usec
    Resample method: copy
    Properties:
        application.icon_name = "google-chrome"
        media.name = "Playback"
        application.name = "Google Chrome"
        native-protocol.peer = "UNIX socket client"
        native-protocol.version = "33"
        application.process.id = "11112"
        application.process.user = "preischadt"
        application.process.host = "prschdt"
        application.process.binary = "chrome"
        application.language = "en_US.UTF-8"
        window.x11.display = ":0"
        application.process.machine_id = "cbeafece9dea4b8f8ad49097943f1e2f"
        module-stream-restore.id = "sink-input-by-application-name:Google Chrome""
Exec Context: ce6acb10-637c-4f5a-9367-85e2d448433e

59: Spotify
132: WEBRTC VoiceEngine
167: Google Chrome
Choose which applications you want to route(space separated list):
167

Exec Context: ec91d747-dcd0-4e47-ae77-1c3d706f9156
    Exec Options:  { verbose: true, output: 3 }
    Exec Command: pactl list sources
    Exec Command Splits:  [pactl,list,sources]
    Exec Result:  { code: 0, success: true },
 output: "Source #0
    State: RUNNING
    Name: alsa_input.usb-Generalplus_Usb_Audio_Device_13662631792-00.mono-fallback
    Description: Usb Audio Device Mono
    Driver: module-alsa-card.c
    Sample Specification: s16le 1ch 44100Hz
    Channel Map: mono
    Owner Module: 7
    Mute: no
    Volume: mono: 47569 /  73% / -8,35 dB
            balance 0,00
    Base Volume: 18471 /  28% / -33,00 dB
    Monitor of Sink: n/a
    Latency: 0 usec, configured 8000 usec
    Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
    Properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "USB Audio"
        alsa.id = "USB Audio"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "1"
        alsa.card_name = "Usb Audio Device"
        alsa.long_card_name = "Generalplus Usb Audio Device at usb-0000:02:00.0-1, full speed"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:02:00.0-usb-0:1:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-1/1-1:1.0/sound/card1"
        udev.id = "usb-Generalplus_Usb_Audio_Device_13662631792-00"
        device.bus = "usb"
        device.vendor.id = "1b3f"
        device.vendor.name = "Generalplus Technology Inc."
        device.product.id = "2008"
        device.product.name = "Usb Audio Device"
        device.serial = "Generalplus_Usb_Audio_Device_13662631792"
        device.string = "hw:1"
        device.buffering.buffer_size = "176400"
        device.buffering.fragment_size = "88200"
        device.access_mode = "mmap+timer"
        device.profile.name = "mono-fallback"
        device.profile.description = "Mono"
        device.description = "Usb Audio Device Mono"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-usb"
    Ports:
        analog-input-mic: Microphone (priority: 8700)
    Active Port: analog-input-mic
    Formats:
        pcm

Source #2
    State: IDLE
    Name: alsa_output.pci-0000_09_00.3.analog-stereo.monitor
    Description: Monitor of Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 28
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Base Volume: 65536 / 100% / 0,00 dB
    Monitor of Sink: alsa_output.pci-0000_09_00.3.analog-stereo
    Latency: 0 usec, configured 100136 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.description = "Monitor of Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo"
        device.class = "monitor"
        alsa.card = "2"
        alsa.card_name = "HD-Audio Generic"
        alsa.long_card_name = "HD-Audio Generic at 0xfe700000 irq 89"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:09:00.3"
        sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:09:00.3/sound/card2"
        device.bus = "pci"
        device.vendor.id = "1022"
        device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
        device.product.id = "1457"
        device.product.name = "Family 17h (Models 00h-0fh) HD Audio Controller"
        device.string = "2"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    Formats:
        pcm

Source #3
    State: SUSPENDED
    Name: alsa_output.pci-0000_07_00.1.hdmi-stereo-extra4.monitor
    Description: Monitor of Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 5)
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 9
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Base Volume: 65536 / 100% / 0,00 dB
    Monitor of Sink: alsa_output.pci-0000_07_00.1.hdmi-stereo-extra4
    Latency: 0 usec, configured 0 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.description = "Monitor of Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 5)"
        device.class = "monitor"
        alsa.card = "0"
        alsa.card_name = "HDA ATI HDMI"
        alsa.long_card_name = "HDA ATI HDMI at 0xfe860000 irq 87"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:07:00.1"
        sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:07:00.1/sound/card0"
        device.bus = "pci"
        device.vendor.id = "1002"
        device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
        device.product.id = "aaf0"
        device.product.name = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]"
        device.string = "0"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    Formats:
        pcm

Source #4
    State: RUNNING
    Name: nui_mic_denoised_out.monitor
    Description: Monitor of Null Output
    Driver: module-null-sink.c
    Sample Specification: s16le 2ch 48000Hz
    Channel Map: front-left,front-right
    Owner Module: 29
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Base Volume: 65536 / 100% / 0,00 dB
    Monitor of Sink: nui_mic_denoised_out
    Latency: 0 usec, configured 30000 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.description = "Monitor of Null Output"
        device.class = "monitor"
        device.icon_name = "audio-input-microphone"
    Formats:
        pcm

Source #5
    State: IDLE
    Name: nui_mic_raw_in.monitor
    Description: Monitor of LADSPA Plugin NoiseTorch rnnoise ladspa module on Null Output
    Driver: module-ladspa-sink.c
    Sample Specification: float32le 2ch 48000Hz
    Channel Map: front-left,front-right
    Owner Module: 30
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Base Volume: 65536 / 100% / 0,00 dB
    Monitor of Sink: nui_mic_raw_in
    Latency: 0 usec, configured 2000000 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.description = "Monitor of LADSPA Plugin NoiseTorch rnnoise ladspa module on Null Output"
        device.class = "monitor"
        device.icon_name = "audio-input-microphone"
    Formats:
        pcm

Source #6
    State: RUNNING
    Name: nui_mic_remap
    Description: NoiseTorch Microphone
    Driver: module-remap-source.c
    Sample Specification: s16le 2ch 48000Hz
    Channel Map: front-left,front-right
    Owner Module: 32
    Mute: no
    Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    Base Volume: 65536 / 100% / 0,00 dB
    Monitor of Sink: n/a
    Latency: 0 usec, configured 30000 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.master_device = "nui_mic_denoised_out.monitor"
        device.class = "filter"
        device.description = "NoiseTorch Microphone"
        device.icon_name = "audio-input-microphone"
    Formats:
        pcm"
Exec Context: ec91d747-dcd0-4e47-ae77-1c3d706f9156

ParsedOutputElement { index: -1, arguments: {}, properties: {} }
ParsedOutputElement {
  index: 2,
  arguments: {
    State: "IDLE",
    Name: "alsa_output.pci-0000_09_00.3.analog-stereo.monitor",
    Description: "Monitor of Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo",
    Driver: "module-alsa-card.c",
    "Sample Specification": "s16le 2ch 44100Hz",
    "Channel Map": "front-left,front-right",
    "Owner Module": "28",
    Mute: "no",
    Volume: "front-left",
    "Base Volume": "65536 / 100% / 0,00 dB",
    "Monitor of Sink": "alsa_output.pci-0000_09_00.3.analog-stereo",
    Latency: "0 usec, configured 100136 usec"
  },
  properties: {
    "device.description": '"Monitor of Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo"',
    "device.class": '"monitor"',
    "alsa.card": '"2"',
    "alsa.card_name": '"HD-Audio Generic"',
    "alsa.long_card_name": '"HD-Audio Generic at 0xfe700000 irq 89"',
    "alsa.driver_name": '"snd_hda_intel"',
    "device.bus_path": '"pci-0000:09:00.3"',
    "sysfs.path": '"/devices/pci0000:00/0000:00:08.1/0000:09:00.3/sound/card2"',
    "device.bus": '"pci"',
    "device.vendor.id": '"1022"',
    "device.vendor.name": '"Advanced Micro Devices, Inc. [AMD]"',
    "device.product.id": '"1457"',
    "device.product.name": '"Family 17h (Models 00h-0fh) HD Audio Controller"',
    "device.string": '"2"',
    "module-udev-detect.discovered": '"1"',
    "device.icon_name": '"audio-card-pci"'
  }
}
ParsedOutputElement {
  index: 3,
  arguments: {
    State: "SUSPENDED",
    Name: "alsa_output.pci-0000_07_00.1.hdmi-stereo-extra4.monitor",
    Description: "Monitor of Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 5)",
    Driver: "module-alsa-card.c",
    "Sample Specification": "s16le 2ch 44100Hz",
    "Channel Map": "front-left,front-right",
    "Owner Module": "9",
    Mute: "no",
    Volume: "front-left",
    "Base Volume": "65536 / 100% / 0,00 dB",
    "Monitor of Sink": "alsa_output.pci-0000_07_00.1.hdmi-stereo-extra4",
    Latency: "0 usec, configured 0 usec"
  },
  properties: {
    "device.description": '"Monitor of Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 5)"',
    "device.class": '"monitor"',
    "alsa.card": '"0"',
    "alsa.card_name": '"HDA ATI HDMI"',
    "alsa.long_card_name": '"HDA ATI HDMI at 0xfe860000 irq 87"',
    "alsa.driver_name": '"snd_hda_intel"',
    "device.bus_path": '"pci-0000:07:00.1"',
    "sysfs.path": '"/devices/pci0000:00/0000:00:03.1/0000:07:00.1/sound/card0"',
    "device.bus": '"pci"',
    "device.vendor.id": '"1002"',
    "device.vendor.name": '"Advanced Micro Devices, Inc. [AMD/ATI]"',
    "device.product.id": '"aaf0"',
    "device.product.name": '"Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]"',
    "device.string": '"0"',
    "module-udev-detect.discovered": '"1"',
    "device.icon_name": '"audio-card-pci"'
  }
}
ParsedOutputElement {
  index: 4,
  arguments: {
    State: "RUNNING",
    Name: "nui_mic_denoised_out.monitor",
    Description: "Monitor of Null Output",
    Driver: "module-null-sink.c",
    "Sample Specification": "s16le 2ch 48000Hz",
    "Channel Map": "front-left,front-right",
    "Owner Module": "29",
    Mute: "no",
    Volume: "front-left",
    "Base Volume": "65536 / 100% / 0,00 dB",
    "Monitor of Sink": "nui_mic_denoised_out",
    Latency: "0 usec, configured 30000 usec"
  },
  properties: {
    "device.description": '"Monitor of Null Output"',
    "device.class": '"monitor"',
    "device.icon_name": '"audio-input-microphone"'
  }
}
ParsedOutputElement {
  index: 5,
  arguments: {
    State: "IDLE",
    Name: "nui_mic_raw_in.monitor",
    Description: "Monitor of LADSPA Plugin NoiseTorch rnnoise ladspa module on Null Output",
    Driver: "module-ladspa-sink.c",
    "Sample Specification": "float32le 2ch 48000Hz",
    "Channel Map": "front-left,front-right",
    "Owner Module": "30",
    Mute: "no",
    Volume: "front-left",
    "Base Volume": "65536 / 100% / 0,00 dB",
    "Monitor of Sink": "nui_mic_raw_in",
    Latency: "0 usec, configured 2000000 usec"
  },
  properties: {
    "device.description": '"Monitor of LADSPA Plugin NoiseTorch rnnoise ladspa module on Null Output"',
    "device.class": '"monitor"',
    "device.icon_name": '"audio-input-microphone"'
  }
}
ParsedOutputElement {
  index: 6,
  arguments: {
    State: "RUNNING",
    Name: "nui_mic_remap",
    Description: "NoiseTorch Microphone",
    Driver: "module-remap-source.c",
    "Sample Specification": "s16le 2ch 48000Hz",
    "Channel Map": "front-left,front-right",
    "Owner Module": "32",
    Mute: "no",
    Volume: "front-left",
    "Base Volume": "65536 / 100% / 0,00 dB",
    "Monitor of Sink": "n/a",
    Latency: "0 usec, configured 30000 usec"
  },
  properties: {
    "device.master_device": '"nui_mic_denoised_out.monitor"',
    "device.class": '"filter"',
    "device.description": '"NoiseTorch Microphone"',
    "device.icon_name": '"audio-input-microphone"'
  }
}
error: Uncaught (in promise) TypeError: Cannot read property 'replace' of undefined
                    let source_name = source.properties["device.product.name"].replace(/"/g, "");
                                                                               ^
    at https://raw.githubusercontent.com/ShayBox/Mon2Cam/master/src/backends/audio.ts:289:65
    at Array.forEach (<anonymous>)
    at https://raw.githubusercontent.com/ShayBox/Mon2Cam/master/src/backends/audio.ts:288:18