How to set up your own private RTMP server using nginx

All Versions How to set up your own private RTMP server using nginx

Jack0r

The Helping Squad
Port 80 is for the webserver. RTMP uses port 1935 by default unless you change it in the nginx.conf.
If you do not need a webserver you can also remove that part from the nginx.conf completely.
 

Fenrir

Forum Admin
Hi everyone
Has anyone tried setting this up with the new ubuntu bash native set up in windows 10 (https://msdn.microsoft.com/en-us/commandline/wsl/about)?

I managed to do all the steps correctly, however once I ran the server, I came across a few errors like this:
Code:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

Then I read somewhere that windows uses http port 80
so I changed the config file to have the http server point to port 81

unfortunatly on obs side, the 'start stream' button would stall on 'connecting'

I tried adding port 81 to the firewall, and wasn't successful.

Let me know if anyone has a good way of doing this. Thanks!

What is the exact URL you're putting in to OBS? Also, post a log from OBS. By default, RTMP is port 1935, not port 80 (or 81 in this case). You don't actually need to run the webserver portion of NGINX unless you're going to be hosting an actual webpage.
 

avstaff

New Member
Hi again

I removed the http's server portion in the conf file, and running nginx didn't give any problems in window's 10 bash.

However OBS still has trouble connecting to the server <localhost>:1935. The stream button is stalling and labeled as "connecting...".

Here is the log file.. note the portion <LOCALHOST_SERVER> shown below is used to represent my actual numerical ip of my localhost. In OBS I use the actual numerical ip.

Code:
16:27:58.909: [Media Foundation AAC: 'simple_aac']: encoder created
16:27:58.909:     bitrate: 160
16:27:58.909:     channels: 2
16:27:58.909:     sample rate: 44100
16:27:58.909:     bits-per-sample: 16
16:27:58.909:
16:27:58.909: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmp://<LOCALHOST_SERVER>:1935...
16:27:58.909: No application or playpath in URL!
16:27:58.911: [rtmp stream: 'simple_stream'] Interface: Intel(R) Centrino(R) Ultimate-N 6300 AGN (802.11, 54 mbps)

Let me know if anyone got this working on windows 10 bash.
 

Fenrir

Forum Admin
Hi again

I removed the http's server portion in the conf file, and running nginx didn't give any problems in window's 10 bash.

However OBS still has trouble connecting to the server <localhost>:1935. The stream button is stalling and labeled as "connecting...".

Here is the log file.. note the portion <LOCALHOST_SERVER> shown below is used to represent my actual numerical ip of my localhost. In OBS I use the actual numerical ip.

Code:
16:27:58.909: [Media Foundation AAC: 'simple_aac']: encoder created
16:27:58.909:     bitrate: 160
16:27:58.909:     channels: 2
16:27:58.909:     sample rate: 44100
16:27:58.909:     bits-per-sample: 16
16:27:58.909:
16:27:58.909: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmp://<LOCALHOST_SERVER>:1935...
16:27:58.909: No application or playpath in URL!
16:27:58.911: [rtmp stream: 'simple_stream'] Interface: Intel(R) Centrino(R) Ultimate-N 6300 AGN (802.11, 54 mbps)

Let me know if anyone got this working on windows 10 bash.

I think I see your problem. You need to include the application from your rtmp block in the stream URL.

i.e. if you set the application name as the default of live your full RTMP url would be rtmp://localhost/live (no need to specify port 1935, as it's assumed by OBS as the default).
 

avstaff

New Member
I think I see your problem. You need to include the application from your rtmp block in the stream URL.

i.e. if you set the application name as the default of live your full RTMP url would be rtmp://localhost/live (no need to specify port 1935, as it's assumed by OBS as the default).

Hi Fenrir
I tried that, with localhost, and also with a variety of different ips 127.0.0.1 for example. Still in all cases, the stream button is stalling as 'Connecting'

the end of the obs log is the same as my previous post.
 

Rockisdead

New Member
I got error message that saying "unknown directive "rtmp" in /etc/nginx/conf.d/rtmp.conf:119" after adding RTMP config snippet to nginx.conf file and trying to reload the nginx server.I'm using brew to install the nginx on my 13-inch macbook pro 2015.

BTW when I try to install brew install nginx-full --with-rtmp-module,I got warning "nginx 1.10.2 already installed",new to mac and nginx,please advise.thanks in advance.
 

Rockisdead

New Member
@Rockisdead, that error comes up if nginx runs without rtmp module. You probably have to remove nginx first and then install it with rtmp-module.

I delete the folder an re-install the rtmp-module,now it's up and running on my Mac as well,thanks.


I installed nginx with rtmp module on my raspberry pi 2 and make the server to public,so I could use vlc app on my iphone to streaming from it,I would learn more of those configuration options as now it choopy every a few seconds if string high resolution videos,my goal is using my HD PVR along side my PC(OBS) to stream my satellite tv programs(Like EPL or La Liga) to my friends,I have sling box but only good for one friend,so I'd like to go with this solution.
 
Last edited:

Hoerli

New Member
Hi!
I stream in 1080p and 4700kbps. Some Platforms don't want this good quality and allow only 3500kbps.
Now i want to Stream to Twitch, HitBox, YouTube,.. with 4700kbps and to other servers in 720p or something and 3500kpbs or lower.

Anyone who have a good Config for that?

Is it enough if i add this Code for the other plattforms?
Code:
exec ffmpeg -re -i rtmp://localhost:1935/transcode/test -Some good Quality-settings who i can find in this forum... rtmp://other-plattform:1935/live/test;


I'm not sure on which line of Code i should use :)

So nobody have a answer for my little problem? :(
Or I have read the wrong way through ....
 

Hoerli

New Member
Thanks!
Works verry good now :)


For all, who want to know what i have done (and ppl with the same problem)

1. Install FFMPEG with thus guid: http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/
2. Create a .bat-File on the Desktop or somewhere eles
3. Put in this bat-File this Code:
Code:
ffmpeg -i rtmp://127.0.0.1/live/ -vcodec libx264 -preset fast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://YourStreamingPlatformServerLikeTwitchOrYouTube/YourKey
pause
You can change the code according to your wishes.
4. Run the nginx-Server
5. Begin to stream
6. Open the bat-file

:)
 

