Streaming 使用OBS和ffmpeg流式传输多个RTMP IP摄像机

Streaming 使用OBS和ffmpeg流式传输多个RTMP IP摄像机,streaming,http-live-streaming,rtmp,ip-camera,obs,Streaming,Http Live Streaming,Rtmp,Ip Camera,Obs,我在运行CentOS 7的VPS上使用Nginx和RMTP模块创建了一个流式服务器。我正在尝试使用OBS对多个IP摄像机进行流媒体播放。我的问题是如何使用nginx.conf文件中的不同应用程序为每个摄像头创建多个m3u8流文件。为了实现这一点,我尝试使用多个OBS实例,但我的CPU资源已经用完了。我发现,通过使用ffmpeg,有一种方法可以传输多个流,但我不知道确切的命令。用于广播的每个摄像机的比特率约为512Kbps-1024Kbps。我的nginx.conf如下所示: # RTMP co

我在运行CentOS 7的VPS上使用Nginx和RMTP模块创建了一个流式服务器。我正在尝试使用OBS对多个IP摄像机进行流媒体播放。我的问题是如何使用nginx.conf文件中的不同应用程序为每个摄像头创建多个m3u8流文件。为了实现这一点,我尝试使用多个OBS实例,但我的CPU资源已经用完了。我发现,通过使用ffmpeg,有一种方法可以传输多个流,但我不知道确切的命令。用于广播的每个摄像机的比特率约为512Kbps-1024Kbps。我的nginx.conf如下所示:

 # RTMP configuration
    rtmp {


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

    # Define the Application
            application camera1 {
                live on;
                exec ffmpeg -i rtmp://123.123.123.123/folder/$name -vcodec libx264 -vprofile
                baseline -x264opts keyint=40 -acodec aac -strict -2 -f flv rtmp://123.123.123.123/hls/$name;



                # Turn on HLS
                hls on;
                hls_path /mnt/hls/camera1;
                hls_fragment 3s;
                hls_playlist_length 60s;
                # disable consuming the stream from nginx as rtmp
                # deny play all;
            }


            application camera2 {
                live on;
                exec ffmpeg -i rtmp://123.123.123.123./$app/$name -vcodec libx264 -vprofile
                baseline -x264opts keyint=40 -acodec aac -strict -2 -f flv rtmp://123.123.123.123/hls/$name;
                # Turn on HLS
                hls on;
                hls_path /mnt/hls/camera2;
                hls_fragment 3s;
                hls_playlist_length 60s;
                # disable consuming the stream from nginx as rtmp
                # deny play all;
            }
http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    server_tokens off;
    aio on;
    directio 512;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;


    server {
        listen 80;
        server_name  123.123.123.123;

        location / {

        root /var/www/html;
        index  index.html index.htm;
        }

        location /hls {
            # 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;
            }

            root /mnt/;
        }
    }
}
使用具有不同流名称的2个OBS实例,我可以同时流2个摄影机,但我想流50多个摄影机,使用这种方法是不可能的。我想可以用ffmpeg来完成。RTSP流的格式如下所示:rtsp://username:password@主机名:端口,但我需要一些命令方面的帮助。任何帮助都将不胜感激。提前谢谢