How to set up your own private RTMP server using nginx

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

Laurent Coiteux

New Member
Good day all,

I am pretty new to this. I set up the server on my raspberry pi 3 (debian) and was able to make it work by following the guide (that is great). But now I would like to add 3 of my other friend stream so that I can combine the 4 stream to go to my twitch. Anyone can give me an hand or direction ?

Thank you.
 

InfinateAnswers

New Member
Hello!

Thank you for the wonderful tutorial, my friend and I have set up an RTMP server on his local windows computer and it works great for his local network. He is pulling his stream from one computer to the other using Media Source. However, when we set up a VPN so that I can send my stream to the RTMP server, Media Source isn't picking up audio/video. The stream connects just fine through hamachi to his RTMP server. The source from his computer is using his local IP and the source for mine is using the hamachi generated IP. i.e. rtmp://192.168.0.1/Stream1/Key1 and rtmp://200.11.12.300/Stream2/Key2

*Note: his local stream IS working, just the VPN isn't picking up audio/videa

Code:
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application Stream1 {
                        live on;
                        record off;
                        }
            application Stream2 {
                        live on;
                        record off;


                }
        }
}
 

BreakTV

New Member
Hey guys i have a problem, i'm trying to make this work but i have some isues, even when i start the nginx and type the ip adress in my broswer, the page doesn't load. Can someone help me ?
 

regstuff

Member
I'm setting this up on an Amazon instance. About 10 connections will be redistributing out from the RTMP server. Anyone have any recommendations if I should choose a particular drive option like SSD with high IOPS? Amazon's default drive gives 3IOPS/GB. Would that be a constraint if I had a 20gb drive and 10 outbound connections with 2mbps each?
 
Good day all,

I am pretty new to this. I set up the server on my raspberry pi 3 (debian) and was able to make it work by following the guide (that is great). But now I would like to add 3 of my other friend stream so that I can combine the 4 stream to go to my twitch. Anyone can give me an hand or direction ?

Thank you.

When you say "combine the 4 streams to go to your twitch", do you mean you want all 4 streams to appear in the same video? If so, that is beyond the capabilities of the nginx RTMP module, as it involves compositing and re-encoding all the video feeds into a new, single video feed.

A number of charity events have used the RTMP module to act as their own Ingest server, much like how Twitch has their Ingest servers. The server owner would then play the incoming video in their own copy of OBS, and they themselves would send that broadcast out to twitch. This way the charity stream would never drop, they wouldn't have to hand out their Twitch stream key to the other broadcasters, and those broadcasters would have a scheduled time that they would have to connect to the Charity's RTMP server to be ready for when the Main Charity Broadcaster sends them live.
 

Tarumes

Member
Note to Windows users:
http://nginx-win.ecsds.eu/download/

- rtmp, 1.7.12.1 is the last free version with rtmp, we do have a rtmp
special offer for the 1.9 branch (which without rtmp you could use
to tcp load balance 1.7.12.1 with rtmp)

Commercial subscription only modules:
...
= Streaming with nginx-rtmp-module
...
 

Robert Rundle

New Member
I would appreciate some help from those in the know.

I have setup nginx on AWS windows server and can stream to it from OBS without a problem. I can see the stream files being created. I have hopefully configured it all for HLS stream, having followed this guide https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/#6-add-peers

however, I just cannot connect to the stream either from VLC for a web player. I have set the firewall exceptions up to allow traffic through on ports 1935,80, 8080. My conf file is below. Any pointers would be appreciated.
Thanks

{
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;

application show {
live on;
# Turn on HLS
hls on;
hls_path c:/nginx/mnt/hls/;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
deny play all;
}
}
}

http {
sendfile off;
tcp_nopush on;
#aio on;
directio 512;
default_type application/octet-stream;

server {
listen 8080;

location / {
# Disable cache
add_header 'Cache-Control' 'no-cache';

# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';

# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}

types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}

#c:/nginx/mnt/;
}
}
}
 

Robert Rundle

New Member
try this in vlc replace <serverip> and <streamkey> with your settings
rtmp://<serverip>/show/<streamkey>
Yep, have tried that and most variations of, including the port number after the server ip. Any different options for connecting to the stream to test?
Thanks
 

