ESSAY / NOTE
How to set up your own private RTMP server using nginx
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 not too complicated, but having familiarity with Linux will certainly help.
A couple things you can do with your own RTMP server that you might be interested in:
This is an extremely basic configuration with a "live" application that simply forwards the RTMP stream on to whoever requests it. You can play with it some more later. Here's the whole configuration guide, which shows you how to forward streams to other places (such as Twitch), save recordings of uploads, output stats, etc.
Restart nginx with:
Step 4: Testing!
Your server should now be ready to accept RTMP streams! Let's try it out.
Create a new profile in OBS, and change your Broadcast Settings thusly:
You may be wondering where that play path "test" came from. Well, we just made it up, just now. You can basically make up any play path and stream to it, and put that path into an RTMP player, and it will play back. For simple purposes, authentication isn't necessary in my experience.
You should now be able to start streaming to your server. If you hit "Start Streaming" and don't get an error from OBS, that's a good sign.
So how do you watch it? Personally, I have been using vMix to play back RTMP streams and incorporate them into my own stream. If you just want to play back the stream that's being uploaded, you can do so with VLC 2.1.0 or later. Just Open a Network Stream and enter in rtmp://<your server ip>/live/test as the URL. If it all worked right, then you should now be seeing your stream in VLC!
You now have a working RTMP server! Congrats!
What now?
You can use the video source plugin to add an RTMP stream to OBS itself, or use something like JWPlayer to play back the RTMP stream on a web site you set up.
You can also use your RTMP server to forward to other streaming services and channels! Underneath the "record off;" line in your nginx.conf, add the following:
And any stream streamed to that application will be forwarded on to the other service, as well as being served up from the server! You can add multiple "pushes" to forward the stream to multiple locations.
FAQ
Q: Why nginx? Why not crtpmserver/Red5/Wowza?
A: I've tried crtmpserver (aka rtmpd) before, and it works, but is harder to use. If you need to use RTSP, though, instead of RTMP, then I recommend it, since the nginx RTMP module doesn't do RTSP. Red5 seemed overly complicated and heavy to me, and written in Java...you can use it if you want though. I haven't investigated it deeply. Wowza is not free. You can use what you like, but so far nginx is lightweight, easy to use, and free, so you're going to have to pry it from my cold, dead hands.
Q: How do I X?
A: This FAQ is still in progress...ask questions so I can add them here!
link:https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/
- Stream to multiple external channels
- Import other people's streams to incorporate for your own purposes (I use it in my casts for multiple camera angles, like in this video I did of a Tribes Ascend broadcast with multiple camera angles)
Code | Analyze
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}