Skip to content

Instantly share code, notes, and snippets.

@CRTified
Last active April 23, 2020 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CRTified/129034c27db71e9f6cf0bb572a259864 to your computer and use it in GitHub Desktop.
Save CRTified/129034c27db71e9f6cf0bb572a259864 to your computer and use it in GitHub Desktop.
Webcam Setup with v4l-utils and udev
{
services.udev.extraRules = let
camSettings = pkgs.writeShellScript "setup-v4l2.sh" ''
${pkgs.v4l-utils}/bin/v4l2-ctl \
--device $1 \
--set-fmt-video=width=1920,height=1080,pixelformat=MJPG \ # Set to 1080p
-p 30 \ # Set to 30 FPS
--set-ctrl=power_line_frequency=1 \ # Set to 50Hz power line compensation
--set-ctrl=focus_auto=0 # Disable autofocus
'';
in
''
SUBSYSTEM=="video4linux", KERNEL=="video[0-9]*", \
ATTRS{product}=="C922 Pro Stream Webcam", RUN="${camSettings} $devnode"
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment