How to set up your own private RTMP server using nginx

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

dodgepong

Administrator
Community Helper
Those have nothing to do with this post. In OBS, you have to add them as a "Custom server" and follow the directions on those sites. I recommend creating a new thread to ask about those sites if you still need help.
 

TheFatal

New Member
Nice guide.

Now, i got one question.
You guys know that Twitch.tv allow you to chose the quality when you watch a stream. So, my quetion is, is that available with rtmplite ?
 

dodgepong

Administrator
Community Helper
To make different quality settings, Twitch transcodes the incoming video to lower qualities, and then the Flash Player is programmed to look for the transcodes when you select them instead of the Source stream. I don't know how to do it with rtmplite (I've never used it) but the basic idea is that you have to send the input to a transcoder (probably ffmpeg) and then provide the transcode at a different play path for the Flash player to play back.
 

dodgepong

Administrator
Community Helper
With the nginx RTMP module described in my guide, you can run an exec to put the stream through ffmpeg. But again, the player you use has to support switching quality modes.
 

robbyrobby

New Member
I've managed to get the stream itself working. But neither i nor someone from outside of the network can watch it. There's an immediate error stating that it can't connect. Obviously something is wrong, but since i followed this guide exactly i can't really figure out what it is. There are connect attempts in the NGINX log, but none of them state any actual errors. It all looks fine in there.
 

dodgepong

Administrator
Community Helper
What method are you using to view the stream?

You might need to make sure port 1935 is open and forwarded properly.
 

robbyrobby

New Member
dodgepong said:
What method are you using to view the stream?

You might need to make sure port 1935 is open and forwarded properly.

Well i've been trying to load the stream in VLC. That's the only program i know that can do this. But it turns out it can't. ;)

Update: I decided to try out jhn123's excellent template, which works fine. It does however so only within the network. I'm still struggling with what address you're supposed to enter when trying to access the HTML document from the outside. Does anyone know? That's the only part of this post that isn't very clear.

So now i've begun reading some about creating a page within the NGINX HTML folder that you can load and play the stream in the browser. I'm trying to use JW Player, but can't get it to work. It says "Error loading player. Could not load player configuration.".

The HTML document looks like this:

Code:
<!doctype html>

<head>

<script src="http://jwpsrv.com/library/xxxxxxxxxxxxxx.js"></script>

</head>

<body>

<div id="myElement">Loading the player...</div>

<script type="text/javascript">
jwplayer("myElement").setup({
    file: "rtmp://[IP Address]/live/flv:test",
    image: "/assets/myVideo.jpg",
    height: 720,
    width: 1280
});
</script>

</body>
This seems to work for this guy. I can't figure out what else needs to be done. So i guess something is wrong with the details here too.

Also.. how do i access that HTML file from outside the network? What's the address to it after the main IP address? I can't find this info in the NGINX wiki.
 

Mixy

New Member
This is an amazing post. Thanks!
I was very nervous about testing it on the server that I use because Apache is hosting a number of websites on it, but nginx went on there with ease and hasn't caused any problems at all.

I've seen people trying to get it working with JW Player. I have it working using
Code:
jwplayer("stream_container").setup(
   ...
streamer: "rtmp://xxx.xxx.xxx.xxx/live",
file: "flv",  //  Play Path/Stream Key

   ...

);

..With the other settings as normal.

Is it possible to have a fallback file stream from inside the same application as the rtmp stream, so that the server automatically streams it between live streams?

Because I would have people streaming for 2 hours and then handing over to someone else at a different location for their 2 hours, I thought it would be great to have a small clip play during that handover.
 

dodgepong

Administrator
Community Helper
That's not possible with this server by default. You would have to write your own script of some sort to do that.
 

abura

New Member
Hello,

Thanks for this guide. I've got a question. Is it possible for others to stream to the server and for me to grab those streams and use them in this program you were using, vMix so I can swap between them, do PiP etc. My own stream is showing up when I use the rtmp link.

I'm not a code junky, I just copy and pasted all you did into a VM of Ubuntu and got it to work perfectly.
Thanks for any replies
 

abura

New Member
Could you give the quick and dirty on how it's done? I've got some people who can help me stream to me, but do I have to change settings in the conf or what do I do?
 

dodgepong

Administrator
Community Helper
You just add the RTMP URI as a source. So if someone is streaming to rtmp://<some server>/live with the stream key of "abcde" then in vMix you add rtmp://<some server>/live/abcde as a RTMP source.
 

cyberbask

New Member
Hello everyone and sorry for my English.

I use the guide of dodgepong, and set up my own rtmp server in a virtual machine.

Thank you all.
 

Daica

New Member
I'm following this guide step-by-step (I did download the latest version of nginx) but at the end, I get this error when I try to stream :

Server offline, try a different server


I'm using a 5$ VPS running Ubuntu 12.04.3


EDIT: I went through the guide again, slowly, and was able to put a server up and stream to my friends :)
THANK YOU so much for this guide, I have been searching for about 1 week to no avail :\

Does anyone know how to install NGINX + RTMP Server when Apache is already installed on the VPS?
I don't want to make any changes to Apache because its currently hosting 1 website on it.
 
Top