首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到Nginx RTMP模块输出HLS

找不到Nginx RTMP模块输出HLS
EN

Stack Overflow用户
提问于 2019-04-15 11:56:32
回答 1查看 1.2K关注 0票数 0

我为直播边缘服务器设置了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

代码语言:javascript
复制
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/;
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-30 21:55:22

我通过添加

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55682406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档