dimtpap / obs-pipewire-audio-capture

🔊 Audio device and application capture for OBS Studio using PipeWire
https://obsproject.com/forum/resources/pipewire-audio-capture.1458/
GNU General Public License v2.0
377 stars 12 forks source link

Virtual sinks are not working #74

Open sfjuocekr opened 1 month ago

sfjuocekr commented 1 month ago

When using a virtual sink, pipewire.conf.d/virtualsink.conf:

context.modules = [
   { name = libpipewire-module-loopback
     args = {
        node.description = "MicSolo"
        capture.props = {
           node.name = "MicSolo_capture"
           media.class = "Audio/Sink"
           audio.position = [ MONO ]
        }
        playback.props = {
           node.name = "MicSolo_playback"
           media.class = "Audio/Source"
           audio.position = [ MONO ]
        }
     }
   }
]

Virtual sinks are shown, but when I try to select one and press the OK button it reverts back to the "Default".

dimtpap commented 1 month ago

Add audio.channels = 1 in the properties

stephematician commented 2 weeks ago

Thanks @dimtpap - I had a similar problem using the loopback module with a virtual source.

In my example, I was forwarding the front-left channel from my audio interface to a mono virtual source. Without audio.channels=1, the virtual source would not work in the obs plugin.

The output before I set audio.channels=1 was:

# select the virtual (microphone) source in OBS...
debug: [pipewire] Stream 0x12345678abcd state: "paused" (error: none)
debug: [pipewire] Stream 0x12345678abcd state: "unconnected" (error: none)

So there was no attempt to connect to the device. Once it was working, I would see:

# select the virtual (microphone) source in OBS...
debug: [pipewire] Stream 0x12345678abcd state: "paused" (error: none)
debug: [pipewire] Stream 0x12345678abcd state: "unconnected" (error: none)
debug: [pipewire] Stream 0x12345678abcd state: "connecting" (error: none)
info: [pipewire] 0x12345678abcd streaming from 46
debug: [pipewire] Stream 0x12345678abcd state: "paused" (error: none)
info: [pipewire] 0x12345678abcd Got format: rate 48000 - channels 1 - format 8
debug: [pipewire] Stream 0x12345678abcd state: "streaming" (error: none)

Here is a functional virtual source configuration ~/.config/pipewire/virtual-umc-mono-microphone.conf:

context.modules = [
{   name = libpipewire-module-loopback
    args = {
        node.description = "Virtual UMC202HD mono microphone"
        capture.props = {
            audio.position = [ FR ]
            stream.dont-remix = true
            target.object = "alsa_input.usb-BEHRINGER_UMC202HD_192k_12345678-00.analog-stereo"
            node.passive = true
        }
        playback.props = {
            node.name = "virtual_input.BEHRINGER_UMC202HD_192k_12345678-00.mono"
            media.class = "Audio/Source"
            node.nick = "Virtual UMC202HD 192k MONO microphone"
            audio.position = [ MONO ]
            audio.channels = 1
        }
    }
}
]

Should the number of channels be inferred from audio.position if channels isn't supplied?

stephematician commented 2 weeks ago

This would require some change near: https://github.com/dimtpap/obs-pipewire-audio-capture/blob/d5d51d483065a7bf02ac9367683e5033ed837025/src/pipewire-audio-capture-device.c#L81