Tips and Tricks
Using your phone as a webcam
There are various ways to use your phone as a webcam. This guide shows you how to use scrcpy on Linux to accomplish that without the need for droidcam or OBS.
Requirements
- Linux
- Android 12 or Higher
Download and Install Scrcpy
Ubuntu/Debian:
bashsudo apt install scrcpyArchlinux:
bashsudo pacman -S scrcpyFedora:
bashsudo dnf copr enable zeno/scrcpy && sudo dnf install scrcpySnap:
bashsnap install scrcpy
Setup Video4Linux (v4l2loopback)
Install the Kernel module:
Ubuntu/Debian:
bashsudo apt install v4l2loopback-dkmsArchlinux:
bashsudo pacman -S v4l2loopback-dkmsFedora:
bashsudo dnf copr enable rothgar/v4l2loopback && sudo dnf install v4l2loopback-dkmsSnap:
Not Applicable; follow distro-specific instructions to install the kernel module.
Then load the Kernel module:
bashsudo modprobe v4l2loopback-dkmsor
bashsudo modprobe v4l2loopback
Run Scrcpy
After you've installed everything, run this to get the device created by v4l2loopback:
bashls /dev/video*Now that you have that device, you can finally run scrcpy:
bashscrcpy --v4l2-sink=/dev/video<insert device number here> --camera-ar=sensor --video-source=camera --camera-facing=<insert front or back here> --no-video-playback
Use your new webcam
Test your webcam:
bashffplay -i /dev/video<insert device number here> or vlc v4l2:///dev/video<insert device number here>Normal Use: Open any web browser and visit https://webcamtests.com/ to confirm it works on a web browser too
Debugging
Doesn't start:
If you face this error:
log[server] ERROR: Capture/encoding error: java.io.IOException: android.hardware.camera2.CameraAccessException: The camera device is currently in the error state; no further calls to it will succeed.Append this to the
scrcpycommand:-m2560
Doesn't work with Chromium based browser:
Try loading the module in exclusive_caps mode:
bashsudo modprobe v4l2loopback-dkms exclusive_caps=1or
bashsudo modprobe v4l2loopback exclusive_caps=1