nginx - 当第二个观看者加入时直播停止

标签 nginx rtmp flv

我正在尝试使用 nginx 和 nginx-http-flv-module (带有 nginx-rtmp-module)构建一个直播平台。

我一直在使用nginx-http-flv-module's guide .

我构建了一个支持 rtmp 和 http-flv 的 nginx 服务器。

我的nginx.conf文件:

#user  nobody;
worker_processes  1;

error_log  logs/error.log debug;

events {
  worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;

  sendfile        on;
  keepalive_timeout  65;

  server {
    listen       8080;
    server_name  localhost;

    ...

    location /live {
      flv_live on; #open flv live streaming (subscribe)
      chunked_transfer_encoding on; #open 'Transfer-Encoding: chunked' response

      add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header
      add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header
      add_header 'Access-Control-Expose-Headers' 'Content-Length';
    }
  }
}

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

    application myapp {
      live on;
    }
  }
}

我开始使用 OBS 发布流,并使用 flv.js 在浏览器中播放流,如下所示:

<video id="videoElement" controls autoplay></video>

...

<script>

    let videoElement = document.getElementById('videoElement');

    let flvPlayer = flvjs.createPlayer({
        type: 'flv',
        isLive: "true",
        url: 'http://192.168.1.122:8080/live?port=1935&app=myapp&stream=test'
    });

    flvPlayer.attachMediaElement(videoElement);
    flvPlayer.load();

</script>

一切都很好!该流正在浏览器中按预期播放。但问题是每当第二个观众开始观看流时(如果我在另一个浏览器选项卡中打开它)。播放器停止播放并开始无限加载。那么什么会导致这个问题呢?

最佳答案

我是 nginx-http-flv-module 的所有者,抱歉,该bug是2019年7月7日提交造成的,目前已经修复。
您可以尝试最新的代码。

关于nginx - 当第二个观看者加入时直播停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57026878/

相关文章:

javascript - 如何仅通过 Javascript 读取 RTMP 流?

ffmpeg - 如何在 FFMPEG 中更改采样率

jquery 可以淡入淡出吗在视频中

docker - 解封80端口/nginx/docker

python - 如何检查 Nginx 是否工作? (Python : Flask+Gunicorn+Nginx)

ffmpeg rtmp 流媒体

linux - RTMP_ReadPacket,读取RTMP包头失败 rtmp ://a. rtmp.youtube.com/live2: Unknown error occurred

ubuntu - 在 Ubuntu 上使用 Nginx 服务多个站点

nginx - 添加 nginx 作为 ubuntu 服务停止并重新加载不起作用

FFmpeg 错误 m4v 到 flv 请求的比特率太低