sergey-dryabzhinsky / nginx-rtmp-module

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

Is this possible? #277

Open rayj00 opened 6 years ago

rayj00 commented 6 years ago

So I want to allow live video streaming access to multiple broadcasters. I have four LXD containers that each have a media server.

Broadcasters will be usuing OBS to generate the rtmp stream with the OBS stream setting as such: rtmp://"nginx serverIP":1935/LPC1 where LPC is 1-4 defining the 4 containers.

So broadcaster 1 sets streaming to rtmp://"nginx serverIP":1935/LPC1 and nginxx receives this and routes this to "LPC1 container IP". Broadcaster 2 sets streaming to rtmp://"nginx serverIP":1935/LPC2 and nginx routes this to "LPC2 container IP", etc.

Is this doable with nginx and if so, how can I accomplish this?

Thanks and please let me know if I articulated my problem well enough!

Ray

sixela commented 6 years ago

I see 2 possibles solutions here:

  1. You might leverage the notify-redirect to dynamically redirect the stream to the correct container

  2. Harcode the redirection using nginx-rtmp relay feature

rayj00 commented 6 years ago

Thanks sixela.

Here is the nginx.conf I am using:

user nobody;

worker_processes 2; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; error_log logs/debug.log debug;

pid logs/nginx.pid;

events { worker_connections 1024; } rtmp { server { listen 1935; ping 30s; ping_timeout 10s; chunk_size 4096;

    application LPC1 {
        live on;
        push rtmp://10.57.215.214:1935;
    }
    application LPC2 {
        live on;
        push rtmp://10.57.215.247:1935;
    }
    }
}

The LPC1 access seems to work using rtmp://"nginx server IP":1935/LPC1 as it indeed goes to the LPC1 container. However if I try rtmp://"nginx server IP":1935/LPC2 it also gets routed to the LPC1 container?

Any ideas why this is happening?

Thanks,

Ray

rayj00 commented 6 years ago

Here is the OBS log for the above issue: 18:08:16.973: [rtmp stream: 'adv_stream'] Connecting to RTMP URL rtmp://192.168.0.47:1935/LPC2... 18:08:16.973: [rtmp stream: 'adv_stream'] Interface: Intel(R) 82579V Gigabit Network Connection (ethernet, 1000 mbps) 18:08:17.975: 192.168.0.47:1935/LPC2 is offline. Try a different server (ECONNREFUSED). 18:08:17.975: [rtmp stream: 'adv_stream'] Connection to rtmp://192.168.0.47:1935/LPC2 failed: -2 18:08:17.975: ==== Streaming Stop ================================================

The LPC2 container is indeed up and running the media server.

sixela commented 6 years ago

I'm not sure I can help more here, I haven't the setup to reproduce and never experienced such issue