媒体流基础知识 - HTTP 与 RTMP
我对媒体流非常陌生,我有一些基本的疑问需要澄清:
据我所知,HTTP 流(例如通过 Apache)和 RTMP 流(通过 Red5)之间的区别在于流服务器提供缓冲和高级控制,如搜索等。我说得对吗?
我可以仅从 Red5 等 RTMP 服务器流式传输 Flash 视频吗?如果我必须流式传输不同格式的文件,我是否必须使用 HTTP 流式传输?我可以使用 xuggler 等工具动态转码文件并根据 Red5 服务器的请求发送吗?
我提出所有这些疑问是因为我必须向所有移动客户端提供流媒体 - iPhone、黑莓、Android - iPhone 不支持 flash,所以选择 Red5 是个好主意吗?
I am very new to media streaming, and I have some basic doubts to clear :
As far as I can understand, the difference between HTTP streaming (say through Apache) and a RTMP streaming (through Red5) is that streaming servers provide buffering and advance controls like seek, etc. Am I right ?
Can I stream only flash videos from RTMP servers like Red5 ? If I have to stream varying formats of files, do I have to go for HTTP streaming ? Can I use tools like xuggler to dynamically transcode files and send according to the request from the Red5 server ?
I am posing all these doubts because I have to provide streaming to all mobile clients - iPhone, Blackberry, Android - iPhone does not support flash, so is it a good idea to go for Red5 ?
为了清楚细节,让我说得更详细一些。
1)什么是“流媒体”。通常,在视频流领域中,帧的传输是实时进行的。如果您有 30 分钟的视频,它将在 30 分钟内交付给用户。
有一些专门用于流媒体的特殊协议:RTSP(可能是当今最古老的协议)、RTMP、MJPEG、基于 http 的协议系列(apple、abobe、microsoft)以及其他一些封闭的供应商协议。
2)什么是“http流”或“伪流”。如果您只是将文件放在 HTTP 服务器上,用户就可以下载并观看。如果他下载完整视频,他甚至可以在其中进行搜索。但是,如果用户想要寻找电影的中间部分而不下载第一部分,会发生什么情况?
它应该以某种方式告诉服务器:打开文件容器,寻找此时并将文件打包回来。因此 HTTP 服务器必须了解文件容器的结构才能向客户端提供查找功能。
nginx 和 apache 可以为 flv 和 mp4 容器做到这一点,这对于 100% 的视频来说是可以的,可以通过 Flash Player 播放。
3)现在的http-streaming 到底是怎么回事?
Apple、Adobe 和微软已经在 HTTP 之上设计并实现了流媒体。这意味着客户端下载 10 秒的片段,仍然保持适当的帧速率。 30分钟的电影仍然会在30分钟内下载,但分段下载之间存在较大的延迟。
可以以这种“格式”进行搜索、切换比特率等。
4) RTMP 流媒体服务器(如 Red5 或 erlyvideo)可以流式传输 H.264、H.263、VP6 和 Screen 视频。不支持 MPEG-4 (Xvid/DivX) 或 MPEG-2。
Let me be a bit verbose to clear details.
1) What is "streaming". Usually in world of video streaming is delivery of frames according to realtime. If you have 30-minutes video it will be delivered to user in 30 minutes.
There are special protocols dedicated exclusively for streaming: RTSP (perhaps the ancient of living today), RTMP, MJPEG, family of http-based protocols (apple,abobe,microsoft) and some other closed vendor protocols.
2) what is "http-streaming" or "pseudo-streaming". If you just put your file on HTTP server, user can download it and watch. If he downloads full video, he can even seek in it. But what happens if user want to seek to the middle of film without downloading first part?
It should somehow tell to server: open file container, seek to this moment and pack file back. So HTTP server must know about structure of file container to deliver seek functionality to client.
nginx and apache can do it for flv and mp4 containers, which is ok for 100% of video, possible to play via Flash Player.
3) what is http-streaming messed with nowadays.
Apple, Adobe and microsoft has designed and implemented streaming on top of HTTP. It means that client downloads 10-seconds segment, still keeping proper framerate. 30-minutes film is still downloaded in 30 minutes, but there are big delays between segment downloadings.
It is possible to seek in such "format", to switch bitrates, etc.
4) RTMP Streaming servers like Red5 or erlyvideo can stream H.264, H.263, VP6 and Screen video. MPEG-4 (Xvid/DivX) or MPEG-2 is not supported.