A systemd user service that waits for an Android phone to be plugged in over USB, then uses
scrcpy to stream the phone's camera into a
v4l2loopback device (/dev/video0). Any app
(Meet, Zoom, OBS, browser) then sees it as a normal webcam. Unplug the phone and the service goes back
to waiting; plug it in again and the camera comes back on its own.
phone (USB, adb) --scrcpy --video-source=camera--> /dev/video0 (v4l2loopback) --> any webcam app
ExecStartPre=adb wait-for-usb-deviceblocks until a phone is connected (TimeoutStartSec=infinity).scrcpyexits when the phone is unplugged;Restart=alwaysputs the service back into waiting.StartLimitIntervalSec=0stops systemd from giving up after repeated restarts.
sudo pacman -S scrcpy android-tools v4l2loopback-dkms v4l2loopback-utils linux-headers(Debian/Ubuntu: sudo apt install scrcpy adb v4l2loopback-dkms v4l2loopback-utils. Camera
mirroring needs scrcpy ≥ 2.2 and Android 12+.)
Load the module at boot (/etc/modules-load.d/v4l2loopback.conf):
v4l2loopback
Module options (/etc/modprobe.d/v4l2loopback.conf):
options v4l2loopback devices=2 video_nr=0,10 card_label="Phone Camera","AI Camera" exclusive_caps=1,1
video_nr=0puts the phone feed at/dev/video0(the second device,/dev/video10, is a spare for a processed feed; usedevices=1 video_nr=0 card_label="Phone Camera" exclusive_caps=1if you only need one).exclusive_caps=1is required for Chrome/WebRTC apps to list the device as a camera.
Apply without rebooting:
sudo modprobe -r v4l2loopback; sudo modprobe v4l2loopback
v4l2-ctl --list-devices # should show "Phone Camera (platform:v4l2loopback-000): /dev/video0"- Settings → About phone → tap Build number 7× to enable Developer options.
- Developer options → enable USB debugging.
- Plug it in, run
adb devices, and accept the "Allow USB debugging" prompt (tick Always allow). - Test manually:
scrcpy --list-cameras scrcpy --video-source=camera --camera-facing=back --v4l2-sink=/dev/video0 --no-window
mkdir -p ~/.config/systemd/user
cp phonecam.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now phonecam.serviceCheck / debug:
systemctl --user status phonecam # "activating (start-pre)" = waiting for the phone
journalctl --user -u phonecam -fAdjust adb's path in ExecStartPre if it isn't /usr/bin/adb (e.g. /opt/android-sdk/platform-tools/adb).
| Flag | What it does |
|---|---|
--camera-facing=back|front |
which camera |
--camera-size=1920x1080 |
resolution (see scrcpy --list-camera-sizes) |
--camera-zoom=2 |
zoom factor (scrcpy ≥ 3.x) |
--no-window --no-control --no-audio |
headless: video only into the loopback device |
-d |
use the USB device (not a TCP/IP one) |
- Phone shows up as "unauthorized" → re-accept the USB debugging prompt on the phone.
- App doesn't list the camera → check
exclusive_caps=1, and that nothing else is writing to/dev/video0. - Screen lock on the phone doesn't stop the camera feed, but some vendors kill background camera use: keep the phone unlocked if the feed freezes.