How to set up your own private RTMP server using nginx

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

Fenrir

Forum Admin
is it at all possible to send video to Twitch as normal, but also host a video, but the hosted video is delayed by, say, 5-10 seconds?

Reason: I am working on a way to do an Instant Replay for my stream. Currently, I can just use a Window Capture of our own stream via our Twitch channel, but the delay is so variable it could be 8 seconds, it could be 30.

Being able to send video as normal to Twitch, but have another copy of the feed that has a much lower delay (from my own server) would make this hacked together method of Instant Replay much more "instant"

Assume you're not transcoding, the delay from your own server and then that of twitch should already be much, much lower. Twitch transcodes pretty much all incoming streams, which adds a significant delay. If you stream to your own server, and then push the stream to your twitch channel, you should get the results you're looking for.
 

Joe Blair

New Member
I used this guide to set up RTMP on my computer running Ubuntu 14.04 and on the LAN I have about 4 second delay. I'm wondering if there's anyway I would be able to reduce that to maybe 1-2 seconds?
Both the computer I stream (running Windows 8) from and the one running the RTMP are pretty powerful, both running i5s.
21dKnwT.png

UMW1REQ.png

ePfV1HZ.png
 

complice

New Member
Hello, please help me with an complete configuration example of the server to broadcast live, recording on the server and transmit the stream to ustream, youtube etc. Thanks
 

Maxunit

New Member
Hello OBS Community,

I am currently trying to set up a Streaming Service and already compiled NGINX with RTMP and Secure Links. I also have Secure Links set up in the nginx.conf by following this tutorial:

http://www.helping-squad.com/nginx-rtmp-how-to-use-secure-links/

At the bottom is the info, that this method can be used to create Keys for Streamers and Visitors. Sadly I cannot figure it out right now :/ Is someone interested in pointing me to the right direction to achieve that goal?

Greetings,

Maxunit
 

Brian Shock

New Member
Question: Can anyone tell me about the differences in RTMP response of JPlayer vs. JWPlayer, in regard to playing video with the OBS-Nginx setup?

I've enjoyed reading through this thread. Dodgepong and Jack0r in particular have had some incredibly helpful, instructive responses, and I've implemented a few of them, some that work and some that don't.

General situation: My project requirements specify streaming live video on Windows, over a network, to IE. We're going cheap on this, so we need to start with open source code. OBS is a great beginning, and the Win32 NGinx with RTMP seems to work well with it. I can play the streamed video with VLC (initial testing) and with a web page using JWPlayer (an undesirable pay application that reports connections to IPs all over the globe; no joke -- packet sniff it someday and then track down some of those IPs). However, when I try a demo web page with JPlayer (the free and open one), I can't make an RTMP connection.

Is my JPlayer demo page working correctly? Yes, as far as I can tell. I can play various other RTMP streaming URLs.

Do I receive any console log errors in my browser? No. None at all.

What errors does Nginx report? None. Everything runs normally. Access log also reports a normal connection, even though nothing is displayed on the JPlayer side.

What happens in terms of RTMP packets between client and server? Handshakes 1, 2, and 3 occur. Everything looks fairly good (as compared with the successful connections I've seen with other RTMP streaming URLs), though an Invoke to the client seems to be missing. Before the packet stream starts, though, the client sends a [FIN,ACK]. After shutting down the exchange of packets to the server, nothing else happens.

Note that I've tried this with both the Win32 Nginx and the Linux version (on a Ubuntu VM). Exactly the same results occur. My nginx.conf file looks exactly like the one in Jack0r's guide. In fact, I've tried to follow these instructions as precisely as possible.

While I can demonstrate proof of principle to my employers using the OBS-Nginx-JWPlayer demo, they're definitely going to reject JWPlayer as a final solution. It seems like Nginx-RTMP isn't supplying something fundamental that JPlayer needs to play streaming video. I would be grateful if anyone had some ideas about what that might be, or better still, what's really going wrong.

Thanks!
 

Jexner

New Member
Hi
How do you make a rtmp player load the stream automatically after the streamer has started?
Because right now when a viewer loads the player(jwplayer or video.js) he doesn't get anything until the streamer restarts his stream via obs.

edit: we got it working, it was because we were using a older version of nginx with a newer version of rtmp module
 
Last edited:

Dakser

New Member
Hi, excuse me, could yo help me to understand what is the URL to play the HLS stream? Right now i could pull an RTMP stream and play it local, but i cant find the way to play it in HLS. This is my conf:

Thanks in advance.

Code:
rtmp {
    server {
        listen 1935;
        application tv {
            live on;

            hls on;
            hls_path /tmp/tv2;
            hls_fragment 15s;

            pull rtmp://23.239.29.126:1935/livepkgr/livestream?adbe-live-event=liveevent live=1;
        }
    }
}

http {
    server {
        listen 80;
        location /tv2 {
            alias /tmp/tv2;
        }
    }
}
 

Dakser

New Member
Hi, excuse me, i think it's working now, i have changed my conf and now i get response from: http://192.249.64.174:8010/tv2/livestream.m3u8
But it does not play any stream. It's only audio stream. I'm testing with Jwplayer wizard. http://www.jwplayer.com/wizard/
I'll appreciate a lot any of your help.

My conf:
Code:
rtmp {
    server {
        listen 1935;
        application tv {
       

    live on;

            hls on;
            hls_path temp/tv2;
            hls_fragment 15s;

            pull rtmp://23.239.29.126:1935/livepkgr/livestream?adbe-live-event=liveevent live=1;
        }
    }
}


http {
        server {
        listen 8010;
        location tv2 {
            types {
                application/vnd.apple.mpegurl m3u8;
            }
            root temp;
            add_header Cache-Control no-cache;
        }
    }
}
 

Dédé

New Member
Hello World !

Nice guide ! Only a few minutes to have a server ready for streaming :)

