arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.41k stars 3.51k forks source link

[HELP] Republish single stream #999

Open cgtarmenta opened 7 years ago

cgtarmenta commented 7 years ago

I wanna know if i'ts possible to republish one single stream from an aplication, instead of republishing all.

I've got something like this;

application myrepublishapp {
    live on;
    record off;
    allow publish all;
        deny play all;

    #hls on;
        #hls_path /home/myrepublishapp;
    #hls_nested on; 
    push_reconnect 1s;
    push rtmp://otherserverip:port live=1 app=appintheotherserver;
}

but it republish all the streams that came to the app to the "other server" any suggestions?

any sugestions?

coditori commented 7 years ago

What is different between that one with others!? take a look at https://github.com/arut/nginx-rtmp-module/wiki/Directives#on_publish

cgtarmenta commented 7 years ago

when you use "push" directive, all the streams that arrives to that application are republished to the server specified.

lets say, we have 3 servers with 3 diferent apps

#SERVER 1 
application myrepublishapp {
    live on;
    record off;
    allow publish all;
    deny play all;

    push_reconnect 1s;
    push rtmp://server2:port live=1 app=hls_for_clients;
    push rtmp://server3:port live=1 app=dash_for_clients;
}

#SERVER 2 
application hls_for_clients {
    live on;
    record off;
    allow publish all;
    deny play all;

    hls on;
    hls_path /home/hls_for_clients;
    hls_nested on;  
}

#SERVER 3 
application dash_for_clients {
    live on;
    record off;
    allow publish all;
    deny play all;

    dash on;
    dash_path /home/dash_for_clients;
    dash_nested on; 
}

The above configuration works perfectly; I'd just send my streams to my republish server, and i can play any of my streams on any of my edge servers.

But recently I've face a situation where i was in the need to republish one of my streams to another server, but only one, so i've solved it like this:

#SERVER 1 
application partner_republish_app {
    live on;
    record off;
    allow publish all;
    deny play all;

    push_reconnect 1s;
    push rtmp://prtnersip:port live=1 app=hls_for_clients;

    push rtmp://127.0.0.1:port live=1 app=myrepublishapp;
}
application myrepublishapp {
    live on;
    record off;
    allow publish all;
    deny play all;

    push_reconnect 1s;
    push rtmp://server2:port live=1 app=hls_for_clients;
    push rtmp://server3:port live=1 app=dash_for_clients;
}

Then, i've edit the source of the stream, to point it to the new app, that republish it to my partner's server, and to my original app.

So, I wanna know if it is possible to do something like:

application myrepublishapp {
    live on;
    record off;
    allow publish all;
    deny play all;

    push_reconnect 1s;
    push rtmp://server2:port live=1 app=hls_for_clients;
    push rtmp://server3:port live=1 app=dash_for_clients;
    if ($stream_name = "somename"){
      push rtmp://prtnersip:port live=1 app=hls_for_clients;
    }
}
coditori commented 7 years ago

Hi just can use $args find it on wiki page please