Html 在 HTML5 中通过 RTSP 或 RTP 流式传输

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1735933/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:19:45  来源:igfitidea点击:

Streaming via RTSP or RTP in HTML5

videohtmlstreamingrtsprtp

提问by Elben Shira

I'm building a web app that should play back an RTSP/RTP stream from a server http://lscube.org/projects/feng.

我正在构建一个网络应用程序,它应该从服务器http://lscube.org/projects/feng播放 RTSP/RTP 流。

Does the HTML5 video/audio tag support the rtsp or rtp? If not, what would the easiest solution be? Perhaps drop down to a VLC plugin or something like that.

HTML5 视频/音频标签是否支持 rtsp 或 rtp?如果没有,最简单的解决方案是什么?也许下拉到 VLC 插件或类似的东西。

采纳答案by Stu Thompson

Technically 'Yes'

技术上“是”

(but not really...)

(但不是真的...)

HTML 5's <video>tag is protocol agnostic—it does not care. You place the protocol in the srcattribute as part of the URL. E.g.:

HTML 5 的<video>标签与协议无关——它不在乎。您将协议src作为 URL 的一部分放置在属性中。例如:

<video src="rtp://myserver.com/path/to/stream">
    Your browser does not support the VIDEO tag and/or RTP streams.
</video>

or maybe

或者可能

<video src="http://myserver.com:1935/path/to/stream/myPlaylist.m3u8">
    Your browser does not support the VIDEO tag and/or RTP streams.
</video>

That said, the implementation of the <video>tag is browser specific. Since it is early days for HTML 5, I expect frequently changing support (or lack of support).

也就是说,<video>标签的实现是特定于 浏览器的。由于 HTML 5 还处于早期阶段,我希望经常更改支持(或缺乏支持)。

From the W3C's HTML5 spec (The video element):

来自 W3C 的 HTML5 规范(视频元素):

User agents may support any video and audio codecs and container formats

用户代理可以支持任何视频和音频编解码器和容器格式

回答by GolfARama

The spirit of the question, I think, was not truly answered. No, you cannot use a video tag to play rtsp streams as of now. The other answer regarding the link to Chromium guy's "never" is a bit misleading as the linked thread / answer is not directly referring to Chrome playing rtsp via the video tag. Read the entire linked thread, especially the comments at the very bottom and links to other threads.

我认为,这个问题的精神并没有得到真正的回答。不,您现在不能使用视频标签来播放 rtsp 流。关于 Chromium 家伙“从不”链接的另一个答案有点误导,因为链接的线程/答案并不是直接指 Chrome 通过视频标签播放 rtsp。阅读整个链接线程,尤其是最底部的评论和其他线程的链接。

The real answer is this: No, you cannot just put a video tag on an html 5 page and play rtsp. You need to use a Javascript library of some sort (unless you want to get into playing things with flash and silverlight players) to play streaming video. {IMHO} At the rate the html 5 video discussion and implementation is going, the various vendors of proprietary video standards are not interested in helping this move forward so don't count of the promised ease of use of the video tag unless the browser makers take it upon themselves to somehow solve the problem...again, not likely.{/IMHO}

真正的答案是这样的:不,您不能只是在 html 5 页面上放置视频标签并播放 rtsp。您需要使用某种 Javascript 库(除非您想使用 Flash 和 Silverlight 播放器播放内容)来播放流视频。{恕我直言} 按照 html 5 视频讨论和实施的速度,专有视频标准的各个供应商都没有兴趣帮助推动这一进程,因此除非浏览器制造商不考虑承诺的视频标签的易用性自己承担以某种方式解决问题......再次,不太可能。{/恕我直言}

回答by Pawel K

This is an old qustion, but I had to do it myself recently and I achieved something working so (besides response like mine would save me some time): Basically use ffmpeg to change the container to HLS, most of the IPCams stream h264 and some basic type of PCM, so use something like that:

这是一个老问题,但我最近不得不自己做,并且我取得了一些成果(除了像我这样的响应可以节省我一些时间):基本上使用 ffmpeg 将容器更改为 HLS,大多数 IPCams 流 h264 和一些PCM 的基本类型,所以使用类似的东西:

ffmpeg -v info -i rtsp://ip:port/h264.sdp -c:v copy -c:a copy -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 /var/www/html/test.m3u8

