How to set up your own private RTMP server using nginx

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

jesterjosh

New Member
rtmp.PNG
rtmperror.PNG
I'm at a loss here. I've followed the tutorial and added the lines to the config file like suggested but I get a simple syntax error that I can't seem to figure out. Any help would be appreciated. Thanks.

Nevermind, I figured it out. There error is misleading. I was actually missing semicolons at the end of the push commands.
 
Last edited:

Fenrir

Forum Admin
Nevermind, I figured it out. There error is misleading. I was actually missing semicolons at the end of the push commands.

The error isn't so much misleading as it's explaining where it first encountered an issue. Without the ; to indicated end of directive, it's assuming that each new line after is part of the same directive string. When it hits a } to close the block, there's unfinished directives, and it throws an error.

Glad you figured it out!
 

Hagstrom

New Member
Thank you for your reply. Much appreciated. Is there anyone here that knows who I can hire to make such server.

And will this server be multi device usable.

Regards
 

Fenrir

Forum Admin
Thank you for your reply. Much appreciated. Is there anyone here that knows who I can hire to make such server.

And will this server be multi device usable.

Regards

The server can handle multiple connections, assuming different stream keys.

I'd be happy to set up a server for you, but it will probably cost you more than you are willing to pay.
 

Hagstrom

New Member
Ok send skype request to ddecanter. With the understanding I will not bother you after we discuss fees and what I receive for fees until it is time to do the job.
By the way this is an awesome forum.

Regards
 

currentyear

New Member
Hi there. I got this working no problem. However, I can't seem to use my domain as the rtmp url.

Could this be a cloudflare issue? I changed the port to a port cloudflare allows (8080), and it is allowed in iptables. it works using rtmp://myip:8080/live

however using rtmp://mydomain.org:8080/live does not work.

At first I thought it was how my nginx.conf was setup, due to it using sites-enabled virtual host block, and rtmp needing to stay in nginx.conf.

I setup nginx again so my site is in nginx.conf instead of a virtual host block in sites-enabled, and the site works, rtmp works via ip, but still luck via domain.

Is this just a cloudflare issue?

Code:
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  mydomain.org;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

}

rtmp {
        server {
                listen 8080;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                        #on_publish http://myip/auth.php;
                        #notify_method get;
                        #these two are for authentication, disabled to test this issue.
                }
        }
}

this is a basic nginx conf I used to test site & rtmp. Both work, site works via domain, rtmp only through ip.

So am I doing something wrong, or is it cloudflare?
 

Hoerli

New Member
Hi!
I stream in 1080p and 4700kbps. Some Platforms don't want this good quality and allow only 3500kbps.
Now i want to Stream to Twitch, HitBox, YouTube,.. with 4700kbps and to other servers in 720p or something and 3500kpbs or lower.

Anyone who have a good Config for that?

Is it enough if i add this Code for the other plattforms?
Code:
exec ffmpeg -re -i rtmp://localhost:1935/transcode/test -Some good Quality-settings who i can find in this forum... rtmp://other-plattform:1935/live/test;


I'm not sure on which line of Code i should use :)
 

Tony32

Member
If I stream at 1080@60 to my NGINX server and want to encode it but let it stay at 1080@60, what would the best ffmpeg command be? Do avoid it doing unnecesary downscale command or something? :P
 

Fenrir

Forum Admin
If I stream at 1080@60 to my NGINX server and want to encode it but let it stay at 1080@60, what would the best ffmpeg command be? Do avoid it doing unnecesary downscale command or something? :P

I'm not sure why you would want to re-encode the stream to the same quality?
 

Fenrir

Forum Admin
Not same quality. Streaming using NVENC with 50mbit to the encoding pc, over there it's gonna get encoded to bitrates for twitch/hitbox. Aka 3500-4500.

1080p 60fps isn't really possible at those bitrates. Twitch's max is 3500, and that's barely enough to make 720p 30fps look decent.
 

Tony32

Member
1080p 60fps isn't really possible at those bitrates. Twitch's max is 3500, and that's barely enough to make 720p 30fps look decent.
But it isin't. You can stream usng more than 3,5k. It just limits your potential veiwers. So for my question, what would the ffmpeg line be for not doing unnecesary lines that scales it? just re-encodes the incoming stream to lower bitrates without modifying scale and such? I use the -s 1920x1080 line, but I'm not sure if its needed or not as it's already in 1920x1080@60
 

Jack0r

The Helping Squad
Fenrir is certainly correct: Official maximum bitrate you should use communicated by Twitch.tv is 3500. Of course you are free to use your own values, we cannot stop you from doing that, but twitch has the right to close down your stream if they want to.
Now to your question, if your input res/fps is the same as the output, you just have to tell ffmpeg which bitrate, encoder and preset to use.
 

Tony32

Member
Fenrir is certainly correct: Official maximum bitrate you should use communicated by Twitch.tv is 3500. Of course you are free to use your own values, we cannot stop you from doing that, but twitch has the right to close down your stream if they want to.
Now to your question, if your input res/fps is the same as the output, you just have to tell ffmpeg which bitrate, encoder and preset to use.
Thank you mate. So no need for the -s flag and -r flag? And how about the filter flag? lanczos/Billneaer
 

t0mi

New Member
hello! is it somehow possible if a streamer have a short disconnect (~2min) to show an alternative stream?
if yes can you show me an example? rmtp server is a remote dedicated server


E: or a video, its because if stream goes offline on twitch there is a huge viewer loss, i would pay for any help
 
Last edited:

Fenrir

Forum Admin
hello! is it somehow possible if a streamer have a short disconnect (~2min) to show an alternative stream?
if yes can you show me an example? rmtp server is a remote dedicated server


E: or a video, its because if stream goes offline on twitch there is a huge viewer loss, i would pay for any help

You could rig something up using https://github.com/arut/nginx-rtmp-module/wiki/Control-module to drop an active streamer and allow another one to connect. But there's nothing built-in that would explicitly allow for this.
 

PenguinSix

New Member
Has anyone got a setup like this to work with the new Periscope Producer? It is just an RTMP server address and key, but when I put in the 'push' nothing appears in Periscope Producer's settings page. I've actually tried streaming to both Youtube and Periscope and the Youtube functions fine, but the Periscope goes into a black hole.

Streaming direct from OBS to Periscope works, or from the App Cameleon to both Youtube and Periscope, but can't make the NGINX solution outlined above work. Wondering if anyone else has had some success.
 

Fenrir

Forum Admin
Has anyone got a setup like this to work with the new Periscope Producer? It is just an RTMP server address and key, but when I put in the 'push' nothing appears in Periscope Producer's settings page. I've actually tried streaming to both Youtube and Periscope and the Youtube functions fine, but the Periscope goes into a black hole.

Streaming direct from OBS to Periscope works, or from the App Cameleon to both Youtube and Periscope, but can't make the NGINX solution outlined above work. Wondering if anyone else has had some success.

Have you checked your nginx access and error logs to see if there's anything there that might indicate what's going on? I would normally be happy to test, but they've locked Periscope Producer behind a registration/approval process, so I don't have access to their services to see how things are set up.
 

avstaff

New Member
Hi everyone
Has anyone tried setting this up with the new ubuntu bash native set up in windows 10 (https://msdn.microsoft.com/en-us/commandline/wsl/about)?

I managed to do all the steps correctly, however once I ran the server, I came across a few errors like this:
Code:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

Then I read somewhere that windows uses http port 80
so I changed the config file to have the http server point to port 81

unfortunatly on obs side, the 'start stream' button would stall on 'connecting'

I tried adding port 81 to the firewall, and wasn't successful.

Let me know if anyone has a good way of doing this. Thanks!
 
Top