Using a raspberry pi as a webcam
Preconditions
- host machine has v4l2loopback for the virtual camera device (/dev/video0)
- raspi with camera module on network
Steps
sudo modprobe v4l2loopback
nc -lp $PORT | ffmpeg -i pipe: -f h264 -r 30 -f v4l2 /dev/video0
- send the data back to the host
ssh RASPI -c raspivid -o tcp://$HOST:$PORT -t 0
- the
raspivid
command can also specify rotations, flips, resolution, etc. It tends to saturate
a slow network with raw video data. Newer models (I'm using model 3b+) may be able to encode
the data first?
- use as a webcam or test the view with
mpv "av://v4l2:/dev/video0"