Using OBS Studio with V4L2 for making my videoconferences more appealing

3 minute read

Introduction

Nowadays, I’m doing more videoconferences, presentations and recording classes for my students using OBS (+ other software). When I find some time, I’m using a chroma background for my videos, so I considered to use the chroma for videoconferences and other online meetings.

There are many apps for doing this dinamically through the use of virtual webcams. In windows, we even could use Snapcam for adding special effects and in Ubuntu we could use Webcamoid for this. However, I wanted to do this using OBS because I would like to have more control over the scene, for example, I could show parts of my desktop or some slides without the need of sharing the screen.

My working environment includes and old laptop with Ubuntu 16.04 LTS, a PC with 18.04 LTS, and I use the following videoconferencing platforms.

  • For particular use:

    • Skype for Linux (ver. 8.59.0.77).
    • Hangout, working from firefox and chrome (I can’t share screen from firefox, but it’s my favourite web browser).
    • I recently met Jitsi Meet which works quite well too.
  • And for a more professional use:

    • Teams for Linux, with a paid account from my University. Webcam was not working with the desktop app, so now I’m working from Chrome web browser.
    • Zoom client for Linux version 3.5 (specifically 3.5.361976.0301), with a paid account from a conference I’m attending.

In this post I’m explaining how I’m working with OBS-studio as a virtual webcam. This way I’m able to use the same configurations, scenes and shortcuts I have created for my videotutorials.

Setting up the computer

Installing all the necessary packages for using this approach is not as straightforward as I would like but there is a lot of information arround to make it done.

This excelent post from srcco.de explains how to use this approach for using it with Google Meet, while Justin Warren makes a more detailed post explaining How To Use OBS Studio With Zoom.

After reading this and other references that I attach at the end of this post, I installed everything using the following commands:

# APT install basics
sudo apt-get install obs-studio
sudo apt install v4l2loopback-dkms
sudo apt install qtbase5-dev

sudo apt-get install libobs-dev      # In Ubuntu Bionic Beaver (18.04)
#sudo apt-get install liboobs-1-dev   # In Ubuntu Xenial (16.04)

# Build plugin
git clone --recursive https://github.com/obsproject/obs-studio.git
git clone https://github.com/CatxFish/obs-v4l2sink.git
cd obs-v4l2sink
mkdir build && cd build
cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install

I’m not sure if we still need the sources for libobs after installing the repository from APT. Another problem is that the plugins are not installed in the correct directory. Probably, we could provide a parameter to the make install command but I ended up doing as most of people do things:

cp /usr/lib/obs-plugins/v4l2sink.so /usr/lib/x86_64-linux-gnu/obs-plugins/

If you are installing obs-v4l2sink for the first time, maybe you can answer my doubts and remove unnecessary installation steps.

Starting a session with a virtual camera

# Removing previous devices
sudo modprobe -r v4l2loopback

# Creating a new device with #10 id
sudo modprobe v4l2loopback video_nr=10 card_label="OBS Video Source" exclusive_caps=1

Now, I’m ready to start OBS and connect the webcam. Sometimes it will be necessary to check the obs-v4l2sink plugin. Go to Tools > V42L Video Output

I let the autostart off because… This is necessary when changing videoconferencing platform, because each platform may accept different video input formats. For example, I have tested these in my computer:

YUV420: Hangout, Zoom

YUV2: Skype, Yitsi

Are there any problems?

I found the answer here or at least I can start the process from zero.

It can be done by removing the v4l2loopback module:

sudo modprobe -r v4l2loopback

and then we can check that all the virtual devices are gone

ls -l /dev/video*

Final thoughts

This is an old draft I prepared during the first lockdown of the COVID pandemics (almost 1,5 years old). Problably there are better solutions for this now, because configuring OBS and virtual cameras before every videoconference was quite painful and I ended up showing my very tidy office when I work from home.

If I had an oportunity I would like to show you the usage in a short video. Another problem for using this approach is that you need a chroma screen in every location you need to do a videoconference, and that’s not very practical.

References