简体   繁体   English

无法让破折号流从 nginx-rtmp 工作

[英]Can't get dash streaming to work from nginx-rtmp

I'm trying to broadcast a stream from OBS (codec is set x264) to nginx with an rtmp server and then view the stream as mpeg-dash in VLC.我正在尝试使用 rtmp 服务器将 stream 从 OBS(编解码器设置为 x264)广播到 nginx,然后在 VLC 中将 stream 视为 mpeg-dash。

I've set up nginx with the rtmp module and that works.我已经使用 rtmp 模块设置了 nginx 并且可以正常工作。 I can stream to nginx and receive the stream via rtmp in VLC.我可以从 stream 到 nginx 并在 VLC 中通过 rtmp 接收 stream。 For that I used this URL: rtmp://127.0.0.1/live/stream为此,我使用了这个 URL:rtmp://127.0.0.1/live/stream

This is my config.这是我的配置。

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

I can see the stream.mpd in the file explorer, but VLC always says can't open source.我可以在文件资源管理器中看到 stream.mpd,但是 VLC 总是说无法打开源代码。 I've tried both URLs: http://127.0.0.1/tmp/dash/stream.mpd and http://127.0.0.1/dash/stream.mpd , but both didn't work.我已经尝试了两个 URL: http://127.0.0.1/tmp/dash/stream.mpdhttp://127.0.0.1/dash/stream.mpd ,但都没有用。

I also tried it with HLS, but I couldn't get this to work either.我也用 HLS 尝试过,但我也无法让它工作。

To avoid having troubles with file privileges, I set the whole folder to chmod 777.为了避免出现文件权限问题,我将整个文件夹设置为 chmod 777。

Any ideas what could be wrong or what I could try?任何想法可能是错误的或我可以尝试什么? Thank you谢谢

I solved it, sort of...我解决了它,有点...

I used the config from here: HTML5 live streaming我使用了这里的配置: HTML5 直播

I had to change some things in the file (http-tag was missing as an example) but then it worked with HLS.我不得不更改文件中的一些内容(例如缺少 http-tag),但随后它与 HLS 一起工作。 Turns out it doesn't really make a difference if I'm using MPEG-DASH or HLS, so I'm fine with it.事实证明,如果我使用的是 MPEG-DASH 或 HLS,这并没有什么区别,所以我没问题。

Another thing I found out, is that I always tried it without defining the port.我发现的另一件事是,我总是在不定义端口的情况下尝试它。 For RTMP this made no problems since I could use the standard port.对于 RTMP 这没有问题,因为我可以使用标准端口。 But on http I had to use port 8080 since 80 was already in use.但是在 http 上我不得不使用端口 8080,因为 80 已经在使用中。 But in VLC I didn't think to define the port.但是在 VLC 中我没有想到定义端口。

Now it works for me;)现在它对我有用;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM