obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

Linux: virtual audio support via ALSA Loopback card

Open aramg opened this issue 2 years ago • 0 comments

NOTE: This PR includes the changes in #8008, which is expected to get merged first.

Description

Adds virtual audio support via the ALSA loopback module, snd_aloop. As implemented, audio is optional and the virtualcam depends on v4l2loopback still. snd_aloop is not auto-loaded and an audio-only mode is not available.

Motivation and Context

Allows sharing audio output with other programs as a virtual microphone.

How Has This Been Tested?

  1. Load the loopback modules: modprobe v4l2loopback modprobe snd-aloop
  2. Start OBS and click [Start Virtual Cam]. Both audio and video are activated:
info: v4l2-output: Using device 'Dummy video device (0x0000)' at '/dev/video0'
info: ALSA output: hw:Loopback,1,0
info: Virtual camera starting: audio=1 video=1
  1. Add a media source, and observe video output as before (in this case, via '/dev/video0' **).
  2. Record audio: arecord -D hw:Loopback,1,0 --duration=30 -fS16_LE -c2 -r48000 /tmp/test.pcm
  3. Replay audio: aplay -fS16_LE -c2 -r48000 /tmp/test.pcm
  4. This varies by distro, but to load the device into PluseAudio: pacmd load-module module-alsa-source source_properties=device.description=OBS device=hw:Loopback,1,0

** ideally the audio and video device names will be added to the OBS status bar, a to-do.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [ ] I have included updates to all appropriate documentation.

aramg avatar Jan 29 '23 09:01 aramg