How to set up your own private RTMP server using nginx

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

Jingael

New Member
Not sure how often this thread is watched anymore, but having a bit of an issue with a more advanced configuration and not really sure where else to turn for support.

I have a custom stream site set up that was working fine, using on_publish directive for stream authentication against a database of users and assigned stream keys. Today, I enabled SSL and everything else about the site is working correctly, outside the on_publish directive. Issue #1 is that it doesn't allow me to enter an https:// link (nginx -t fails), but it sort of works if I leave it as http. However, the returned stream key sent back to the rtmp-module is the entire GET url, and not just the stream key as expected.

Here is my server block to redirect to HTTPS:

Code:
server {
        listen       80;
        server_name    my.domain.name;
        return         301 https://$server_name$request_uri;
}

With on_publish directive turned of, my.stream.key is returned correctly. With on_publish turned on, it returns:

Code:
https://my.domain.name/authcode.php?app=live&flashver=FMLE/3.0%20(compatible%3B%20obs-studi&swfurl=rtmp://my.domain.name/live&tcurl=rtmp://my.domain.name/live&pageurl=&addr=xx.xx.xx.xx&clientid=15813&call=publish&name=my.stream.key&type=live

Any ideas how I can correct this? I'm a bit puzzled why it's returning the whole URL string instead of just the my.stream.key part. Is there some way I should edit the non-SSL server block to allow for this specific file?

How do you get the stream name?