Edward_Stryfe

New Member
Is there a video streaming solution other than JWPlayer or an application/plugin like listed in the FAQ? Say for an independant user who wanted to make or use their own player without having to use any other sourced material such as how JWplayer's players are hosted on JW and one would want similar operability is there an open source HTML player like solution?
 

Rockisdead

New Member
What's best configuration for recording?I set up the nginx rtmp server on the pi and also using avconv to capturing a usb camera and streaming to the server,I'd like to recording the video in mp4 format with h.264 codec and separated file to 500MB each,just could not figure out the best configuration of doing it,asking for some help here,thanks in advance.
 

Jack0r

The Helping Squad
@Edward_Stryfe I pretty much only know of video.js and jwplayer. There might be smaller less known projects. Google is your friend. (You can host the jwplayer files youself btw)
@Rockisdead: https://github.com/arut/nginx-rtmp-module/wiki/Directives#record
In short:
Code:
rtmp {
    server {
        listen 1935;
        chunk_size 8192;

        application live {
                        live on;
                        meta copy;
                        record all;
                        record_unique on;
                        record_max_size 500M;
        }
    }
}
You will have to test if nginx splits the files that way or just stops recording after 500mb.
 

Edward_Stryfe

New Member
@Edward_Stryfe I pretty much only know of video.js and jwplayer. There might be smaller less known projects. Google is your friend. (You can host the jwplayer files youself btw)
@Rockisdead: https://github.com/arut/nginx-rtmp-module/wiki/Directives#record
In short:
Code:
rtmp {
    server {
        listen 1935;
        chunk_size 8192;

        application live {
                        live on;
                        meta copy;
                        record all;
                        record_unique on;
                        record_max_size 500M;
        }
    }
}
You will have to test if nginx splits the files that way or just stops recording after 500mb.
Thank you I tried google but I couldn't find the right keywords I guess. Sorry if the video.js was a no duh answer I just didn't see anything else in the FAQ and when I tried JWPlayer it wasn't so. Thank you very much for your help.
 

Jack0r

The Helping Squad
Code:
<script type="text/javascript">
                setTimeout(function () { location.reload(true); }, 40000);
</script>
 
Top