nginx HLS 流不起作用

疲劳

我已经在我的 linux 服务器上安装了带有 RTMP 模块的 nginx,我希望它从 Open Broadcaster Software 接收 RTMP 流,将其转换为 HLS 并使用一些 HTML5 播放器在我的私人网站上播放。通过 RTMP 接收流有效,但 HLS 流似乎不起作用。我目前的配置是这样的:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    #include       mime.types;
    #default_type  application/octet-stream;
    sendfile        off;
    #keepalive_timeout  65;

    server {
        listen       8080;
        #server_name  localhost;

        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}

        #*********************************************************************************************************************************
        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
        }
            root /mnt/;
            add_header Cache-Control no-cache;

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

    }

}

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application stream {
                        live on;
                        #record off;

            hls on;
            hls_path /mnt/hls;
            #hls_fragment 6s;
                }
        }
}

为了接收我使用的 RTMP 流rtmp://ip/stream/streamname,它工作正常,为了接收 HLS,我尝试使用http://ip:8080/hls/streamname.m3u8它,如果我在浏览器中输入它会给我 .m3u8 文件,但当我尝试播放文件时似乎在网页上不起作用在 HTML5 播放器中。我正在通过这些页面进行测试:https : //videojs.github.io/videojs-contrib-hls/https://demo.theoplayer.com/test-hls-mpeg-dash-stream

谁能帮我理解我做错了什么?

安格茨

如果您分享在这些页面上测试 HLS 流时遇到的控制台或网络错误类型,将会有所帮助。

它可能会为您进行故障排除提供一些见解。例如,您可能会通过从不同域访问您的流而收到访问控制允许来源错误。尝试在 nginx.conf 中取消注释此行并重新加载。

#add_header Access-Control-Allow-Origin *;

我也参考了“video/mp2t ts;” 在我的 hls 位置块中。

location /hls/ {
    # Serve HLS fragments
    types {
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
    }
    root /tmp;
    add_header Cache-Control no-cache;
    add_header 'Access-Control-Allow-Origin' '*';
}

干杯。伊恩

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章