The accepted answer did not work for me. Here's what did.
The problem is you're missing the v4l2 library, or Video4Linux2. But you can't install v4l2, because you're missing the kernel headers for your linux version. Now if you're like me you're wondering, shouldn't something called "kernel headers" come preinstalled? That is a great question. I don't know the answer.
1. Install from PPA
First, you need to have installed OBS from the PPA. Uninstall whatever OBS you're running (remove and purge as required by your package manger) and install thus:
sudo apt-add-repository ppa:obsproject/obs-studio
sudo apt-get update
sudo apt-get install ffmpeg obs-studio
(OBS needs ffmpeg
, so don't miss this)
2. Install Kernel Headers
Next, install your kernel headers. To find your kernel headers, run:
apt search linux-headers-$(uname -r)
In my case, the output looked like this
Sorting... Done
Full Text Search... Done
linux-headers-5.19.0-76051900-generic/jammy 5.19.0-76051900.202207312230~1663791054~22.04~28340d4 amd64 [upgradable from: 5.19.0-76051900.202207312230~1660780566~22.04~9d60db1]
Linux kernel headers for version 5.19.0 on 64 bit x86 SMP
In my case, my headers are called linux-headers-5.19.0-76051900-generic So:
sudo apt install <your headers>
3. Install v4l2
Then you can install the library
sudo apt install v4l-utils v4l2loopback-utils v4l2loopback-dkms
4. Test
Reboot and open OBS. You should see the virtual camera button appear. Click the button and look for the virtual camera in wherever source you're streaming to.
sudo obs
at least made the error messages visible, and searching on the error messages led me to a guide on disabling secure boot to enable modprobe: askubuntu.com/a/1198351/652. And that worked. So thanks, @AnkurASharma.