How to set up your own private RTMP server using nginx

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

Daica

New Member
dodgepong said:
When you say that it lagged like crazy, what do you mean? Did OBS drop a lot of frames? Or was playback choppy?

Well it wasn't lagging for me of course but when other people view the stream they say that its "dropping frames" like crazy.
One person said it looks as if it was like 5-10 FPS
 

dodgepong

Administrator
Community Helper
Then yeah, if that server doesn't have enough upload bandwidth to serve all the viewers, you're gonna have a bad time.
 

Daica

New Member
dodgepong said:
Then yeah, if that server doesn't have enough upload bandwidth to serve all the viewers, you're gonna have a bad time.

I don't understand though, my speed : 30/4,
Server speed: shared 1gigabit

Im "uploading" to the server and the server is serving it to people right?
So if I'm streaming directly from my computer, I'll be the one serving it instead, but I have the same upload speed when im uploading to the server, so why is there lag?
 

Daica

New Member
MoiseyPRO said:
Compiled nginx for win32 (v.1.5.8), nginx-rtmp-module (v.1.1.2), included php-5.5.8 (8.01.2014 x86) and jwplayer-6.1.2972 (nulled). For start server run Start.bat, for close - Stop.bat
Download from Dropbox


Hey, I was trying this out and I got :

fafa3cf63a.png
 

Jack0r

The Helping Squad
Your http port 80 is already in use. You can change it in the nginx.conf to 8080 or something and it should work.

Code:
http {
   server{
      listen 8080;
 

Daica

New Member
Jack0r said:
Your http port 80 is already in use. You can change it in the nginx.conf to 8080 or something and it should work.

Code:
http {
   server{
      listen 8080;

My port 80 isn't being used by anything, I don't have any web server running.
My system is AMD x64, Windows 7, does that matter?
Maybe it would help if I port forward port 80 first?
 

JyB

New Member
Thanks a lot for this awesome tutorial.
I am setting this up on two windows 7 machine, I am using the exact same config as the OP. I believe I got OBS and Nginx to work together :
OBS is starting the stream without any error.
nginx runs well (can hit http://localhost).
If I shut down Nginx on my laptop (client), right away OBS on my big computer (server) is alerting me about not finding the conection anymore. The alert goes away when nginx is started again.

Now, I am having trouble playing the stream directly on my laptop running nginx. I tried to use VLC but it says it can't decode the format « undf » (stands for undifined I guess).
The address I enter in VLC is : rtmp://127.0.0.1/live/
I have tried with my local address, with localhost, without live, with the port 1935 written, ... without any success.

Each time I try to play the stream on VLC, the nginx access.log updates with :

127.0.0.1 [21/Jan/2014:23:12:23 +0100] PLAY "live" "" "" - 325 436 "" "LNX 9,0,124,2" (1s)
127.0.0.1 [21/Jan/2014:23:16:45 +0100] PLAY "live" "" "" - 353 490 "" "LNX 9,0,124,2" (4m 21s)

The error.log file only contains :
2014/01/21 22:54:39 [notice] 8832#6832: WSASocket() attempting to duplicate the listen sockets
2014/01/21 22:54:39 [notice] 8832#6832: Duplication of listen sockets succeded!
2014/01/21 22:54:39 [notice] 8832#6832: using inherited sockets from "4;48;"
Do you guys have any idea what is wrong ?


thanks
 

Daica

New Member
JyB said:
Thanks a lot for this awesome tutorial.
I am setting this up on two windows 7 machine, I am using the exact same config as the OP. I believe I got OBS and Nginx to work together :
OBS is starting the stream without any error.
nginx runs well (can hit http://localhost).
If I shut down Nginx on my laptop (client), right away OBS on my big computer (server) is alerting me about not finding the conection anymore. The alert goes away when nginx is started again.

Now, I am having trouble playing the stream directly on my laptop running nginx. I tried to use VLC but it says it can't decode the format « undf » (stands for undifined I guess).
The address I enter in VLC is : rtmp://127.0.0.1/live/
I have tried with my local address, with localhost, without live, with the port 1935 written, ... without any success.

Each time I try to play the stream on VLC, the nginx access.log updates with :

127.0.0.1 [21/Jan/2014:23:12:23 +0100] PLAY "live" "" "" - 325 436 "" "LNX 9,0,124,2" (1s)
127.0.0.1 [21/Jan/2014:23:16:45 +0100] PLAY "live" "" "" - 353 490 "" "LNX 9,0,124,2" (4m 21s)

The error.log file only contains :
2014/01/21 22:54:39 [notice] 8832#6832: WSASocket() attempting to duplicate the listen sockets
2014/01/21 22:54:39 [notice] 8832#6832: Duplication of listen sockets succeded!
2014/01/21 22:54:39 [notice] 8832#6832: using inherited sockets from "4;48;"
Do you guys have any idea what is wrong ?


thanks

Try playing the stream using Jwplayer?
 

JyB

New Member
Daica said:
Try playing the stream using Jwplayer?

I just got jwplayerfrom the official website and I get a nice :
Error loading Player. Offline playback not supported.

Do you guys have a version that allow offline mode since that's what I'm looking for ?

Thanks

Code:
<head>
<script type="text/javascript" src="jwplayer.js"></script>
</head>
<body>
<div id="myElement">Loading the player...</div>

<script type="text/javascript">
jwplayer("myElement").setup({
    file: "rtmp://127.0.0.1/live/",
    height: 360,
    width: 640
});
</script>
</body>

Edit:
Using :
http://dl.dropboxusercontent.com/u/2918 ... ayback.swf
The player is listing me the available file : 'mp4/114.flv' Which I don't really know where it's coming from.

I'm trying to dump the stream using rtmpdump but I'm getting :

Code:
rtmpdump -r "rtmp://127.0.0.1/live" -o test.flv -v

Error (...) You must specify a playpath or url (...)

rtmpdump -r "rtmp://127.0.0.1/live/mp4:112.flv" -o test.flv -v

(...)
ERROR: RTMP_ReadPacket, failed to read RTMP packet header
 

Jack0r

The Helping Squad
Ok first of all you always have to tell the streamkey/playpath you use, the error from rtmpdump clealy says that:
"specify a playpath"
rtmp://ip.ad.dr.ess/APPNAME/PLAYPATH
Appname is live in your case and they playpath/streamkey, whatever you entered into OBS as playpath/streamkey.
rtmp://127.0.0.1/live/test for example

In VLC player you sometimes have to give it one or two tries before it will connect successfully, and I never got it to play back without buffering. For the jwplayer, I think it just has to be hosted on a webserver, you can probably put it with the html file into the html folder of nginx and use http://127.0.0.1/filename.html :)
 

JyB

New Member
Thanks a lot for your answers Jack0r !
I managed to get everything to work because of your advices ;)

Now I'll start working on getting the smallest delay as possible on a lan network.
I'm having around a 3/4 second delay using flowplayer/jwpplayer.
 

floorinaa

New Member
Can someone clear up some confusion with the 4G network, and iphone? I talked to someone at a local AT T store, and they said no network has access to 4G as of right now. But eventually it will be coming out in certain places, and only be used to a certain degree.. I happened to be passing a sprint store so i asked there, they said they have been using the 4G network for quite some time!
___________________________
meals ideas ~ meal ideas ~ vegetarian recipes
 

MoiseyPRO

New Member
floorinaa said:
Can someone clear up some confusion with the 4G network, and iphone? I talked to someone at a local AT T store, and they said no network has access to 4G as of right now. But eventually it will be coming out in certain places, and only be used to a certain degree.. I happened to be passing a sprint store so i asked there, they said they have been using the 4G network for quite some time!
Apple can disable 4g function in some regions, in which it is unstable. When network will be tested and certificated by Apple, it's automatically becomes available in this region
http://thenextweb.com/apple/2012/11/30/ ... rks-first/
 

Daica

New Member
When do you think you could get around to streaming keys for each users?
For example if I give my friend my RTMP link he would be able to stream with any key.

Is it possible to "allow" certain people to stream to the server?
 

Glennbob

New Member
Hi guys,
Great guide by the way. I have managed to get everything to work and playing the stream with jw player works like a charm on the inside but i can't get it to work from outside my network.
Forwarded port 80 and 1935 but still nothing. I get to the webpage but the stream won't load.
Do in need to use port 443 aswell or what might be the problem?

Update, forwarding 443 didn't help. I'm stuck...
 

Daica

New Member
Glennbob said:
Hi guys,
Great guide by the way. I have managed to get everything to work and playing the stream with jw player works like a charm on the inside but i can't get it to work from outside my network.
Forwarded port 80 and 1935 but still nothing. I get to the webpage but the stream won't load.
Do in need to use port 443 aswell or what might be the problem?

Update, forwarding 443 didn't help. I'm stuck...

Whats your internet speed? I ask because if you don't have a good enough speed you won't even be able to stream to people anyways :\

As for your port problem, can you see if you could access your WEBSITE (not the stream with JW) outside your network?
Also, the IP you should be using is the one you get from ipchicken.

Also, make sure you port forward to the computer running your web server.
 

Glennbob

New Member
Whats your internet speed? I ask because if you don't have a good enough speed you won't even be able to stream to people anyways :\

As for your port problem, can you see if you could access your WEBSITE (not the stream with JW) outside your network?
Also, the IP you should be using is the one you get from ipchicken.

Also, make sure you port forward to the computer running your web server.

My internetspeed is 250/100mb sothat shouldnt be an issue.
I can see the webpage fine. The stream never starts just keeps trying to load.
 
Top