Last active
April 13, 2024 19:31
-
-
Save strfry/422b83f7d6e695c9bc1d55f3b4d2a6d1 to your computer and use it in GitHub Desktop.
v4l2loopback example
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
#!/bin/sh -e | |
# Dependencies | |
apt install -y v4l2loopback-dkms v4l2loopback-utils gstreamer1.0-plugins-good | |
apt install -y gstreamer1.0-plugins-bad # h264parse | |
apt install -y gstreamer1.0-libav # H.264 | |
# Reset module state | |
modprobe -r v4l2loopback | |
modprobe v4l2loopback | |
# Setup camera stream | |
v4l2-ctl -d /dev/video0 -c timeout=3000 | |
v4l2loopback-ctl set-fps 25 /dev/video0 | |
v4l2loopback-ctl set-caps "video/x-raw,format=UYVY,width=640,height=480" /dev/video0 | |
v4l2loopback-ctl set-timeout-image testcard.png /dev/video0 | |
# You need to wait here, until the software has started to grab the webcam | |
gst-launch-1.0 -v videotestsrc pattern=snow ! "video/x-raw,width=640,height=480,framerate=25/1,format=UYVY" ! v4l2sink device=/dev/video0 | |
gst-launch-1.0 uridecodebin uri=file:///home/pi/testcard.mp4 ! decodebin name=demux demux. ! videoconvert ! videoscale ! 'video/x-raw,format=UYVY,width=640,height=480,framerate=25/1' ! v4l2sink device=/dev/video0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment