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.

  • Are you accessing this locally (x11 server on Pi) or remotely (X11 Forwarding -> client)? It sounds like maybe ffmpeg is trying to detect the hardware decoder or something. Can you try and check if DISPLAY, and ffmpeg 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
  • This is when attempting locally. My setup is very similar to that link. – SilentNightx Oct 8 '20 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.