I've setup a webcam viewer that detects when a USB webcam is plugged in with a udev
rule, then starts a systemd
service that executes a script that starts an FFmpeg/FFplay webcam stream. I noticed when setting DISPLAY=:0
and XAUTHORITY=/home/pi/.Xauthority
in the script before FFmpeg is started FFmpeg will run the stream very poorly (Pi Zero W < 1fps).
On the Pi Zero W I left this bit out and it runs great when a webcam is plugged in but on a Pi 4 4GB the webcam viewer never comes up unless these environment variables are set. The logs say XDG_RUNTIME_DIR not set in the environment
. Why would the stream work fine on the Zero W without these variables and not work at all on the Pi 4? Better yet, why does FFmpeg run terribly when these variables are set?
On the Pi 4 setting these variables does not seem to affect FPS.
DISPLAY
, andffmpeg
run outside the script interactively gives any clue? Maybe also check out this reddit.com/r/raspberry_pi/comments/5677qw/… – dza Sep 29 '20 at 21:58