In this day and age, streaming is at the forefront of the new normal so you could do with a streaming server. In this project, you’ll learn the basics on how to set up a private streaming server that will allow you to receive, manage and combine several streams into one to then re-stream to any platform. We’ll be using NGINX, a server application which we’ll configure to run as an RTMP (Real-time Messaging Protocol) streaming server on a Raspberry Pi. We’ll use OBS running on a separate computer to combine a number of streams together and broadcast them to the world.
You should start with a Raspberry Pi running the latest Raspbian, connected to screen, mouse and keyboard. If you’re using the OKdo Pi 4 starter kit you can learn how to get it ready here.
The OKdo kit is strongly recommended for this project as it includes heat sinks and a fan which will be very handy to keep your Pi cool as it deals with all the video processing. It is also recommended that you use a network cable for your Pi’s internet connection as this will improve the reliability of your streaming.
sudo apt install nginx
sudo apt install libnginx-mod-rtmp
sudo nano rtmp.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}
sudo nano /etc/nginx/nginx.conf
include /etc/nginx/rtmp.conf;
sudo systemctl start nginx.service
sudo systemctl status nginx.service
You should now have NGINX up and running. You can check it by opening a browser window on your Pi and pointing it to your Pi’s Ip address.
Server: rtmp://YOUR Pi's IP:1935/live
Key: test
“test” is our unique stream key, we just made it up by entering it in the preferences. You can basically make up any stream key and stream to it. For simple purposes, authentication isn’t necessary in my experience.
rtmp://YOUR Pi's IP:1935/live/test
If all is well you should now see whatever you’re streaming from OBS on your PI. It takes a little while to start showing so be patient!
To add more streams to the Pi, you just need to have a different Stream Key for each source, in our case, this could be rtmp://YOUR Pi’s IP:1935/live/test2 for example.
Now that you have your Pi receiving multiple streams, you can mix them live with OBS.
input: rtmp://your Pi's IP:1935/live/test
Input Format: rtmp
You can add as many different streams as you have, refer to OBS documentation if you need help creating scenes mixing etc…
At this point, you have an NGINX RTMP server receiving streams which you can mix with OBS.
To safely stop NGINX running before switching off your Pi in Terminal enter:
sudo systemctl stop nginx.service
Exposing ports outside of your network opens you up for attack. Ensure that you understand the risks and that you take the necessary security measures.
With the set-up so far, only devices on your local network will be able to access the RTMP server on your PI. To enable streams coming from the outside do the following:
You can find information regarding these procedures here.
From a quick tap to smashing that love button and show how much you enjoyed this project.