Html 使用 HTML5 阅读 red5 直播
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4206141/
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
Read red5 live stream with HTML5
提问by Zakaria
How can I read a Red5 (RTMFP) stream using HTML5?
如何使用 HTML5 读取 Red5 (RTMFP) 流?
回答by Wouter Dorgelo
Red5 supports different kinds of streaming*, so I don't know which kind of streaming you mean:
Red5支持不同类型的流媒体*,所以不知道你指的是哪种流媒体:
- Streaming Video (FLV, F4V, MP4)
- Streaming Audio (MP3, F4A, M4A)
- Recording Client Streams (FLV only)
- 流媒体视频(FLV、F4V、MP4)
- 流媒体音频(MP3、F4A、M4A)
- 录制客户端流(仅限 FLV)
*source: Red5 on Google Code.
*来源:Google Code 上的 Red5。
You probably want to use the HTML5 Video Tagand/or the HTML5 Audio Tagto 'play' the stream. Therefor you will need to do some conversion.
您可能想要使用HTML5 视频标签和/或HTML5 音频标签来“播放”流。因此,您需要进行一些转换。
Audio streaming
音频流
New technique, lot's of browsers and no universal codec support yet.
新技术,大量浏览器,尚无通用编解码器支持。
See browsers + codec's it supports*:
查看它支持的浏览器 + 编解码器*:
FireFox 3.6+
- Ogg Vorbis
- Wav
Safari 5+
- MP3
- WAV
Chrome 6
- Ogg Vorbis
- MP3
Opera 10.5+
- Ogg Vorbis
- WAV
Internet Explorer 9 (beta)
- MP3
- WAV
FireFox 3.6+
- 奥格·沃比斯
- 波形
Safari 5+
- MP3
- WAV
Chrome 6
- 奥格·沃比斯
- MP3
Opera 10.5+
- 奥格·沃比斯
- WAV
Internet Explorer 9 (beta)
- MP3
- WAV
*source: Native Audio in the browser.
*来源:浏览器中的原生音频。
Video streaming
视频流
Currently there's a discussion going on about the HTML5 Video Codec, between Ogg Theoraand H.264. So make a conversion to one of those formats. I would recommend H.264 because it looks like Red5 will implement H.264 support in the future.
目前正在Ogg Theora和H.264之间讨论HTML5 Video Codec。因此,请转换为其中一种格式。因为它看起来像的Red5将实现H.264的支持,我会建议H.264的未来。
As with audio as with video.. New technique, lot's of browsers and no universal codec support yet. See for list: HTML5 Video on Wikipedia.
与音频和视频一样。新技术,许多浏览器,尚无通用编解码器支持。参见列表:维基百科上的 HTML5 视频。
After conversion
转换后
The easiest way to check for support of the video and audio tags is to dynamically create one or both with scripting and check for the existence of a function:
检查视频和音频标签支持的最简单方法是使用脚本动态创建一个或两个并检查函数是否存在:
var hasVideo = !!(document.createElement('video').canPlayType);
This simple code line will dynamically create a video element and check for the existence of the canPlayType()
function. By using the !! operator
, the result is converted to a Boolean value, which indicates whether or not a video object could be created.
这个简单的代码行将动态创建一个视频元素并检查该canPlayType()
函数是否存在。通过使用!! operator
,结果被转换为布尔值,指示是否可以创建视频对象。
Alternatively
或者
You can serve 2 streams with a Flash Fallback:
您可以使用 Flash Fallback 提供 2 个流:
<video src="video.ogg">
<object data="videoplayer.swf" type="application/x-shockwave-flash">
<param name="movie" value="video.swf"/>
</object>
</video>
The video tag is used by default, if not supported the browser will use the flashplayer.
默认使用 video 标签,如果不支持,浏览器将使用 flashplayer。
Edit:
编辑:
I now see that Red5 supports H.264 (Live Stream Publishing). Read here how to use the HTML5 video tag with the H.264 codec
我现在看到Red5 支持 H.264 (Live Stream Publishing)。在此处阅读如何将HTML5 视频标记与 H.264 编解码器一起使用
You also might wanna have a look at: Adobe's Video Player Widget.
您可能还想看看:Adobe's Video Player Widget。
回答by vbence
A short answer: you can't. The browsers will not support streams over RTMP (RTMFP), RTP or UDP. Your stream must be sent over HTTP to be accessible (in fact you have to emulate a static file on the server).
简短的回答:你不能。浏览器将不支持通过 RTMP (RTMFP)、RTP 或 UDP 传输的流。您的流必须通过 HTTP 发送才能访问(实际上您必须在服务器上模拟静态文件)。
Also WebMdeserves a few words. In May 2010 Google announced a royalty-free codec for HTML5 viceo purposes. As of now, the latest versions of alternative browsers (Mozilla, Opera, Chrome) has the ability to play it. Only the big ones who have invested good bucks to H.264 resist.
另外的WebM值得几句话。2010 年 5 月,Google 宣布了一种用于 HTML5 vico 目的的免版税编解码器。截至目前,最新版本的替代浏览器(Mozilla、Opera、Chrome)都可以播放。只有在 H.264 上投入大量资金的大公司才会抵制。
Now days a couple of media servers support WebM. I guess the first was Flumotionto implement it. I also have my own GPL software for live-streaming WebM called stream.m. It is a very early release but if you want to give it a try I'm not stopping anyone. :)
现在有几个媒体服务器支持 WebM。我想第一个是Flumotion来实现它。我也有自己的 GPL 软件,用于直播 WebM,称为stream.m。这是一个非常早的版本,但如果您想尝试一下,我不会阻止任何人。:)
回答by ankitr
RTMFPand HTML5(WebRTC or Websocket)protocols are supported in WCS4
WCS4支持RTMFP和HTML5(WebRTC 或 Websocket)协议
So you can publish RTMFPstream to the server and play this stream using Chrome(WebRTC), Firefox(WebRTC) or iOS Safari browser(Websocket).
因此,您可以将RTMFP流发布到服务器并使用 Chrome(WebRTC)、Firefox(WebRTC)或 iOS Safari 浏览器(Websocket)播放此流。
Red5does not support RTMFP.
Red5不支持RTMFP。
RTMFP is a peer-to-peer designed protocol, however server can be used like RTMFP peer, therefore it would be simple client-server connection Flash-Server like RTMP.
RTMFP 是一种点对点设计的协议,但是服务器可以像 RTMFP 对等体一样使用,因此它会像 RTMP 一样是简单的客户端-服务器连接 Flash-Server。