Skip to content

Instantly share code, notes, and snippets.

@stuaxo
Last active April 23, 2025 01:20
Show Gist options
  • Save stuaxo/6f45a46a22a5301faf424b5be5ddd08c to your computer and use it in GitHub Desktop.
Save stuaxo/6f45a46a22a5301faf424b5be5ddd08c to your computer and use it in GitHub Desktop.
V4L2 from SCRCPY

Packages needed

$ sudo apt install v4l2loopback-dkms v4l2loopback-utils

Create virtual device

$ sudo modprobe -v v4l2loopback exclusive_caps=1 card_label="Virtual Webcam"

Another example -

Create 4 virtual devices, starting at /dev/video10

$ sudo modprobe -v v4l2loopback exclusive_caps=1 card_label="Virtual Webcam 1,Virtual Webcam 2,Virtual Webcam 3,Virtual Webcam 4" devices=4 nr=10
$ sudo modprobe v4l2-loopback

List cameras

$ scrcpy --list-cameras
$ scrcpy --video-source=camera --no-audio --camera-facing=back \
    --v4l2-sink=/dev/video2

Then open OBS and add V4L2 source.

Links

https://adityatelange.in/blog/android-phone-webcam-linux/

Packages and setup, needed from here https://gist.github.com/cadadr/64df554935c6fd50aa45428b4e5e4a11

Notes:

Running a camera on Android, then capturing the Window is not needed. Running a webcam on Android then forwaerding is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment