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
dodgepong submitted a new resource:

How to set up your own private RTMP server using nginx - A somewhat advanced guide for Linux-based servers

Most people who stream enjoy using services such as Twitch.tv or Ustream to deliver video to viewers, and that works well enough. But sometimes you want some more control over your stream, or you want other people to be able to stream to you, or you want to stream to multiple places, or any number of things that requires you to have access to an actual RTMP stream from an RTMP server. This guide will cover the very basics of setting up a simple RTMP server on a Linux computer. Don't worry, it's...

Read more about this resource...
 

Koolio

New Member
Why is there such a lack of easy to use ways of doing this, I have an apache server but I couldn't just wipe it to use ngix even if I wanted to, Though this guide looks like a great help and is exactly want I need.

I wish you had done a guide on doing it with Red5 as I have another windows server that has Red5 installed, but like you said it is heavy.


Is there any other free way of doing this same sort of OBS to RTMP relay streaming server setup?
 

dodgepong

Administrator
Community Helper
Koolio said:
Is there any other free way of doing this same sort of OBS to RTMP relay streaming server setup?
The only free RTMP servers I know of are Red5, crtmpserver, and nginx with RTMP module. I haven't used Red5 at all, but it seemed more complicated to me than the other two. nginx was the least complicated.

Koolio said:
Why is there such a lack of easy to use ways of doing this
It's a hard problem in a new field. We're pioneers in this new world of streaming, and consumer-level RTMP servers aren't things that are in high enough demand yet for easy solutions to exist.

What in particular are you trying to do with your RTMP server?
 

ThoNohT

Developer
Koolio said:
I have an apache server but I couldn't just wipe it to use ngix even if I wanted to, Though this guide looks like a great help and is exactly want I need.

nginx should be able to work alongside apache just fine. The only conflict I can imagine is them both wanting to listen on the same port. In that case, you will want to change the http module in the config file, change "listen 80" to "listen 8080" or any other currently unused port. This guide doesn't use the http module for rtmp anyway.
 

Koolio

New Member
I figured that wouldnt' be a problem, but the linux machine I have doesn't have the upstream bandwidth where as the windows machine I have access to has datacenter connection

I just don't know how u can compile this rmtp module for nginx on windows... the developer of the module also has no idea how..

seems to be much easier if u use linux
 

steveswl

New Member
Excellent guide dodgepong!

A free, open-source, relatively simple RTMP server/client solution is something I've sought after for quite a while. I just set it up on an Ubuntu 12.04 virtual machine. Since the guide is using apt-get and therefore deb packages it's more specific to Linux distributions such as Debian, Ubuntu, Linux Mint, etc. I'll try it on CentOS at some point which uses yum and rpm packages instead of apt-get.

I also got the stream to work with JW Player. I looked at Using RTMP Streaming.

The JavaScript code was
Code:
jwplayer("myElement").setup({
    file: "rtmp://<Ubuntu VM server ip>/live/flv:test",
    height: 360,
    width: 640
});

I'm serving the html with the player on nginx as well. There is about a 3 second delay when I watch the stream which isn't that bad.

Koolio said:
I figured that wouldnt' be a problem, but the linux machine I have doesn't have the upstream bandwidth where as the windows machine I have access to has datacenter connection

I'm using VirtualBox with a Windows server as the host OS and Ubuntu as the guest. VirtualBox or VMware might be a solution if it doesn't hinder the performance of your Windows server too much.

Koolio said:
I just don't know how u can compile this rmtp module for nginx on windows... the developer of the module also has no idea how..

Building nginx on the Win32 platform with Visual C. Trying to build a Linux application from source on Windows requires a lot of steps. Cygwin, MinGW, MSYS, and a bunch of other libraries are usually needed to be able to do it. I've chosen to use virtualization and run Linux software that way.
 

dodgepong

Administrator
Community Helper
Thanks, steveswl! From my experience, I get 3-3.5 seconds of delay with OBS 0.472b and ~1 second of delay with OBS 0.473b Test 11 and later

Thanks for the bit on JWPlayer, too. I haven't had a need to show an RTMP stream over the web yet, so I hadn't looked into it, but that is certainly useful information to have.

Good call about setting up Ubuntu on VirtualBox...since RTMP doesn't require much CPU, that might be Koolio's easiest option.
 

ScardyBob

New Member
Awesome guide! I've been looking for a way to incorporate streams from other casters in a Co-Caster -> Me -> Twitch setup. Only question I have is the bandwidth requirements for incorporating like one or two other streams into your own?
 

dodgepong

Administrator
Community Helper
ScardyBob said:
Awesome guide! I've been looking for a way to incorporate streams from other casters in a Co-Caster -> Me -> Twitch setup. Only question I have is the bandwidth requirements for incorporating like one or two other streams into your own?
It takes a decent amount. Tonight, I had 2 cameraman streams upload to my server at 2500 kbps (2.5 Mbps), and then I downloaded both of them simultaneously, so the bandwidth cost was doubled with both upload and download). Overall, I burned through over 11 gigs of transfer on my VPS for a 2-hour cast.

As for bandwidth pipe size, you'll need enough to download at the speed they are uploading, probably with some headroom. It's something you'll need to experiment with.
 

Koolio

New Member
Just set things up with nginx on a different port instead, works great..

I still hope someone will do a proper guide for red5, even though it really seems like a barely documented pile of junk... is not much free paths to go on for hosting on windows server.

The idea of virtualbox linux I might try, it did actually cross mind before, I just don't really want to do it that way, this temp setup with nginx on another server will have to do for now but just doesn't have the kind of connection speed for lots of streams.
 

mrbrain

New Member
Can you please show how to do authentication?

I know how a little bit doing it with PHP but it doesn't work right, thanks!
 

WeissJT

New Member
Hi, thanks for the guide!
I have a problem. I can't connect to the rtmp server even inside a Lan.
Always shows this error:
NeZpjBn.jpg


All step were followed correctly.
No errors in the build stage, nginx is working fine in the standard http port and shows the sample webpage. The server doesn't have a firewall configured.
Tried on Ubuntu and Archlinux.
And I think this is correctly configured:
v0ta3m7.jpg



Some ideas?
 

dodgepong

Administrator
Community Helper
Did you edit the nginx.conf file correctly? Was nginx running when you edited the conf file?
 

WeissJT

New Member
dodgepong said:
Did you edit the nginx.conf file correctly? Was nginx running when you edited the conf file?

Nevermind, was an error inside of my network. Thanks anyways!

Now it's working just fine!
 

Nekuikos

New Member
I followed this guide for red5 install:
Be advised!! i later found that installing JDK 64bit screwed up my firefox java.
http://juankpro.com/wordpress/2011/01/2 ... n-windows/

Basicly i installed red5 version 1 locally on my gaming computer.
Fiddled with the RTMP setup ip (red5.properties in conf folder) and presto OBS could stream to my local ip.

I used flowplayer to playback the stream from the RTMP server...
Follow the flowplayer guide i found:
http://www.unibia.com/unibianet/freebsd ... d?page=0,6
Please note:
clip url: stream name (Example: livestream) (OBS: path/key name)
netConnectionUrl: FMS URL (Example: rtmp://<red5-server>/midiDemo)
These need to fit what you write into the custome broadcast settings in OBS.
 

dodgepong

Administrator
Community Helper
Are you hosting your server on a VPS or on your own box somewhere? Might it be a router issue where the port isn't being forwarded?

Which port did you change in the config? What RTMP URL are you using?
 

rlex

New Member
Just setup it, works perfectly. Nginx 1.4.1 and recent rtmp module ATM.

My point was to re-stream to two different servers from my dedicated server in Germany.
As already said, for restreams you should use push directive, something like that:


(thanks to KristyKoala for helping with twitch RTMP url)
And make sure to put proper twitch/hashd/etc RTMP server in url.

And it will be good idea to protect this stream point since it have access to your twitch/etc streams. You can do that inside application { } block, something like this:
allow publish 127.0.0.1;
deny publish all;
replace IP with your external IP (ie inside LAN, or in WAN if you use dedicated server, will be great if you have static IP from ISP).

Of course proper way will be setting up authentication with on_connect function, but it requires external web service (ie PHP scripts) and i have not looked into it ATM. Probably later...
 

dk-info

New Member
Thank you for a great guide dodgepong!
I have now installed my own local RTMP server. This is a big step for me to finish an internal info-screen project.

I installed the RTMP on a vitual Ubuntu 12.04 running on a large (fast) HP server.
I could not install latest nginx (1.4.1) - but 1.2.9 worked.

With rtmpdump I am now able to se my stream in VLC.
But it is far from running smooth. :(
I repeatedly get 2 seconds of stream + 8-10 seconds of pause.

My final goal is to show my stream in a webbrowser.
So right now I am trying to set up an internal webserver to show the stream with JW player.
I have not yet figured out the right setup for the webserver but am working on it.

Any tips are of course welcome. :o)
 
Top