How to set up your own private RTMP server using nginx

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

Tomasz Góral

Active Member
The problem with nginx was solved by changing worker threads to 1. Any higher number and OBS disconnects at random times.

As for getting the stream to be SSL, I'm still working on that because some folks are afraid to go to a non secure site and the browser warns them as if they are entering a malware site.

And finally, I have a lag of a bout 40-50 seconds between activity on camera and when it appears in the web player. nginx has a huge playlist with over 20 fragment files. I wonder if that's why? I'd like to get this delay down to 5 seconds or so, but not sure how the fragment and other commands in nginx.conf work.
5 sec is not real, use LL-HLS but must change server because nginx-rtmp not working with LL-HLS (sub-second mode).
But if you want :
- keyframe set to 1 sec
- segment size set to 1 or 2 sec
- minimum segment list set to 3
now you got 6 second lags.
 

kitten_kiwi

New Member
Hi, first of all, thanks for this wonderfull guide! now i have just a few questions...
i plan on streaming via my mobile phone on a 4G or 5G network which is sadly not so reliable as i whished. is there an option i can set up so if the Input stream stops, it starts sending a "currently disconnected, but please stand by" media file till the connection is back but doesnt disconnect the output to Twitch, FB, TikTok what ever... ?

i just say thanks in advance, even if there is no way currently.

Love Kim
 

Mark Weiss

Member
5 sec is not real, use LL-HLS but must change server because nginx-rtmp not working with LL-HLS (sub-second mode).
But if you want :
- keyframe set to 1 sec
- segment size set to 1 or 2 sec
- minimum segment list set to 3
now you got 6 second lags.

I find that shorter segment list DOES work, but that playback in a browser freezes after a short time.

I finally did get most everything working well. My delay is down to 11 seconds simply by changing GPU to the Intel 630.

I also managed to get the stream files served by my IIS 10 server (had to add MIME type .m3u8 to make it work. So now my live stream is embedded in an iFrame in my main web page. It's wonderful.

Only thing is my friends in Japan have difficulty getting the stream to play. It plays well in Brazil and North America though.
 

alp35035

New Member
Just to give back to the community. For new users on windows to OBS and NGINX, here is a portable version to learn with done by ustoopia on github https://github.com/ustoopia/Live-stream-server-portable-Windows-Nginx-RTMP-HLS-Dash.

Second, both HLS and Dash work at 30fps on high with a card like the gtx 1660 Super on all high settings using NVENC h.264 and AMD A10 older processor . However, if you run at 60 fps, the Dash player will start playing and freezing. I narrowed down the issue to keyframe intervals. At 30fps, even 48fps 2s works reasonably well. To get 60fps to work you have to increase the keyframes closer to 10s or the dash player will act like it is buffering.

Hopes this helps.
 
Top