Tech recs from Luke Stein
My goal was to set up a single Raspberry Pi 4 to receive/play video out to HDMI from a variety of sources. I’m drawing on a number of online tutorials, and even what works now may not continue to work in the future.
sudo raspi-config
. Set the following:
Ensure you know your Pi’s local IP address (e.g., 192.168.0.140) which you can check using hostname -I
, or various other ways. You probably want to set up a static IP address using your router settings.
Especially if you will be regularly accessing the Raspberry Pi remotely via ssh, you may want to set up passwordless SSH access on the Pi, and/or a ~/.ssh/config
file on the computer you will be using to access it.
sudo
commands, edit /etc/sudoers.d/010_pi-nopasswd
and change NOPASSWD
to PASSWD
.In terminal, run:
sudo apt update
sudo apt install omxplayer nginx libnginx-mod-rtmp
sudo usermod -aG video www-data
Note that nginx will fail to set up if a previously-installed app already controls port 80. However, once set up, we can change nginx’s web server to a different port so that other apps (e.g, Dicaffeine) can use port 80 instead.
To create an RTMP server, edit the main nginx config file /etc/nginx/nginx.conf
using e.g.,
sudo nano /etc/nginx/nginx.conf
adding at the bottom (and savings your changes):
rtmp {
server {
listen 1935;
application live {
# Enable livestreaming
live on;
# Disable recording
record off;
# Allow only this machine to play back the stream
allow play 127.0.0.1;
deny play all;
# Start omxplayer and play the stream out over HDMI
exec omxplayer -o hdmi rtmp://127.0.0.1:1935/live/$name;
}
}
}
If you prefer, you can set up a restreamer rather than a player by replacing the exec omxplayer
line with one or more lines containing e.g., push rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx-xxxx;
Test the config using:
sudo nginx -t
and restart nginx using:
sudo nginx -s reload
Ensure you know your local IP address (e.g., 192.168.0.140, which you can check using hostname -I
). You should then be able to use the RTMP URL rtmp://192.168.0.140/live
with any stream key. Access from outside your local network should require you to set up port forwarding on your router, with potentially serious security implications; at a minimum, you may want to change nginx to use a non-standard port, and change the application name to a long string other than “live.”
Note that by default the cursor will show on top of streamed video. (This would not be true if you were using a terminal-only Pi as suggested in Aaron Parecki’s original instructions.) We can hide the cursor when it’s not moving using the unclutter
package:
sudo apt install unclutter
sudo service lightdm restart
If you wish to change nginx’s default webserver from port 80 to another port (e.g., so that we can install Dicaffeine), edit /etc/nginx/sites-available/default
using e.g.,
sudo nano /etc/nginx/sites-available/default
and change the two “listen” lines under server {
from “80” to any unused port (e.g., “81”):
server {
listen 81 default_server;
listen [::]:81 default_server;
Test the config using
sudo nginx -t
and restart nginx using
sudo nginx -s reload
In terminal, run
wget -O - http://dicaffeine.com/repository/dicaffeine.key | sudo apt-key add -
echo "deb https://dicaffeine.com/repository/ buster main non-free" | sudo tee -a /etc/apt/sources.list.d/dicaffeine.list
sudo apt update
sudo apt install -y dicaffeine
Ensure you know your local IP address (e.g., 192.168.0.140, which you can check using hostname -I
). Open Dicaffeine at that IP using either the Pi’s web browser, or another computer on the local network that can access the Pi.
The default password for Dicaffeine is admin
; you can change this using the “System” tab at the top of the browser window.
On the “Player” tab, choose an NDI source under Main stream, and select “Built-in Audio Digital Stereo” under Audio. “Low resolution” is suggested (or use the Advanced properties); Dicaffeine does not seem able to handle e.g. 1080p30. Click “Save” to save setting, and then “Play.”
Exit the player by clicking “Stop” if controlling from a remote computer, or by right-clicking the Pi’s mouse.
If you choose “Autorun after start” (and then save), the Pi will boot directly into a running Dicaffeine player rather than the desktop environment.
We need to set a few Chromium flags to ensure the Pi relies on hardware-accelerated decoding to the degree possible. Open the Chromium browser, and enable the following options:
chrome://flags/#ignore-gpu-blocklist
chrome://flags/#enable-accelerated-video-decode
chrome://flags/#enable-gpu-rasterization
Restart the browser. You can check hardware acceleration status by browsing to chrome://gpu
, although some sources suggest that Chromium may falsely claim to be using hardware acceleration.
As a simple example, direct guests to join an OBSN room at e.g., https://vdo.ninja/?room=ROOMNAME&pw=ROOMPASSWORD or obfuscate the password using https://invite.cam. You can control this “room” (including sending audio/video to your guest that will not be captured by the Pi) at https://vdo.ninja/?director=ROOMNAME&pw=ROOMPASSWORD.
Ensure you know your local IP address (e.g., 192.168.0.140, which you can check using hostname -I
). You can now open a fullscreen OBS viewer remotely via SSH using e.g.,
ssh pi@192.168.0.140 "chromium-browser --kiosk --display=:0 --autoplay-policy=no-user-gesture-required \"https://vdo.ninja/?scene=0&room=ROOMNAME&password=ROOMPASSWORD&codec=h264&nocursor&height=720\""
You can close this browser window remotely via SSH using e.g.,
ssh pi@192.168.0.140 "pkill -o chromium"
VLC should already be installed by default, but you can confirm by running:
sudo apt install vlc
Ensure you know your local IP address (e.g., 192.168.0.140, which you can check using hostname -I
). You can now open a fullscreen VLC player remotely via SSH using e.g.,
ssh pi@192.168.0.140 "cvlc --one-instance -I http --http-port 8080 --http-password testpassword --no-xlib --aout=alsa --no-video-title --repeat /opt/vc/src/hello_pi/hello_video/test.h264"
The one-instance
flag helps ensure that any subsequent commands run in the same VLC instance. Many command line flags are available.
You can close this player by asking it to “play” vlc://quit
, or remotely via SSH using e.g.,
ssh pi@192.168.0.140 "cvlc --one-instance --no-xlib --aout=adummy vlc://quit"
omxplayer should already be installed by default, but you can confirm by running:
sudo apt install omxplayer
Ensure you know your local IP address (e.g., 192.168.0.140, which you can check using hostname -I
). You can now open a fullscreen omxplayer player remotely via SSH using e.g.,
ssh pi@192.168.0.140 "omxplayer --loop /home/pi/media/fallingstars_1080p.mp4"
You can close this player remotely via SSH using e.g.,
ssh pi@192.168.0.140 "pkill omxplayer"
Incomplete
fbi is not installed by default, so run:
sudo apt install fbi
Ensure you know your local IP address (e.g., 192.168.0.140, which you can check using hostname -I
). You can now output an image remotely via SSH using e.g.,
ssh pi@192.168.0.140 "sudo fbi -vt 1 -noverbose /home/pi/bars.png"
To be added
Incomplete
cd ~/companion
git pull
yarn update
sudo reboot