【问题标题】:Retrieve HLS data from another stream and push it to rtmp server从另一个流中检索 HLS 数据并将其推送到 rtmp 服务器
【发布时间】:2022-08-22 10:55:56
【问题描述】:

我一直在从事一个需要能够动态推送到 2 或 3 个其他频道的项目。我测试了几个场景,我的最后一次尝试如下:

流服务器

worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
    server {
        listen 1935; # Listen on standard RTMP port

        application live {
            live on;
            hls on;
            hls_path /www/tmp/hls;
            hls_fragment 10s; # default is 5s
            hls_playlist_length 5m; # default is 30s
            # once playlist length is reached it deletes the oldest fragments

            # authentication
            # on_publish => some other server
            # on_done => some other server
        }
    }
}

http {
    server {
        listen 8080;

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                application/octet-stream ts;
            }
            root /www/tmp;
            add_header Cache-Control no-cache;

            # To avoid issues with cross-domain HTTP requests (e.g. during development)
            add_header Access-Control-Allow-Origin *;
        }
    }
}

然后强制另一台服务器读取该服务器创建的 hls 内容。我尝试使用 node-media-server 和 nginx,但都没有真正的解决方案,这是我对 nginx 的尝试:

events {}
rtmp {
    server {
        listen 1935; # Listen on standard RTMP port
        chunk_size 4000; 
        # ping 30s;
        # notify_method get;

        # This application is to accept incoming stream
        application live {
            live on; # Allows live input
            deny play all; # disable consuming the stream from nginx as rtmp

            hls on; # Enable HTTP Live Streaming
            hls_fragment 3;
            hls_playlist_length 10;
            hls_path /www/tmp/hls;  # hls fragments path
                        
            # MPEG-DASH
            dash on;
            dash_path /mnt/dash/;  # dash fragments path
            dash_fragment 3;
            dash_playlist_length 10;    
            push => another rtmp server;
        }
    }
}

http {
    server {
        listen 8080;

        location / {
            root /www;
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                application/octet-stream ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;

            # To avoid issues with cross-domain HTTP requests (e.g. during development)
            add_header Access-Control-Allow-Origin *;
        }
    }
}

如果您知道任何其他选择,请告诉我或有任何其他建议,谢谢

    标签: nginx stream http-live-streaming rtmp node-media-server


    【解决方案1】:

    你想这样做如下:

    Client -----> Nginx -------> Server
             (Stream 1/2/3)    (Stream 2)
    

    你不应该让另一个服务器从 Nginx 读取Stream 2,你应该使用FFmpeg 作为客户端来执行此操作:

    Client -----> Nginx -----> FFmpeg  --> Server
             (Stream 1/2/3)             (Stream 2)
    

    为此,请运行如下命令:

    ffmpeg -f flv -i rtmp://ip/live/stream2 -c copy -f flv rtmp://server/live/stream2
    

    所以你可以从 Nginx 读取任何流到另一台服务器。

    如果您希望Server 执行此操作,可以使用SRS/Ingest,它派生一个FFmpeg 进程将流拉到SRS

    【讨论】:

      猜你喜欢
      • 2020-12-11
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      相关资源
      最近更新 更多