Zend certified PHP/Magento developer

‘v4l2’ is not a suitable output format

I have created following script I’ve been using on Arch Linux to stream the camera feed to OBS

#!/usr/bin/env bash

set -euo pipefail

sudo modprobe v4l2loopback exclusive_caps=1 max_buffer=2

gphoto2 
    --stdout 
    --set-config viewfinder=1 
    --capture-movie |
    ffmpeg 
        -i - 
        -vcodec copy 
        -threads 1 
        -f v4l2 
        "/dev/$(ls -1 /sys/devices/virtual/video4linux)"

Since I’ve switched to NixOS, it stopped working with following error.

q --enable-libzimg --enable-zlib --disable-vulkan --disable-libglslang --disable-libsmbclient --disable-debug --enable-optimizations --disable-extra-warnings --disable-stripping
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
[mjpeg @ 0xe08300] Format mjpeg detected only with low score of 25, misdetection possible!
Input #0, mjpeg, from 'pipe:':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 1024x576, 25 tbr, 1200k tbn
[NULL @ 0xe0af80] Requested output format 'v4l2' is not a suitable output format
/dev/video0: Invalid argument

I’ve tried to capture frame using gphoto2 and it successfully captures one frame.

gphoto2 --capture-movie=1

Applications

❯ nixos-version
23.05.2664.9034b46dc4c7 (Stoat)

❯ gphoto2 --version
gphoto2 2.5.28

❯ ffmpeg --version
ffmpeg version 5.1.3
  boot.kernelModules = [ "v4l2loopback" ];
  boot.extraModulePackages = [ pkgs.linuxPackages.v4l2loopback ];

Why does it say v4l2 is not suitable?