【问题标题】:Stream video with rtmp and videojs使用 rtmp 和 videojs 流式传输视频
【发布时间】:2015-11-26 14:07:30
【问题描述】:

我正在寻找一种使用 rtmp 流式播放视频的方法。我使用video-js,但它不起作用。 Firebug 返回错误:

L'attribut « type » spécifié sur « video/flash » n'est pas géré. Le chargement de la ressource média rtmp://server.com/vod/mp4:foo/bar/my_video.mp4 a échoué.
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this video. MediaError { code=4,  message="No compatible source was found for this video."

HTML 代码:

<!doctype html>
<html lang="fr" class="no-js">
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
   <link rel="stylesheet" href="css/reset.css"> <!-- CSS reset -->
   <link rel="stylesheet" href="css/video-js.css"> <!-- Video.js -->
   <link rel="stylesheet" href="css/style.css"> <!-- Resource style -->
   <script src="js/modernizr.js"></script> <!-- Modernizr -->
   <title>Title</title>
</head>
<body class="sous-menu">
  <video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered"
    controls preload="auto" width="640" height="264"
    data-setup='{"techOrder": ["flash", "html5"]}'>
    <source src="rtmp://server.com/vod/mp4:foo/bar/my_video.mp4" type='rtmp/mp4' />
  </video>
   <script src="js/jquery-2.1.4.min.js"></script> <!-- jQuery -->
   <script src="js/video-js.js"></script> <!-- Videojs.js -->
</body>
</html>

我做错了什么?

编辑:我添加了type='rtmp/mp4',但它仍然不起作用...在 FF、Chrome 和 IE11 中测试。尝试了 VLC 中的链接,它可以工作。

【问题讨论】:

    标签: html video-streaming mp4 video.js


    【解决方案1】:

    在您的源代码中使用 rtmp/mp4 类型。此外,video.js 使用与号分隔服务器 URL 和流名称。当然,RTMP 只能在 Flash 可用的情况下工作。

    <source src='rtmp://server.com/vod/&mp4:foo/bar/my_video.mp4' type='rtmp/mp4'/>
    

    【讨论】:

    • 忘了提到和号作为分隔符很重要。如果没有和号,则假定最后一个斜杠是分隔符。
    • 我想念那个&符号......它工作!只在 Chrome 和 IE11 中,不在 Firefox 中,但 IE 对我来说已经足够了,非常感谢
    【解决方案2】:

    您可能希望确保在服务器上返回正确的内容类型。见:https://github.com/videojs/video.js/issues/1994

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-03
      • 1970-01-01
      • 1970-01-01
      • 2012-11-14
      • 2019-10-07
      • 1970-01-01
      • 2019-01-06
      • 1970-01-01
      相关资源
      最近更新 更多