Then use video.jswith HLS pluginThis will play Live stream nicely There is also a jsfiddle example under second link).

然后使用带有HLS 插件的video.js这将很好地播放直播流第二个链接下还有一个 jsfiddle 示例)。

Note: although this is not a native support it doesn't require anything extra on user frontend.

注意:虽然这不是原生支持,但它不需要用户前端的任何额外内容。

回答by janesconference

Chrome will never implement support RTSP streaming.

Chrome 永远不会实现支持 RTSP 流。

At least, in the words of a Chromium developer here:

至少,在Chromium开发的话,在这里

we're never going to add support for this

我们永远不会增加对此的支持

回答by ankitr

There are three streaming protocols / technology in HTML5:

HTML5 中有三种流媒体协议/技术:

Live streaming, low latency - WebRTC - Websocket

实时流媒体,低延迟 - WebRTC - Websocket

VOD and Live streaming, high latency - HLS

VOD 和直播,高延迟 - HLS

1. WebRTC

1.WebRTC

In fact WebRTC is SRTP(secure RTP protocol). Thus we can say that video tag supports RTP(SRTP) indirectly via WebRTC.

事实上,WebRTC 是 SRTP(安全 RTP 协议)。因此我们可以说视频标签通过 WebRTC 间接支持 RTP(SRTP)。

Therefore to get RTP stream on your Chrome, Firefox or another HTML5 browser, you need a WebRTC server which will deliver the SRTP stream to browser.

因此,要在 Chrome、Firefox 或其他 HTML5 浏览器上获取 RTP 流,您需要一个 WebRTC 服务器,它将 SRTP 流传送到浏览器。

2. Websocket

2. 网络套接字

It is TCP based, but with lower latency than HLS. Again you need a Websocket server.

它基于 TCP,但延迟比 HLS 低。同样,您需要一个 Websocket 服务器。

3. HLS

3.HLS

Most popular high-latency streaming protocol for VOD(pre-recorded video).

最流行的 VOD(预录视频)高延迟流媒体协议。

回答by molokoloco

With VLC i'm able to transcode a live RTSP stream (mpeg4) to an HTTP stream in a OGG format (Vorbis/Theora). The quality is poor but the video work in Chrome 9. I have also tested with a trancoding in WEBM (VP8) but it's don't seem to work (VLC have the option but i don't know if it's really implemented for now..)

使用 VLC,我能够将实时 RTSP 流(mpeg4)转码为 OGG 格式(Vorbis/Theora)的 HTTP 流。质量很差,但视频在 Chrome 9 中工作。我也在 WEBM (VP8) 中进行了转码测试,但它似乎不起作用(VLC 有这个选项,但我不知道它现在是否真的实现了。 .)

The first to have a doc on this should notify us ;)

第一个有这方面的文档的人应该通知我们;)

回答by Renegah

My observations regarding the HTML 5 video tag and rtsp(rtp) streams are, that it only works with konqueror(KDE 4.4.1, Phonon-backend set to GStreamer). I got only video (no audio) with a H.264/AAC RTSP(RTP) stream.

我对 HTML 5 视频标签和 rtsp(rtp) 流的观察是,它仅适用于 konqueror(KDE 4.4.1,Phonon-backend 设置为 GStreamer)。我只得到了带有 H.264/AAC RTSP(RTP) 流的视频(无音频)。

The streams from http://media.esof2010.org/didn't work with konqueror(KDE 4.4.1, Phonon-backend set to GStreamer).

来自http://media.esof2010.org/的流不适用于 konqueror(KDE 4.4.1,Phonon-backend 设置为 GStreamer)。

回答by vrbsm

Chrome not implement support RTSP streaming. An important project to check it WebRTC.

Chrome 未实现支持 RTSP 流。一个重要的项目来检查它WebRTC。

"WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs"

“WebRTC 是一个免费、开放的项目,它通过简单的 API 为浏览器和移动应用程序提供实时通信 (RTC) 功能”

Supported Browsers:

支持的浏览器:

Chrome, Firefox and Opera.

Chrome、Firefox 和 Opera。

Supported Mobile Platforms:

支持的移动平台:

Android and IOS

安卓和IOS

http://www.webrtc.org/

http://www.webrtc.org/