Files
tooling/streaming/obs-setup.org

147 lines
5.7 KiB
Org Mode

#+TITLE: Open broadcast studio setup
#+AUTHOR: James Blair
#+EMAIL: mail@jamesblair.net
#+DATE: 25th January 2022
I use [[https://obsproject.com][Open Broadcast Studio]] in Linux Mint to manage my audio and video devices for virtual meetings which drastically improves my video and audio quality. This page documents how I set up and the configuration I use.
Note: For audio hardware I generally rely on [[https://www.bluemic.com/en-us/products/yeti-nano/][Blue Yeti Nano]] microphones and [[https://electronics.sony.com/audio/headphones/headband/p/wh1000xm4-b][Sony WH-1000XM]] bluetooth headphones, for a camera I've recently moved to the [[https://www.logitech.com/en-au/products/webcams/brio-4k-hdr-webcam.960-001105.html][Logitech Brio 4k]].
* Install obs
To get started install obs including all dependencies required using the steps below:
#+NAME: Install open broadcast studio dependencies
#+begin_src tmate
# Install dependencies first
sudo apt install --yes ffmpeg v4l2loopback-dkms
# Load the v4l2loopback module for virtual cam
sudo modprobe v4l2loopback exclusive_caps=1
# Add package repository
sudo add-apt-repository ppa:obsproject/obs-studio
#+end_src
#+NAME: Install open broadcast studio
#+begin_src tmate
# Install open broadcast studio
sudo apt update && sudo apt install --yes obs-studio
#+end_src
* Install plugins
Before we get underway we also install the StreamFX plugin for OBS so we can blur backgrounds without a greenscreen. Follow the steps below to install the plugin:
#+NAME: Install streamfx plugin
#+begin_src tmate
# Ensure the plugin directory exists
mkdir --parents ~/.config/obs-studio && cd ~/.config/obs-studio
# Download latest plugin release archive from github
curl -s https://api.github.com/repos/Xaymar/obs-StreamFX/releases/latest \
| grep "browser_download_url.*zip" \
| grep "ubuntu" \
| grep -v "clang" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O streamfx.zip -i -
# Extract the archive then remove it
unzip -o streamfx.zip && rm streamfx.zip
#+end_src
* Setup virtual audio devices
To control improve the quality of our audio we use a virtual audio output device, this allows us to take raw audio input from a microphone, apply filters and enhancements in obs, then output the enhanced audio to the virtual meeting software as a virtual microphone.
#+NAME: Create virtual audio devices
#+begin_src tmate
# Create the virtual speaker
pactl load-module module-null-sink sink_name=Source sink_properties=device.description=VirtualSpeaker
# Check if we are on pulseaudio or pipewire and use appropriate module
audio_system_module="module-virtual-source"
if [[ "$(pactl info | grep -i "pipewire")" ]]; then audio_system_module="module-remap-source"; fi
# create the virtual microphone
pactl load-module "${audio_system_module}" source_name=VirtualMic master=Source.monitor source_properties=device.description=VirtualMic
#+end_src
The code snippet above sets up virtual audio devices for our current session only with ~pactl~, if we restart our machine or session those devices will no longer exist.
To make it permanent we need to save the configuration to a file in our home directory.
#+NAME: Save virtual audio device configuration
#+begin_src tmate
# Ensure required directory exists
mkdir --parents ~/.config/pulse
# Check if we are on pulseaudio or pipewire and use appropriate module
audio_system_module="module-virtual-source"
if [[ "$(pactl info | grep -i "pipewire")" ]]; then audio_system_module="module-remap-source"; fi
# Create configuration file
echo ".include /etc/pulse/default.pa" > ~/.config/pulse/default.pa
echo "load-module module-null-sink sink_name=Source sink_properties=device.description=VirtualSpeaker" >> ~/.config/pulse/default.pa
echo "load-module ${audio_system_module} source_name=VirtualMic master=Source.monitor source_properties=device.description=VirtualMic" >> ~/.config/pulse/default.pa
#+end_src
If all devices created successfully you should see them listed after running the code block below:
#+NAME: Check virtual audio devices
#+begin_src shell
pacmd list-modules | grep -i "VirtualSpeaker"
pacmd list-modules | grep -i "VirtualMic"
#+end_src
#+RESULTS: Check virtual audio devices
#+begin_example
argument: <sink_name=Source sink_properties=device.description=VirtualSpeaker>
argument: <source_name=VirtualMic master=Source.monitor source_properties=device.description=VirtualMic>
#+end_example
* Launch obs
Once obs is installed we can launch it with the command below. The setup wizard should open and you should see an option to optimize your configuration for using the Virtual Camera.
If you see that option, select it; once you get to the main OBS Studio screen, you should now see a button in the bottom right, "Start Virtual Camera".
#+NAME: Run open broadcast studio
#+begin_src tmate
obs&
#+end_src
* Configure obs scene
Our final step to get up and running is to restore our "Profile" and "Scene Collection" via the OBS *Profile > Import* and *Scene Collection > Import* menu options, using the [[./basic.ini][profile.ini]] and [[./scene.json][scene.json]] files included in this repository.
You can use the snippet below to check the contents of the files.
#+NAME: Show included configuration files
#+begin_src tmate
# Show contents of profile ini file
cat ~/Documents/tooling/streaming/basic.ini
# Show contents of scene collection json
cat ~/Documents/tooling/streaming/scene.json | jq
#+end_src
With the imports done you may need to revist the *Profile* and *Scene Collection* menus to ensure the right profile and scene collection are now selected. Once finished it should look like the image below:
#+CAPTION: Obs screenshot
#+NAME: fig:obs-screenshot
[[./obs.png]]
Congratulations, you should now have a robust obs configuration in place for video calling! :)