I'm trying to get a stream name as a var, but I don't know how :(

I used this:

Code:
on_publish http://localhost/panel/redir/destino1.php;

destino1.php send me a rtmp as a HTTP Location 302 and works fine (only works IPs, not domains). But the last week, Facebook's IP don't works and I changed it like this:

Code:
push rtmp://live-api-a.facebook.com:80/rtmp playpath=http://localhost/panel/redir/facebookvar.php;

or

Code:
push rtmp://live-api-a.facebook.com:80/rtmp/$playpath

But I dont know how to do

Can someone help me?

Thanks
 

ebanafea

New Member
hello guys,

i would like to ask, is there a way i can run 2 nginx streaming server in 1 machine ?
or let me explain what i was and maybe someone has a good solution for me,

i want to stream 2 videos from 2 OBS to 1 nginx server and pull 2 different streaming server.

OBS 1 + PS4 stream pushing to nginx server with twitch streaming details

OBS 2 + XBOX stream pushing to the same nginx server with hitbox.tv streaming details

and i get a video in twitch site from the twitch OBS and i get video in hitbox site from the hitbox OBS.

hope i delivered my idea,

Thanks in advanced and sorry for my difficult question,
 

yvilene

New Member
Hi, wondering if you were able to find a solution for this using nginx? I'm having the exact same issue, using my own server, streaming obs to nginx, nginx to Youtube and Periscope, Periscope acts like it sees it then the video goes into a black hole; looked everywhere. I looked at my own log file and heck if I know what's wrong or not. lol
 

paladzin

New Member
hello guys,

i would like to ask, is there a way i can run 2 nginx streaming server in 1 machine ?


and i get a video in twitch site from the twitch OBS and i get video in hitbox site from the hitbox OBS.
Yes, just make another live application in nginx conf
Code:
server {
        listen 1935;
            chunk_size 4000;

        application twitch {
            live on;
            record off;
            push twitch_url;
        }

        application hitbox {
             live on;
             record off;
             push hitbox_url;
        }
obs twitch push to nginx/twitch - twitch
obs hitbox push to nginx/hitbox - hitbox
 

Dijoncustard

New Member
Hello I came upon this Post and i and want to know if this will be the best option for what i'm trying to achieve. First i am trying to do a collective stream/Podcast where both streamers show up on one channel with both cameras showing of both streamers. The other person i am trying to do this with lives in another country so obviously the idea of just having them here is beyond an option. I am looking for the quality of the broadcast to be seamless in its audio and video just as it would be when i stream by myself. I know its possible for me to broadcast a hangouts video conversation and just use the desktop capture in obs instead of doing all this but im looking for quality and that will not do for me. Please if anyone thinks this is a suitable option or if there are other options out there to achieve this , let me klnow .

Thanks, Dijoncustard
 

zizio zozo

New Member
hello everyone.I need to manage to make a livestream system, so i can remotely stream from my android smartphone camera to OBS which is based in the different network and then put processed signal on youtube live.
i was googling about my issue and here is my option right now:

1.smartphone connects to LAPTOP OBS using WI FI,
2.using NGNIX and LTE connection i'm planning to restream singal to remote server
3.push signal to processing WIN10-PC with OBS running on
4.using this OBS, stream to youtube.live my processed signal

so my question is: how can i manage to capture RTMP signal pushed to my PC at step 3?
according to this guide NGNIX provides an option to note the link for restreaming process , so somehow i need to get a link leading to my PC and put the incoming signal into OBS. and i dont know how
help me, please!
 
Last edited:

zizio zozo

New Member
GS1tYMX.png
 

rail

New Member
is there a simpel how to, make a auth key in?
i mean, if i host this script on a dedicate server, ervy one can stream to this server, is there a way to simple protect the service? (i need it explained step by step like in this tuorial)
there is a rtmp-auth at github but i dont understand it..
https://github.com/Nesseref/nginx-rtmp-auth
 
Last edited:

caseguy

New Member
Hey all. I set up a nginx rtmp server , opened all the ports needed and tested it locally. It worked, so I set up the conf file to allow external access so I could utilize the stream outside my home network. This worked poorly at first, frequently buffering every few seconds, but then began to appear stable.

After about a half hour, it stopped working correctly. I now get a black screen whether accessing rtmp or hls.
No video at all.

Can anyone be of any help with two issues-

One- Could you point me in the right direction as to how to tweak the stream to reduce buffering every few seconds?
Two- How do I fix this black screen? It does this no matter what I am streaming and didn't occur until I used nginx for about a half hour.

Edit- This appears to be a problem with the newest version of OBS. When I used a much older version, I no longer had this problem. I noticed that the newest version immediately downgraded the stream bandwidth from 3k plus all the way back down to 150 and that this is causing the issue. When not using a new obs version and using a deprecated one, the black screen went away.

Further edit : After changing from the Nvenc media foundation to the Nvenc 264 (no media foundation) the black screen went away using the newest version of obs.

Thank you so much!
 
Last edited:

Jared Landry

New Member
Can someone help me with a config File

I have 2 pcs and one laptop

i need to take the to streams from Each PC and stream them to a laptop to combine them and then i need NGINX to push to two seperate twich channels

Whenever i try to write a Conf on my own it breaks NGINX & wont even Launch
 

Kopf02

New Member
I do not know if this is the right place for this question, but which Get / Post requests do I need to query in php, which I use with on_publish, to request the user name and the password of the authentication?

Sorry for my bad English :/
 

Kopf02

New Member
hello everyone.I need to manage to make a livestream system, so i can remotely stream from my android smartphone camera to OBS which is based in the different network and then put processed signal on youtube live.
i was googling about my issue and here is my option right now:

1.smartphone connects to LAPTOP OBS using WI FI,
2.using NGNIX and LTE connection i'm planning to restream singal to remote server
3.push signal to processing WIN10-PC with OBS running on
4.using this OBS, stream to youtube.live my processed signal

so my question is: how can i manage to capture RTMP signal pushed to my PC at step 3?
according to this guide NGNIX provides an option to note the link for restreaming process , so somehow i need to get a link leading to my PC and put the incoming signal into OBS. and i dont know how
help me, please!

First of all you can use this: https://play.google.com/store/apps/details?id=com.miv.rtmpcamera or https://itunes.apple.com/us/app/broadcast-me/id491982406 instead of using a laptop at step 2.
And for your Problem: Just use media source with your rtmp address and as format just use rtmp ;)
 

6ix

New Member
I have been using this for some time now for a dual pc setup. Is there any way to improve the latency in making it more static and less variable? How many Mbit are most of you people feeding your second PC? I'm doing about 20000 bitrate from OBS on my game pc to my stream pc.
 

myohmyke

New Member
I set up the RTMP using this guide on a DigitalOcean Linux server. The important parts are working, but I looked into finding a way to see what stream keys were in use (someone's streaming to the RTMP and forgot to switch back to their 'home' channel), but all of the options on the configuration page make my head swim. I added

Code:
location /control {
           rtmp_control all;
       }

under the Server section, but going to
<ip>:66/control bring up nothing, while <ip>:66 brings me to the "Welcome to nginx" page. What would I need to do to A) See what stream keys/connections/whatever are being used, and B) bop someone off the server if they're not supposed to be there?

Would the best thing be to make a list of 'valid' keys instead -- and if so, what's a good way to go about that?

Thanks!
 

Jack0r

The Helping Squad

Eric Schmidt

New Member
When I try to follow the tutorial, I always get an error in the ngix log (using the linked to Windows builds):
[emerg] 8572#3080: unknown directive "rtmp" in C:\nginx/conf/nginx.conf:182
This has happened across 2 different systems. If I delete the RTMP reference from nginx.conf I get no error. Am I somehow missing the RTMP module?
I appreciate any insight the forum can provide...
 

dodgepong

Administrator
Community Helper
Yes, you are missing the RTMP module. Which version did you download from the linked site?
 
Top