How to set up your own private RTMP server using nginx

How to set up your own private RTMP server using nginx

Used this to setup a YouTube like service for a media editing team on an intranet, between this guide, and a little php and SQL. Was able to deliver what they wanted without having to build a java app through Red5. Was a huge help. Didn't realize nginx could do this. Running on CentOS 6 VM via a intranet XenServer flawlessly.
Works great. Set up a Docker version of it (see https://github.com/DvdGiessen/nginx-rtmp-docker ), so installing Docker (`sudo apt-get install docker.io`) and running `sudo docker run -dp 1935:1935 dvdgiessen/nginx-rtmp-docker` should do everything.
Used the above information to port over a CentOS server, worked like a charm. Was up and running to four different stream hosts, from one source, in under an hour. Good information!
Thanks to you were able to stream our whole gaming event at school.
Twenty PC's on one server and it works fine, not on an raspberry pi but on a normal PC and of cures an 1gbit lan.
With the push function and a rented vserver streaming on multiple platforms was also no problem, one stream out to the rtmp on the vserver and than with 10gbit up to the web.
I think this guide is outdated.
It mentions version 1.15.1 at the top, then asks us do download a dev.zip file, and then extracting a master.zip file, that we haven't been intructed to download. And after that it wants us to go to a folder named nginx-1.13.1, which doesn't exist, because we downloaded the 1.15.1.

If I extract the 1.15.1 file and the dev.zip, the installation in the next steps fails.
same if I download the 1.13.1 file and master.zip, although I get a different error.

I'm using ubuntu in windows.
dodgepong
dodgepong
Hi Popupkiller,

I missed a couple spots when I recently updated the guide for a newer version, thanks. The correct files are nginx-1.15.1.tar.gz for nginx and dev.zip for the rtmp module.
You have done something wrong when it comes to installing the RTMP modules, if anyone is getting an error when configuring the RTMP config file do this >> ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-dev << As you can see, I changed the 'module' at the end to 'dev' as you are no longer downloading module.zip but dev.zip. Hope this helps some people!
dodgepong
dodgepong
Looks like that was one more spot I missed when I did the update a couple weeks ago, thanks for the catch. Sorry about that.
can i use this method to lower my cpu usage ? when i stream on my pc my cpu blows up and stream stops randomly from obs , so i was thinking maybe i can let my rasperi board handle streaming part
Good stuff to deal with ISP oversea speed throttle and lower down resource use.

There is a way to add stream key for OBS (to rtmp server)?
I'm using a VPS and this VPS also running my small website.
I'm afraid of someone will know my VPS public IP (since it can be discover by reverse website IP).
Since OBS didn't support proxy/socks so I can't tunnel to VPS to make a local proxy/socks and using block all IP from using RTMP protocol except localhost.
Thanks for writing this, it got me fairly far. However it does assume a bit of prior knowledge. I've used Linux before, but not extensively.
I found out that I needed to install unzip. I had to Google that. For newbies, it would be good to include this line before unzipping:
sudo apt-get install zip unzip

Also for the initial line:
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
I got loads of 404 errors. That's apparently because some of the paths are old. I Googled and found that the following worked:

apt-get update && install build-essential libpcre3 libpcre3-dev libssl-dev

Not sure why!

However, when I got to the end and added to the config file and tried to stream to it from OBS I just got server not found.

I used something similar to this:
rtmp {
server{
listen 1935;
chunk_size 4096;

application live {
live on;
record off;
push rtmp://live.twitch.tv/app/[streamkeyfromtwitch];
push rtmp://a.rtmp.youtube.com/live2/[streamkeyfromyoutube];
}
}
}

and streamed to rtmp://(My-IP)/live

Any thoughts on how I can debug this. I really don't like it when things don't work!
Great post! I was able to follow it and within a short period of time I have built a Docker-based solution to stream content via HLS protocol and consume it in a web application using video.js library. Here is my GitHub repo https://github.com/codeworksio/docker-streaming-server
I couldn't get this to work because I was using a network bridge, but my friend who wasn't got his to work fine. I guess just keep that inmind if you're doing this.
It took me a while to start using this feature in OBS.
For those who are having trouble transmitting to Facebook, I have adopted a very simple solution that yielded results: Just omit the Facebook server port in the nginx.conf file, like this: "push rtmp://live-api-s.facebook.com/rtmp/... "
Thus, the stream was received in the preview of Facebook.
Beside that, this solution allowed me to stop using recording settings to stream over UDP, since the RTMP stream are easily accessed through VLC.
Everything works great! However Youtube is giving me a RED stream status with the error: "Please change the video's container format. The current container format is not correct for this configuration." This seems to be a 'badContainer' error, any ideas why and how to fix? I would like a GREEN status in Youtube!
It's working but only kinda stream labs cant connect to the server but when I go in and type the server up into google it comes up just like it should and I have no clue how to fix it
Amazing guide and a powerful way to multistream with Obs Studio. Excellent! Anyone having trouble with YouTube container format I posted a solution in the discussion https://obsproject.com/forum/threads/how-to-set-up-your-own-private-rtmp-server-using-nginx.12891/page-31#post-308773
Great guide but for some reason I'm running into the same issue as another. When I stream my CPU usage goes just as high as when I'm streaming normally to twitch.
This guide finally made me get it to work! I also had to add this to the nginx config:
events { }

Something new? Not sure.
This is almost exactly the kind of thing I was looking for. Thanks for posting!
Thanks for the guide!

Here's my problem: I need to stream sports events to youtube, the camera we're using outputs to hdmi, we use an elgato usb capture device to encode the video feed and outputs it via usb to a computer. Than we grab that encoded feed with OBS and stream it to youtube. Except that the camera needs to be close to the computer (due to hdmi cable length limitations) and we'd like to put the camera farther away from the computer...

Using a raspberry and a usb capture device, would it be possible to stream to the computer over wifi or ethernet?

Something like this:
camera > usb capture card > raspberry > network > computer > youtube
Great review! I have wanted to try this for ages :D
Top