Search code examples
nginxffmpegrtsprtmponvif

How to display multiple rtmp streams from Gryphon nginx?


CONTEXT :

-I received a rtsp stream link from an onvif ip camera.

-The camera can only host 5 streaming connection at a time (I want/need more connections).

-I've been informed that a combination of ffmpeg (to convert the rtsp stream to rtmp) and nginx (to redistribute as many streams as I want) would do what I want.

-I'm on Windows 10.

-I downloaded ffmpeg from this source and nginx from this source (nginx 1.7.11.3 Gryphon.zip).

-Here's the conf file of the nginx server:

user nobody;
worker_processes 1;

events {
  worker_connections  1024;
}

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

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

-I'm using this command to push my camera's stream to the nginx server:

ffmpeg -hide_banner -i "rtsp://user:password123@192.168.10.116:554/videoMain" -an -f flv -rtmp_live live "rtmp://127.0.0.1:1935/live"

-I can then see the output stream using vlc's open network stream tool (rtmp://127.0.0.1:1935/live)

QUESTION :

Is there a way to have multiple input/outout streams at the same time?

I want to have multiple cameras redirected at the same time by one server...

enter image description here


Solution

  • The answer was fairly simple, all I needed to do was to add a second server tag in my nginx.conf file :

    user nobody;
    worker_processes 1;
    
    events {
      worker_connections  1024;
    }
    
    rtmp {
            server {
                    listen 1935;
                    chunk_size 4096;
                    max_streams 512;
    
                    application live {
                            live on;
                            record off;
                    }
            }
            server {
                    listen 1936;
                    chunk_size 4096;
                    max_streams 512;
    
                    application live {
                            live on;
                            record off;
                    }
            }
    }
    

    I can now push another rtmp stream to the port 1936 using:

    ffmpeg -hide_banner -i "rtsp://user:password123@192.168.10.116:554/videoMain" -an -f flv -rtmp_live live "rtmp://127.0.0.1:1936/live"