Streaming to a private RTMP server

IGSteven

Council Staff
#1
Streaming to a private RTMP server.

Want to stream to more than one streaming platform such as Twitch, Mixer, Smashcast or youtube gaming at once without using restream or switchboard well then you could consider setting up a custom RMTP server might be your solution. ( wow made this sound like an ad)

I'm mainly writing this so cause people ask me how I stream to twitch and mixer without stupid delay you get from services like Restream and SwitchBoard. I've been running my own RTMP for around 9 months so far and I've only ever had 1 issue with it and that's because of lack of restarts I've no got it on a crown to auto restart every month.


Installing Nginx

login to your server using a terminal, this can be with ssh terminal or by with a screen and keyboard plugged into it if you have the server box locally to you, but I personally use a VPS with UKServers for my server but you don't need anything too powerful, I've ever seen use raspberry pies

You need to install the dependencies,

Code:
$ sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
Now we can download nginx it doesn't matter where you put it, but I've put mine in /home

Code:
$ wget http://nginx.org/download/nginx-1.13.1.tar.gz

You also want to download the RTMP Module from GitHub

Code:
$ wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

Now we can extract these files and begin the install

Code:
$ tar -zxvf nginx-1.13.1.tar.gz$ unzip master.zip$ cd nginx-1.13.1

After ok now we get down to business and configure and install Nginx with the RMTP module

Code:
$ ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master$ make$ sudo make install

Ok so now the servers installed, let's start it up

Code:
$ sudo /usr/local/nginx/sbin/nginx


Configuring RMTP

Where it says (KEY) replace that with you're stream key for that platform; if you don't want to stream on that platform you can remove that line,

you can choose if you want to be able to connect the server and watch the stream using publish but if you're just using this to restream then can just leave it as off.

Note to change the Key in this config (also I still use beam demains for RTMP server, are less used
Code:
[/INDENT]
rtmp {  
  server {
        listen 1935;
        chunk_size 4096;
        application live {
            live on;
            record off;
            publish on;
            push rtmp://live-lhr.twitch.tv/app/(KEY);
            push rtmp://ingest-lon.beam.pro:1935/beam/(KEY);
            push tmp://a.rtmp.youtube.com/live2(KEY);
       }
   }
}
Restart Nginx/RTMP

to restart nginx and RTMP you can do the following commands,



Code:
$ sudo /usr/local/nginx/sbin/nginx -s stop$ sudo /usr/local/nginx/sbin/nginx
 

IGSteven

Council Staff
#8
You can use Ubuntu or Centos, Think i'm using ubuntu 14.04 in this example although my current server is centos 7
 

IGSteven

Council Staff
#10
I run it on a VPS with 2GB of ram 10GB storage 1 core 2.4ghz but I've seen a few people buy raspberry pies to do this on