【问题标题】:nginx streaming server serving stream that causes VLC to reload in a loopnginx 流服务器服务流,导致 VLC 在循环中重新加载
【发布时间】:2020-04-01 04:38:09
【问题描述】:

我在 Video Stack Exchange Question 中解释了问题,因为我认为这与代码无关(例如错误)。

这对于开发人员来说可能是一个有用的信息,但我确实没有从源代码编译 nginx。我明确提到了这一点,因为搜索网络,似乎从源代码构建是 nginx/rtmp 设置的推荐方式。但是,我找不到可以解释这种行为的错误报告。

我觉得我在监督一些愚蠢的事情。

为了完整起见,我将发布配置文件。此外,不要错过现场演示,玩转其他帖子中链接的流媒体服务器,玩得开心;)

编码愉快!

nginx.conf:

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Gzip Settings
    ##

    gzip on;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

rtmp {
    include /etc/nginx/streams-enabled/*;
}

rtmp 服务器(在启用流的/中)

server {

        listen 1935;
        chunk_size 4096;

        application live {
                live                    on;
                hls                     on;
                hls_path                /home/streamer/hls;
                hls_nested              on;
                hls_fragment            3s;
                hls_playlist_length     30s;
                hls_base_url            http://0.0.0.0:3456/hls;
                on_publish              http://0.0.0.0:3456/auth;
                # Recent versions of IE need this for normal playback.
                wait_video              on; # start audio with video
                # force hls
                deny play all;

        }
}

http-server (在启用站点/)

server {

    listen      3456;

    location /hls {

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

        types {
        application/dash+xml mpd;
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
        }

        root       /home/streamer/;


    }
}

【问题讨论】:

    标签: nginx streaming http-live-streaming rtmp


    【解决方案1】:

    问题在于流配置。

    vlc -vv http://104.248.36.47:3644/hls/debug/index.m3u8 输出显示:

    [00007f0594002580] 主​​流调试:连接0.0.0.0端口3644 ...

    [00007f0594002580] 主​​流错误:连接错误:连接被拒绝

    ...

    [00007f0594002580] 自适应流调试:检索http://0.0.0.0:3644/hlsdebug/75.ts@0

    注意它说的是 hlsdebug 而不是预期的 hls/debug

    在 hls_base_url 中添加一个“/”,并将 0.0.0.0 更改为公共 IP 后,它就可以工作了。

    我不完全明白为什么 0.0.0.0 不起作用..

    【讨论】:

      猜你喜欢
      • 2018-06-01
      • 2016-03-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-17
      • 2018-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多