Last active
March 27, 2023 19:30
-
-
Save TheSirC/93130f70cc280cdcdff89faf8d4e98ab to your computer and use it in GitHub Desktop.
My Nix module to work with v4l2loopback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib, config, pkgs, ... }: | |
with lib; | |
{ | |
options.v4l2 = mkEnableOption "Enable the confguration to use the reflex as a webcam"; | |
config = mkIf config.v4l2 { | |
# 20.03: v4l2loopback 0.12.5 is required for kernel >= 5.5 | |
# https://github.com/umlaeute/v4l2loopback/issues/257 | |
# Extra kernel modules | |
boot.extraModulePackages = with unstable; [ | |
config.boot.kernelPackages.v4l2loopback | |
]; | |
# Register a v4l2loopback device at boot | |
boot.kernelModules = [ | |
"v4l2loopback" | |
]; | |
boot.extraModprobeConfig = '' | |
options v4l2loopback exclusive_caps=1 video_nr=9 card_label=a7III | |
''; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env nix-shell | |
#! nix-shell -i bash -p gphoto2 ffmpeg zoom-us | |
set -euo pipefail | |
function connect-camera() { | |
gphoto2 --stdout --capture-movie 2> ~/tmp/camera.log | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video9 > /dev/null 2> ~/tmp/encoding-err.log & | |
PID_CAM=$! | |
} | |
function main() { | |
connect-camera &&\ | |
read -n 1 -s -r -p "Press any key to continue" &&\ | |
zoom-us 2> ~/tmp/zoom-output.log &&\ | |
kill -KILL $PID_CAM | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment