Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Additional information about Udev rules for virtual webcams. #4689

Open
1 task done
tkapias opened this issue Feb 20, 2024 · 0 comments
Open
1 task done

[Doc] Additional information about Udev rules for virtual webcams. #4689

tkapias opened this issue Feb 20, 2024 · 0 comments

Comments

@tkapias
Copy link

tkapias commented Feb 20, 2024

Issue

I use scrcpy as a virtual webcam with the new Video4Linux feature, but today I've noticed that some applications can't list the device I've created.

It seems that, awaiting Pipewire support, it's common to use the symlink /dev/v4l/by-id/ to list webcams.

This symlink is created by an existing udev rule in most distributions, but only for USB physical devices, not virtual ones.

Solution

I found the v4l2loopback issue #96 indicating to manually create another udev rule.

It works for me and I think that it might be useful to add this information to the doc.

Context

OS: Debian GNU/Linux trixie trixie/sid x86_64
Kernel: 6.6.13-amd64
WM: i3 (X11)
scrcpy: 2.3.1 https://github.com/Genymobile/scrcpy
Dependencies (compiled / linked):

  • SDL: 2.30.0 / 2.30.0
  • libavcodec: 60.31.102 / 60.31.102
  • libavformat: 60.16.100 / 60.16.100
  • libavutil: 58.29.100 / 58.29.100
  • libavdevice: 60.3.100 / 60.3.100
  • libusb: - / 1.0.27

Persistent v4l2loopback devices conf:

  • /etc/modules-load.d/v4l2loopback.conf
v4l2loopback
  • /etc/modprobe.d/v4l2loopback.conf
options v4l2loopback devices=2 exclusive_caps=1,1 video_nr=0,2 card_label=android-cam,fake-cam
  • /etc/udev/rules.d/60-persistent-v4l2loopback.rules
    The solution suggested above.
KERNEL=="video*", ATTR{max_openers}=="?*", SYMLINK+="v4l/by-id/v4l2loopback-$attr{name}-video"

Systemd service to toggle the webcam:

  • ~/.config/systemd/user/scrcpy-cam.service
[Unit]
Description=Scrcpy - virtual webcam from ADB Device
PartOf=graphical-session.target
StartLimitIntervalSec=5
ConditionUser=!root

[Service]
Type=simple
ExecStart=scrcpy --video-source=camera --no-audio --camera-id=0 --max-size=1000 --camera-ar=sensor --orientation=0 --camera-fps=15 --v4l2-sink=/dev/video0 --no-video-playback --v4l2-buffer=0 --no-clipboard-autosync --no-cleanup --video-codec=h264
Restart=no

StandardOutput=journal
StandardError=journal
SyslogIdentifier=scrcpy-cam
Slice=app.slice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant