Javascript 如何从 HTML5 访问网络摄像头?

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

How to access webcam from HTML5?

javascripthtml

提问by Adrian B

I want access webcam from HTML5 for register and save a video file, for playing later. Is this possible?

我想从 HTML5 访问网络摄像头进行注册并保存视频文件,以便稍后播放。这可能吗?

回答by OverZealous

Apparently, the <device>tag is not part of the HTML5 spec, and therefore there is no currently standard way to access webcams from a browser. You might be able to get away with using the JavaScript API navigator.getUserMedia(...), but that isn't supported by any browsers, either

显然,该<device>标签不是 HTML5 规范的一部分,因此目前没有从浏览器访问网络摄像头的标准方法。您可能可以使用 JavaScript API 逃脱惩罚navigator.getUserMedia(...),但任何浏览器都不支持

You can read up on this here: Which web browsers support the HTML5 <device> tag?

您可以在这里阅读:哪些网络浏览器支持 HTML5 <device> 标签?

回答by Mars Robertson

I was doing similar research recently and found a working demo: http://gadgets-code.com/taking-webcam-photo-with-opera-browser-new-technology

我最近在做类似的研究,发现了一个工作演示:http: //gadgets-code.com/taking-webcam-photo-with-opera-browser-new-technology

It requires install of an experimental version of Opera: http://snapshot.opera.com/labs/camera-and-pages/

它需要安装 Opera 的实验版本:http: //snapshot.opera.com/labs/camera-and-pages/

Happy hacking!

快乐黑客!



UPDATE [20 May 2012]:

更新 [2012 年 5 月 20 日]:

http://www.webrtc.org/running-the-demos- WebRTC - GoogleChromeCanary - about://flags - enableMediaStream + PeerConnection :) Me recommends - Jerome Etienne's blog - http://learningthreejs.com/

http://www.webrtc.org/running-the-demos- WebRTC - GoogleChromeCanary - about://flags - enableMediaStream + PeerConnection :) 我推荐 - Jerome Etienne 的博客 - http://learningthreejs.com/

UPDATE [13 Sep 2012]:

更新 [2012 年 9 月 13 日]:

WebRTC enabled in Chrome 21 by default (change introduced couple weeks ago)

默认情况下,Chrome 21 中启用了 WebRTC (几周前引入了更改)

UPDATE [2 Jul 2014]:

更新 [2014 年 7 月 2 日]:

WebRTC is mainstream / huge: http://youtu.be/GBAEG_RuqeE?t=50m1s(Google Hangouts, Amazon Mayday, Snapchat)

WebRTC 是主流/巨大:http: //youtu.be/GBAEG_RuqeE?t=50m1s(Google Hangouts、Amazon Mayday、Snapchat)