简体   繁体   English

如何在node.js应用程序中从计算机的麦克风和摄像头获取数据?

[英]How to get data from computer's microphone and camera in node.js application?

I want to make a node.js application that can access computer's microphone and camera. 我想制作一个可以访问计算机麦克风和摄像头的node.js应用程序。 One way of doing this would be to create a web server and use browser's webrtc API but I don't wanna do that I don't even want to open the browser. 一种方法是创建一个Web服务器并使用浏览器的webrtc API,但我不想这样做,甚至不想打开浏览器。 Is there a way that my app can access the computer's microphone and camera? 我的应用程序可以通过某种方式访问​​计算机的麦克风和摄像头吗? Ask me if the explanation is not clear. 问我解释是否不清楚。

Node.js runs on the server and has no GUI. Node.js在服务器上运行,没有GUI。 (Although who knows what people already wrote for node.js these days). (尽管谁知道这些天人们已经为node.js编写了什么)。 Also, although node.js is cross platform, communication to the microphone and camera is not. 同样,尽管node.js是跨平台的,但与麦克风和相机的通信却不是。 Every OS has its own way, its own APIs and drivers. 每个操作系统都有自己的方式,自己的API和驱动程序。

If you're trying to make a standalone application, that captures audio and video and shows it to the client on the same machine, node.js is not the best technology to use in this case. 如果您要制作一个独立的应用程序,该应用程序可以捕获音频和视频并将其显示在同一台计算机上的客户端上,那么在这种情况下,node.js并不是最好的技术。 Please provide more information on the purpose of your application, the platform etc. and maybe we can help you more. 请提供有关您的应用目的,平台等的更多信息,也许我们可以为您提供更多帮助。

Edit: Look at a similar question Accessing WebCam with NodeJS Note that WebRTC is not a capturing technology, it's a streaming technology. 编辑:看一个类似的问题使用NodeJS访问WebCam注意,WebRTC不是捕获技术,它是流技术。 The capturing of the video and audio is implemented in the browser and the implementation is different for every platform. 视频和音频的捕获是在浏览器中实现的,并且每个平台的实现都不同。 For example Chrome for Linux and Chrome for Windows are different pieces of software and implement the capturing differently. 例如,Chrome for Linux和Chrome for Windows是不同的软件,并且捕获方式也不同。 Only the webRTC API is the same for the web developer. 对于Web开发人员,只有webRTC API相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM