Html 使用 rtmp 和 videojs 流式传输视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33940721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stream video with rtmp and videojs
提问by Snabow
I looking for a way to stream play videos with rtmp. I use video-js but it doesn't work. Firebug return an error :
我正在寻找一种使用 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 code :
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>
What I'm doing wrong ?
我做错了什么?
Edit:I add the type='rtmp/mp4'
but it still dosen't work ... Test in FF, Chrome & IE11. Tried the link in VLC and it work.
编辑:我添加了type='rtmp/mp4'
但它仍然不起作用......在 FF、Chrome 和 IE11 中测试。尝试了 VLC 中的链接,它工作正常。
采纳答案by misterben
Use the type rtmp/mp4
in your source. Also, video.js uses an ampersand to separate the server URL and stream name. RTMP will only work where Flash is available of course.
使用rtmp/mp4
源中的类型。此外,video.js 使用与号分隔服务器 URL 和流名称。当然,RTMP 仅适用于 Flash 可用的情况。
<source src='rtmp://server.com/vod/&mp4:foo/bar/my_video.mp4' type='rtmp/mp4'/>
回答by Broonix
You might want to ensure you are returning the correct content-type on the server. See: https://github.com/videojs/video.js/issues/1994
您可能希望确保在服务器上返回正确的内容类型。见:https: //github.com/videojs/video.js/issues/1994