找不到Nginx RTMP模块输出HLS

时间:2019-04-15 03:56:32

标签: nginx

我为实时流边缘服务器设置了Nginx,该服务器将RTMP从原始服务器中拉出。就我而言,RTMP可以正常工作,但是找不到hls返回。

我像基于源的动态流一样拉rtmp,例如“ pull rtmp:// ORIGIN_IP:1935 / appname”,我可以播放“ rtmp:// EDGE_IP:1935 / stream / origin_streamname”,但不能播放“ http://EDGE_IP:8080/stream/origin_streamname.m3u8”始终返回“未找到”端口8080打开。

下面是nginx.conf

worker_processes  auto;

error_log  /var/log/nginx/error.log  warn;

events {
    worker_connections  1024;
}

# RTMP configuration
rtmp {
    server {
        listen 1935;
        chunk_size 4000;


        application show {
            live on;

            hls on;
            hls_path /mnt/hls/;
            hls_fragment 3;
            hls_playlist_length 60;

            deny play all;
        }


        application vod {
            play /mnt/mp4s;
        }


        application stream {
            live on;
            pull rtmp://ORIGIN_IP:1935/appname;
        }

    }

}

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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    server {
        listen 8080;

        server_name 127.0.0.1;
        location /nginx_status {
        stub_status on;
        allow 127.0.0.1;
        deny all;
    }

        location / {

            add_header 'Cache-Control' 'no-cache';

            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

            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/;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我通过添加来解决

hls on;
hls_path /mnt/hls/;
hls_fragment 3;
hls_playlist_length 60;

然后您需要同时玩rtmp://EDGE_IP:1935/stream/origin_streamnamehttp://EDGE_IP:8080/hls/origin_streamname.m3u8