html 5 可以提供实时媒体流吗?

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

Can html 5 serve real time media stream?

htmlvideo-streaming

提问by user198729

I've heard of many interesting features of html 5,

我听说过 html 5 的许多有趣的特性,

but is it able to serve real time media stream from web camera?

但它能够从网络摄像头提供实时媒体流吗?

回答by nebkat

Not html5 on it's own but html5 video can read streams(like on youtube, live streaming).

不是 html5 本身,但 html5 视频可以读取流(如在 youtube 上,实时流媒体)。

Streaming via RTSP or RTP in HTML5for some info

在 HTML5 中通过 RTSP 或 RTP 流式传输以获取一些信息

回答by Esko

HTML5 video is just a tag that looks like

HTML5 视频只是一个看起来像的标签

<video src="movie.mp4" controls="controls">
    Your browser doesn't support the video tag.
</video>

(reference here)

(参考这里

Whatever that movie.mp4actually contains is decided by the underlying server and may be streaming content as long as the format itself supports streaming. For example h.264's eXtended Profile and Scalable High Profile both support video streaming.

无论是movie.mp4实际包含由底层服务器决定的,可流化内容,只要格式本身支持流。例如h.264的 eXtended Profile 和 Scalable High Profile 都支持视频流。

回答by QueueHammer

I did the proof for this a few days ago. The answer is yes and no. Yes the XMLHttpRequest allows you to access the data while it is streaming from the camera. No it is not supported across all browsers.

我几天前为此做了证明。答案是肯定的和否定的。是的,XMLHttpRequest 允许您在数据从相机流式传输时访问数据。不,并非所有浏览器都支持它。

In a XMLHttpRequest you can get status messages from the object when done asynchronously. Problem being that each browser handels this a little diffrent. The big problem is that even though Internet Explorer dose support the update to the status if you try to access the data in state 3 it will give an error. For more info please follow the link.

在 XMLHttpRequest 中,您可以在异步完成时从对象获取状态消息。问题是每个浏览器处理这个有点不同。最大的问题是,即使 Internet Explorer 支持更新状态,如果您尝试访问状态 3 中的数据,它也会出错。欲了解更多信息,请点击链接

If your camera can send a video stream that is a standard media type like the other posters have been saying then that would be your best option. Maybe after the release of IE 9 will the XMLHttpRequest work as assumed.

如果您的相机可以像其他海报所说的那样发送标准媒体类型的视频流,那么这将是您的最佳选择。也许在 IE 9 发布后 XMLHttpRequest 会按预期工作。

回答by Tronic

This is probably what you are looking for:

这可能是您正在寻找的:

http://www.whatwg.org/specs/web-apps/current-work/complete/video-conferencing-and-peer-to-peer-communication.html

http://www.whatwg.org/specs/web-apps/current-work/complete/video-conferencing-and-peer-to-peer-communication.html

Unfortunately I have no idea of browser support at this time and the standard itself appears to be frequently changed.

不幸的是,我目前不知道浏览器支持,而且标准本身似乎经常更改。

回答by anderspitman

You can use ffmpegto convert the video real time from the camera format (MJPEG, etc) and then access the converted file while it's being generated. MP4 containers store some of the information at the end of the file, which prevents streaming, so unless you use a different container (ogg, mkv, etc) you'll need to use something like qt-faststartto generate real-time compatible MP4 files.

您可以使用ffmpeg从相机格式(MJPEG 等)实时转换视频,然后在生成转换后的文件时访问它。MP4 容器在文件末尾存储一些信息,这会阻止流式传输,因此除非您使用不同的容器(ogg、mkv 等),否则您需要使用类似qt-faststart 的东西来生成实时兼容的 MP4文件。

回答by Joey

This has nothing to do with HTML 5, actually. In HTML you just point the browser to a resource, specifying it's video. If your camera emits a stream in a format the browser is able to render, then it should work, sure. Though in my experience many cameras yield MJPEG and support for that directly in browsers appears to be limited at best.

实际上,这与 HTML 5 无关。在 HTML 中,您只需将浏览器指向一个资源,指定它的视频。如果您的相机以浏览器能够呈现的格式发出流,那么它应该可以工作,当然。尽管根据我的经验,许多相机会产生 MJPEG,并且在浏览器中直接支持 MJPEG 似乎充其量是有限的。