Tarumes

Member
Yep, have tried that and most variations of, including the port number after the server ip. Any different options for connecting to the stream to test?
Thanks

Try this config

RTMP server URL = rtmp://<serverip>/live
Streamkey = stream

VLC HLS link = http://<serverip>:8080/hls/stream.m3u8

Code:
worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;

        application live {
            live on;
            push rtmp://127.0.0.1/hls/stream;
        }
      
        application hls {
            live on;
            hls on;
            hls_path temp/hls;
            hls_fragment 8s;
        }
    }
}

http {
    server {
        listen      8080;
      
        location / {
            root html;
        }
      
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html;
        }
      
        location /hls {
            #server hls fragments
            types{
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            alias temp/hls;
            expires -1;
        }
    }
}
 

willowen100

New Member
Hi everyone

I'm wanting to setup NGINX so that I can stream from OBS to Twitch, YouTube and a WordPress site simultaneously. For the basic setup of all three services to have the same bandwidth being fed from OBS is very simple. However, I would like to have OBS at it's highest quality and then transcode at NGINX using ffmpeg so Twitch and YouTube output at 6Mbps to their servers, and the remaining bandwidth I would like to leave for my website. I'm not worried if the stream for the viewers is slightly delayed if the encoding need time, so long as all three streaming services are receiving their respective bandwidth. Is this possible to do?

Many thanks

Will
 

regstuff

Member
Hi everyone

I'm wanting to setup NGINX so that I can stream from OBS to Twitch, YouTube and a WordPress site simultaneously. For the basic setup of all three services to have the same bandwidth being fed from OBS is very simple. However, I would like to have OBS at it's highest quality and then transcode at NGINX using ffmpeg so Twitch and YouTube output at 6Mbps to their servers, and the remaining bandwidth I would like to leave for my website. I'm not worried if the stream for the viewers is slightly delayed if the encoding need time, so long as all three streaming services are receiving their respective bandwidth. Is this possible to do?

Many thanks

Will
It's possible. This might be of interest to you: https://github.com/arut/nginx-rtmp-module/issues/455
 

Flimmykins

New Member
hey, so I've been messing around with this recently mostly out of boredom. My aim was to set it up so I can have a stream embedded on a page on my website, so I can link 1-2 friends once I'm streaming instead of using twitch/mixer/etc. Right now I have it so nginx is set up on a Windows AWS, and my OBS connects to the IP via there.

So I kind have two things here:
1. Are there any specific settings I can use in my nginx config to decrease the delay of HLS as much as feasible? Right now it's about 10 seconds, is lower possible?

2. If not, does anyone have a simple way of embedding an RTMP stream into a html page? I've tried so much with older versions of video.js and such with flash enabled, but I just keep running into issues getting it to work. If I directly link people the rtmp url, then it works in vlc, etc but I just can't get it in a browser.
 

kukurigu

New Member
Hello . I have a Hikvision camera and working with obs, but after 10 minute the image is intrrerupting! What can I do?? Can help me someone?
 

Tarumes

Member
hey, so I've been messing around with this recently mostly out of boredom. My aim was to set it up so I can have a stream embedded on a page on my website, so I can link 1-2 friends once I'm streaming instead of using twitch/mixer/etc. Right now I have it so nginx is set up on a Windows AWS, and my OBS connects to the IP via there.

So I kind have two things here:
1. Are there any specific settings I can use in my nginx config to decrease the delay of HLS as much as feasible? Right now it's about 10 seconds, is lower possible?

2. If not, does anyone have a simple way of embedding an RTMP stream into a html page? I've tried so much with older versions of video.js and such with flash enabled, but I just keep running into issues getting it to work. If I directly link people the rtmp url, then it works in vlc, etc but I just can't get it in a browser.

1. more cpu and faster hdd/ssd

2.rmtp without flash or vlc nope
https://developer.mozilla.org/en-US...o_delivery/Live_streaming_web_audio_and_video

Hello . I have a Hikvision camera and working with obs, but after 10 minute the image is intrrerupting! What can I do?? Can help me someone?
this happen if your bitrate is too hight maximum is 15000kbits
 
Top