How to set up your own private RTMP server using nginx

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

Selzier

New Member
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!

Thanks for any tips.
 

Fenrir

Forum Admin
You will need to provide your config for us to answer that. Remove any sensitive information first.
 

Selzier

New Member
Here is the config file for nginx:

nginx_conf.jpg


And here is my OBS output settings:

obs_output_conf.jpg
 

Selzier

New Member
I've made a video tutorial for this guide which shows how to setup OBS with nginx on a VPS windows server from Amazon AWS. Glad to hear I didn't mess anything up, the container error from youtube seems completely irrelevent and stream works great.

 

hew34

New Member
YouTube say they want things in an FLV container to get rid of that error - I am thinking of using ffmpeg to convert to FLV before sending to YouTube... I know the stream works fine - but I just don't want to have to put up with the warnings on my dashboard :P
 

theherobilly

New Member
I'm trying to host a server for multiple people to stream to, but I'd like to have it so I don't have to change configs for people different people to stream, or have multiple people stream at once, how would I go about doing that?
 

Parapac

New Member
This is a great Idea and when I get it working fantastic, thanks for this. but sorry newby here. I set up as the install notes on the setup. I have the nginx server on a Raspberry pi 3 with an x300 addon board
trouble is I cannot start nginx rtmp its saying:
Code:
nginx : [emerg] "rtmp" directive is not allowed here in/usr /local/nginx/conf /nginx.conf
I have tried from the Raspberry and via ssh from Win10
 

Fenrir

Forum Admin
This is a great Idea and when I get it working fantastic, thanks for this. but sorry newby here. I set up as the install notes on the setup. I have the nginx server on a Raspberry pi 3 with an x300 addon board
trouble is I cannot start nginx rtmp its saying:
Code:
nginx : [emerg] "rtmp" directive is not allowed here in/usr /local/nginx/conf /nginx.conf
I have tried from the Raspberry and via ssh from Win10

This means you are either putting the RTMP directive in the wrong block location, or you have not compiled nginx with the rtmp-module support.
 

Fenrir

Forum Admin
I'm trying to host a server for multiple people to stream to, but I'd like to have it so I don't have to change configs for people different people to stream, or have multiple people stream at once, how would I go about doing that?

Stream key in OBS will let you stream multiple times to the same nginx-rtmp application.

For example, if you set the stream key to Stream1 and your application is called live in the nginx config, your full playback would be

rtmp://server.ip/live/Stream1

You can set the stream key to whatever you want and each user will have a unique playback URL.
 

Parapac

New Member
Sorry for the delay in getting back to you Fenrir, I shall try and look deeper in the install I did on the raspi, I thought maybe it was a password thing.
 

Mike Russell

New Member
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!

Thanks for any tips.

I was struggling with this error and have the solution. You just need to use ffmpeg to change the container format without re-encoding. This command will not place a big strain on your CPU as it is simply changing the container and not re-encoding your whole stream. Enter this line in the rtmp section of your nginx.conf file with your correct stream key:

Code:
exec ffmpeg -i rtmp://localhost/live/$name -codec copy -f flv rtmp://a.rtmp.youtube.com/live2/<STREAM KEY>;
 
Last edited:

Fenrir

Forum Admin
I was struggling with this error and have the solution. You just need to use ffmpeg to change the container format without re-encoding. This command will not place a big strain on your CPU as it is simply changing the container and not re-encoding your whole stream. Enter this line in the rtmp section of your nginx.conf file with your correct stream key:

Code:
exec ffmpeg -i rtmp://localhost/live/$name -codec copy -f flv rtmp://a.rtmp.youtube.com/live2/<STREAM KEY>;

This is curious, since RTMP only supports FLV. Just as FYI. Wonder why that fixes it? Strange.
 

Parapac

New Member
sorry guys I am still having problems, I have tried on a linux machine as well as the raspberry pi3... and its still saying.....

Code:
pi@x300rp3:~ $ sudo /usr/local/nginx/sbin/nginx -s stop
nginx: [emerg] "rtmp" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:117
'
The server runs in the web page if I delete the lines... "rtmp onwards...



Code:
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                }
        }
}
Everything is installed as above, I think (no idea really) that the problem is the lines rtmp onwards in the nginx. dot config
 

regstuff

Member
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!

Thanks for any tips.

I've been using nginx to stream to multiple locations, and I have not come across any such issue on YouTube. I haven't been using an instance on the cloud though. I have nginx on my local system. I stream from OBS to nginx on 127.0.0.1 and have nginx push to multiple destinations from there.Not sure if the local/cloud instance makes the difference.
 

RobertoT

New Member
I tried this on a VM instance through google cloud, and I believe I've done everything right, but when I attempt to connect the connection times out, and fails to connect to the server. The only difference from what I did and this guide was install nginx 1.13.4 being the latest patch

Any help would be appreciated.
 

6ix

New Member
My rtmp_error.log file for Windows was 750GB. Any way to disable error logging? Itgrows at about 1KB/s.
 

regstuff

Member
My rtmp_error.log file for Windows was 750GB. Any way to disable error logging? Itgrows at about 1KB/s.

Open your nginx.conf file and look for this line: error_log logs/rtmp_error.log debug;
Change it to: error_log logs/rtmp_error.log notice;
 

regstuff

Member
I tried this on a VM instance through google cloud, and I believe I've done everything right, but when I attempt to connect the connection times out, and fails to connect to the server. The only difference from what I did and this guide was install nginx 1.13.4 being the latest patch

Any help would be appreciated.
Did you check your instance Firewall settings? By default, ingress over port 1935 (RTMP) would be blocked. You have to add a firewall rule to allow it. You can do that here: https://console.cloud.google.com/networking/firewalls/list
 
Top