首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法从nginx-rtmp获取dash流

无法从nginx-rtmp获取dash流
EN

Stack Overflow用户
提问于 2020-07-29 17:38:13
回答 1查看 1.3K关注 0票数 0

我正在尝试通过rtmp服务器从OBS (编解码器设置为x264)向nginx广播一个流,然后在VLC中以mpeg-dash格式查看该流。

我已经使用rtmp模块设置了nginx,并且可以正常工作。我可以流到nginx,并在VLC中通过rtmp接收流。为此,我使用了以下URL: rtmp://127.0.0.1/live/stream

这是我的配置。

代码语言:javascript
复制
 #user  nobody;
worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application live {
            live on;
        dash on;
        dash_path /tmp/dash;
        }
    }
}


http {
    include       mime.types;
    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  logs/access.log  main;

    sendfile off;
    tcp_nopush on;
    aio off;
    directio 512;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        listen 8080;
    location /dash {
            # Serve DASH fragments
            types {
                application/dash+xml mpd;
                video/mp4 mp4;
            }
            root /tmp;
            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;
            }
        }
    }
}

我可以在文件资源管理器中看到stream.mpd,但VLC总是显示不能开源。我尝试了两个URL:http://127.0.0.1/tmp/dash/stream.mpdhttp://127.0.0.1/dash/stream.mpd,但都不起作用。

我也尝试过HLS,但我也不能让它工作。

为了避免遇到文件权限的问题,我将整个文件夹设置为chmod 777。

有什么想法可能是错误的,或者我可以尝试一下吗?谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-07-29 20:25:09

我解决了,某种程度上...

我在这里使用了配置:HTML5 live streaming

我不得不修改文件中的一些东西(例如,缺少http-tag),但是它可以与HLS一起工作。事实证明,如果我使用MPEG-DASH或HLS,并没有真正的区别,所以我可以接受它。

我发现的另一件事是,我总是在没有定义端口的情况下尝试它。对于RTMP,这没有问题,因为我可以使用标准端口。但在http上,我不得不使用端口8080,因为80已经在使用中了。但在VLC中,我没有考虑定义端口。

现在它对我来说是有效的;)

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

https://stackoverflow.com/questions/63150697

复制
相关文章

相似问题

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