使用 VideoJS 播放器播放 RTMP 流

Playing RTMP stream with VideoJS player

我正在尝试使用 VideoJS 播放器播放 RTMP 流,下面是我的代码:

<head>
  <link href="http://vjs.zencdn.net/6.2.0/video-js.css" rel="stylesheet">

  <!-- If you'd like to support IE8 --> 
  <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>

<body>
  <video id="my-video" class="video-js" controls preload="auto" width="640" height="264" data-setup='{"techorder" : ["flash"]}'>
    <source src="rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov" type="rtmp/mp4">                                                                                                                           
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
    </p>
  </video>

  <script src="http://vjs.zencdn.net/6.2.0/video.js"></script>
</body>

我看到的错误是这样的:

VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media. MediaError {code: 4, message: "No compatible source was found for this media."}

错误很明显,但是有很多文档向人们展示了使用 VideoJS:

播放 RTMP 流的成功案例

我确定以下 URL 会在 VLC 播放器上播放,在 JWPlayer 上也会播放:

rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov

可能是什么问题?

如果你想玩 RTMP,你必须包括 flash-tech,可以从这里检索:

https://github.com/videojs/videojs-flash

因此正确的代码应该是这样的:

<head>
  <link href="http://vjs.zencdn.net/6.2.0/video-js.css" rel="stylesheet">

  <!-- If you'd like to support IE8 --> 
  <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>

<body>
  <video id="my-video" class="video-js" controls preload="auto" width="640" height="264" data-setup='{"techorder" : ["flash"]}'>
    <source src="rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov" type="rtmp/mp4">                                                                                                                           
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
    </p>
  </video>

  <script src="http://vjs.zencdn.net/6.2.0/video.js"></script>
  <script src="/videojs-flash.js"></script>
</body>