So, you have a Raspberry Pi and want to use it as a dashboard to display a rtsp stream without having to install a full desktop environment. This is useful if you want to display security camera streams etc without requiring a full desktop environment or window manager. This way it keeps your solution simple and lightweight.
Parts needed
- – Raspberry Pi
- – Screen
Setup your Pi
You can install the raspberry pi OS lite edition. Once that is up and running you need to update it:
sudo apt update && sudo apt upgrade -y
Next, install the required packages:
sudo apt install -y xserver-xorg ffmpeg
Now reboot:
sudo reboot
Once that is installed, create a service file in /etc/systemd/system/ :
sudo nano /etc/systemd/system/stream.service
and paste the following:
[Unit] Description=RTSP Stream to attached Screen with ffplay After=multi-user.target rescue.service rescue.target display-manager.service [Service] Type=simple User=1000 # User UID to run service under Group=1000 # Group GID to run service under ExecStart=/usr/bin/ffplay -autoexit -rtsp_transport tcp -sync video -fflags nobuffer -framedrop -i rtsp://hotname:port Environment="XDG_RUNTIME_DIR=/run/user/1000" #change 1000 to the user above Restart=always RestartSec=20 [Install] WantedBy=multi-user.target
Once that file is saved, run the following commands
Sudo systemctl daemon-reload sudo systemctl enable stream.service sudo systemctl start stream.service
That’s it. All going well your RTSP stream should now automatically come up at boot. Enjoy