Using RTMP for Streamlabs OBS (GoPro, Co-Streaming to multiple Channels)
Table of Contents
Using a GoPro as a stream source over Wi-Fi? What about streaming from SLOBS to two Twitch channels at once? Having a dedicated recording machine? Streaming to multiple platforms? Maybe even host a LAN party with a commentary stream? You can use RTMP and a custom ingest for streaming. This way you are able to accomplish what you want. In this article, I will guide the setup and show examples for the different use cases. It can be a bit technical for most people, but I will be happy to help if you have questions.
Setting up an NGINX RTMP server #
Let’s dive in on the technical part first, you might not have this if you got a device/image from me, if so you can skip this chapter. You can use a Raspberry Pi as a test or other generic GNU/Linux server. RTMP should run fine on a Raspberry Pi since it is not too heavy on system resources. But if multi-streaming I can highly recommend a dedicated machine with a bit more powerful CPU.
Installation (Debian based systems) #
You can install NGINX with RTMP support as root on Debian. This is tested on Debian 10. Run the following to install dependencies:
apt install -y build-essential libpcre3 libpcre3-dev libssl-dev unzip zlib1g-dev
You now need to download NGINX, and the NGINX RTMP module:
cd /usr/local/src
wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar -xvzf nginx-1.18.0.tar.gz
rm -f nginx-1.18.0.tar.gz
mv nginx-1.18.0 nginx
cd nginx
wget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip
unzip dev.zip
Great, everything should be downloaded and in place. Now we can build & compile the project as such by executing these commands:
./configure --with-http_ssl_module --add-module=./nginx-rtmp-module-dev
make
make install
Congrats! It should have installed to /usr/local/nginx, you can now try to run /usr/local/nginx/sbin/nginx and see if it works.
Now create a Systemd service file in /lib/systemd/system/nginx.service with the following contents:
[Unit]
Description=The NGINX HTTP and reverse proxy server with RTMP
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Example configuration #
This configuration contains examples for the /usr/local/nginx/conf/nginx.conf configuration file. In order to stream from another place than your local network, you need to forward port 1935 and set up security settings (like in the allow publish part of the multichannelstream application) in order to prevent unauthorized people from streaming.
worker_processes 1;
error_log logs/rtmp_error.log debug;
pid logs/nginx.pid;
rtmp {
server {
listen 1935;
chunk_size 4096;
# Use a GoPro livestream in other applications
application gopro {
live on;
record off;
}
# Use a single OBS output for multiple streams
application multichannelstream {
live on;
record off;
meta copy;
push rtmp://live-ams.twitch.tv/app/<YOUR TWITCH STREAM KEY>;
push rtmp://live-ams.twitch.tv/app/<YOUR 2nd TWITCH CHANNEL STREAM KEY>;
# Use this to limit who is allowed to stream to this application, this is important to prevent others from being able to stream to your channels. This has to be an IP or range you plan to stream from.
allow publish 10.10.0.0/24;
deny publish all;
allow play all;
}
# Use a single OBS output for multiple platforms (Facebook, Twitch, Youtube)
application multiplatformstream {
live on;
record off;
meta copy;
push rtmp://live-ams.twitch.tv/app/<YOUR TWITCH STREAM KEY>;
push rtmps://live-api-s.facebook.com:443/rtmp/<YOUR FACEBOOK STREAM KEY>;
# Youtube allows a backup server in case their primary ingress server fails. This is why there are two listed here.
push rtmp://a.rtmp.youtube.com/live2/<YOUR YOUTUBE STREAM KEY>;
push rtmp://b.rtmp.youtube.com/live2/<YOUR YOUTUBE STREAM KEY>?backup=1;
}
# Twitch stream catcher, for commentary streams or recording. You will need multiple of these in order to capture multiple broadcasts with a unique name for each
application <TWITCH CHANNEL> {
live on;
record off;
meta copy;
push rtmp://live-ams.twitch.tv/app/<CHANNEL TWITCH STREAM KEY>;
}
}
}
events {}
http {
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/src/nginx/nginx-rtmp-module-dev/stat.xsl;
}
}
}
This configuration has examples for the multiple use cases listed below. Please check and alter as needed.
GoPro setup #
Using a GoPro camera in OBS? You can with the magic of RTMP! Playing around with this was how I initially got into RTMP streams and figuring out the other things you can do with it. GoPro’s have the option to directly stream to some platforms, but you wouldn’t have OBS/Overlays then, to fix this you can stream to a custom RTMP server and catch that stream in OBS. The only downside to this is that it’s not as real time as a webcam might be since it is over the network, but not everything requires this. Especially if you use the audio from the RTMP stream!
Streamlabs OBS setup #
First, you got to add a new media source to import your newly generated RTMP feed, set the buffering as low as possible, as well as the reconnect delay. Your source should look something like this:
This should now activate automatically when you start streaming to your RTMP server from your Gopro
Using RTMP to stream on multiple Twitch channels #
You could be playing a game together, on a single console for example but still want to stream to each of your channels. You can configure RTMP to re-stream to two outputs at the same time. This way you can stream from one Streamlabs OBS to two separate Twitch channels for example.
Using the example configuration provided above, we need the multichannelstream application example.
In order to do
this safely, the second streamer needs to share a stream key with you. It isn’t recommended to share a primary stream key, the better way would be for the streamer to add you to their “People who can stream on your channel” on your channel settings page: https://www.twitch.tv/settings/channel. Twitch will then add a secondary streaming key to your account and email this to the person you added. If they remove the person from the list only that stream key will be invalidated.
Set your OBS to stream to a custom server, and input the following URL, fill in anything you want for stream key since the authentication is based on IP. Once you start streaming it should automatically forward to multiple channels at once!
rtmp://<your ip>/multichannelstream
In case you want notifications from the other streamer(s) make sure to add the alert box URL (for example if you use Streamlabs OBS) from the other streamer(s) as well. There currently isn’t a method to filter between the different streamers if you use multi streamer like this. So both channels will show the notifications, maybe something like different parts of the screen for the different streamers work for this?
Using RTMP to stream on multiple platforms #
Another way to use this, if you want to stream to multiple platforms at the same time, like for example Youtube, Twitch & Facebook Live. For this, we use the multiplatformstream application from the example configuration above.
It seems that on Facebook, you need to manually press the “Go Live” button for the stream to start, even after supplying a RTMP stream.
Another thing that has to be noted, if you are a Twitch affiliate or partner you are not allowed to stream to other platforms at the same time since you give Twitch a 24 hour exclusivity on the content you create (Twitch Affiliate Agreement 2.2. Live Content Exclusivity).
Using RTMP to embed streams (for example, to give commentary as a gamemaster) #
Let say you are the game master for a multiplayer game at a LAN party, everyone is streaming to their own Twitch channels and you want to embed the other streamers while giving commentary on it. Using multiple of the Twitch streamer application, you can embed the streams of other players in your own stream easily. You could already do this using a Browser source but this would be open to more issues like the network connectivity.
All streamers need to stream to their application on the RTMP server and provide a stream key. The server acts as a proxy for the stream which others can capture from. You can then use the OBS configuration from the GoPro setup to embed the streams in OBS. Keep in mind your hardware & network needs to be able to handle it.