Skip to content

Instantly share code, notes, and snippets.

@GroverChouT
Last active May 26, 2022 12:18
Show Gist options
  • Save GroverChouT/7b50531b21cbe0efe751a28dcc95133d to your computer and use it in GitHub Desktop.
Save GroverChouT/7b50531b21cbe0efe751a28dcc95133d to your computer and use it in GitHub Desktop.

V4L2 Loopback and DroidCam

On openSUSE Tumbleweed, you need to install droidcam and v4l2loopback-kmp-default (should be selected automatically). In addition, you may need to install v4l2loopback-utils to have some useful commands.

However, v4l2loopback-autoload may also be installed, which comes with a default module option to provide the Virtual Camera functionality of obs-studio. We need to uninstall this package and better add a lock on it.

sudo zypper rm v4l2loopback-autoload
sudo zypper al v4l2loopback-autoload

Then we need to create the following files to use our module options.

# /etc/modules-load.d/v4l2loopback.conf  
v4l2loopback

# /etc/modprobe.d/v4l2loopback.conf 
options v4l2loopback devices=2 exclusive_caps=1,1 card_label="OBS Virtual Camera,DroidCam"

After that, you need to reload your module and create your initramfs:

sudo modprobe -r v4l2loopback
sudo modprobe v4l2loopback
sudo dracut -f

It create two loopback devices: /dev/video0 and /dev/video1 (by default, obs-studio takes /dev/video0). You can check it's information by use this command:

v4l2-ctl --info --device /dev/video0
v4l2-ctl --list-formats-ext --device /dev/video0

To launch droidcam, use this command:

droidcam -dev=/dev/video1 -size=1920x1080

You can edit your application property to avoid using terminal.

To check your camera, you may use mpv or other player.

mpv --profile=low-latency --untimed av://v4l2:/dev/video0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment