【问题标题】:HLS files(.m3u8, .ts) not generated with pull on RTMP stream未通过拉取 RTMP 流生成 HLS 文件(.m3u8、.ts)
【发布时间】:2020-04-30 02:54:14
【问题描述】:

我将 nginx 设置为流式传输 rtmp,并且我能够完美地流式传输到它并使用 VLC 在 rtmp://[insterip]:1935/stream/test 播放它。

我尝试使用 ffmpeg 进行转码,它开始使用正确的文件填充 /mnt/hls。我想避免在此服务器上进行转码,因为它较旧,所以我尝试使用 pull 功能直接从 rtmp 流中提取它。

我正在使用 OBS 流式传输到服务器,默认情况下应该使用正确的编解码器来处理视频和音频供 hls 使用。请记住,我使用 pull url 将 IP 放入应有的位置,并且允许端口通过防火墙,因为我能够使用网络上的辅助 pc 访问流。这都是在 Centos 8 中配置的。

nginx 配置

worker_processes  auto;
events {
    worker_connections  1024;
}

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

# Define the Application
        application show {
            live on;
            pull rtmp://localhost:1935/stream/test;
            # Turn on HLS
            hls on;
            hls_path /mnt/hls/;
            hls_fragment 3;
            hls_playlist_length 60;
            # disable consuming the stream from nginx as rtmp
            deny play all;
        }

        # RTMP video on demand for mp4 files
        application vod {
            play /mnt/mp4s;
        }

        # RTMP stream using OBS
        application stream {
            live on;
        }

    }
}

http {
    sendfile off;
    tcp_nopush on;
    aio on;
    directio 512;
    default_type application/octet-stream;

    server {
        listen 8080;

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

【问题讨论】:

    标签: nginx http-live-streaming rtmp


    【解决方案1】:

    像这样添加“静态”选项:

    pull rtmp://localhost:1935/stream/test static;
    

    【讨论】:

      猜你喜欢
      • 2020-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 2013-10-24
      • 1970-01-01
      • 2021-03-06
      相关资源
      最近更新 更多