I am
However, I am trying to setup a streaming server, that can produce MPEG-DASH live streams.

Here is my config :
Code:
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  8192;
    # max value 32768, nginx recycling connections+registry optimization =
    #   this.value * 20 = max concurrent connections currently tested with one worker
    #   C1000K should be possible depending there is enough ram/cpu power
    # multi_accept on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    server_names_hash_bucket_size 128;

## Start: Timeouts ##
    client_body_timeout   10;
    client_header_timeout 10;
    keepalive_timeout     30;
    send_timeout          10;
    keepalive_requests    10;
## End: Timeouts ##

    gzip  on;

    server {
        listen       80;
        server_name  localhost;
   
        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
       
        location /dash {
            alias dash;
            add_header Cache-Control no-cache;
            types {
                application/dash+xml    mpd;
                video/mp4    m4v;
                audio/mp4    m4a;
            }
        }
       
        location /hls {
            alias hls;
            add_header Cache-Control no-cache;
            types {
                application/vnd.apple.mpegurl m3u8;
            }
        }
    }
}

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                       
                        publish_notify on;
                        play_restart on;
                       
                        wait_key on;
                        wait_video on;
                       
                        dash on;
                        dash_path dash;
                        dash_cleanup on;
                       
                        hls on;
                        hls_path hls;
                        hls_fragment 5s;
                        hls_cleanup on;
                        hls_type live;
                }
        }
}

I have a simple index.html file that display the original stream in 3 formats : RTMP, HLS, MPEG-DASH.
For RTMP, I use jwPlayer, it works.
For HLS, I use jwPlayer, not working, but using VLC, it works.
For MPEG-DASH, I am using the dash.js lib, but streaming does not work, even using VLC.

All the DASH files are generated, files are downloaded, but no video is displayed. Do you think a transcoding may be needed ?

I would like to use MPEG-DASH to have the benefits of HLS, without having to include flash in my app...

Thanks.
 

PeterFour

New Member
I successfully follow this tutorial to stream on my local machine but when I want playback the stream on vlc, it says that it can't read the video, but the audio is fine (I used Vlc 2.1.5) what can be the problem?
 

Kane

New Member
What causes the 3 second delay? I mean I'm going to encode it over on the master machine over lan. Would it be better not to compress it as much? Or would there still be a delay? Sorry it was just at the start of this guide i heard something about newer version OBS has like no delay but i might of been misunderstanding.
 

Kane

New Member
So I thought this would work but I'm pretty screwed. I was hoping a q6600 OC would be able to handle the incoming RTMP connections and use the OBS Video input plugin and be able to encode lol.
 
Got a question about the on_publish directive.

Does that directive fire if I was to start streaming to my Nginx RTMP server?

Use case: I am working on a bot for our Twitch channel that will cycle thru different streamers and host their channel if they are online, but stop hosting when I go live. For some reason Host mode doesn't seem to turn off automatically when I go live, and the Twitch API wasn't reporting that I was live while Host mode was active. This could have been a bug on Twitch's part or just a fluke. I figured if I could make my RTMP server tell my bot via an HTTP request that I am broadcasting, the bot could then unhost any channel currently being hosted.

Thanks in advance
 

Jack0r

The Helping Squad
Yea, to my knowledge thats the directive you would need for that.
I would test a bit though, maybe it was just twitch being slow?!
 

StallionFire

New Member
Is there a guide for installing this on Windows Server 2012 ? I want to stream to my Server 2012 and then have it render and sent it to Twitch.tv . The main reason I want this is to make the server do all the work instead of my PC.

Is there a guide for Windows instead of Linux?

I see this in your guide but no further instructions or links to any guides:

Note to Windows users: This guide focuses on using Linux. If you want to use Windows, you can find Windows binaries for nginx with the RTMP module already included here: http://nginx-win.ecsds.eu/

I need a step by step setup guide for Windows Server 2012 Standard if there is one.

Can it run beside iis8 ?

Can it be run on a Windows Server 2012 VM ?
 

dodgepong

Administrator
Community Helper
Does your PC support encoding via Quicksync or NVENC? And is the server on the same LAN as you?
 
Top