[英]Howto stream webcam data to a server?
I'm looking for a way to stream the webcam data from a browser to a webserver. 我正在寻找一种将网络摄像头数据从浏览器流式传输到网络服务器的方法。 The webcam data is acquired by using
getUserMedia
. 使用
getUserMedia
获取网络摄像头数据。 One common option seems to be to use a canvas and a timer in order to send screenshots to a server, but I want a proper video stream. 一种常见的选择似乎是使用画布和计时器以将屏幕截图发送到服务器,但是我想要适当的视频流。 WEBRTC seems to be another option, but that might be a bit over the top, plus there is not too much software that runs on a server (ie non-browser), speaks WEBRTC, and has bindings for Python.
WEBRTC似乎是另一种选择,但是可能有点过头了,再加上在服务器(即非浏览器)上运行,讲WEBRTC并具有Python绑定的软件太多。
Maybe I'm missing sompling simpler. 也许我缺少简单的放大。 For example, could the video stream be streamed using Websockets?
例如,可以使用Websockets流化视频流吗?
'use strict';
var errorCallback = function(e) {
console.log('Rejected!', e);
};
var successCallback = function(stream) {
console.log('Got Video.');
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(stream);
// ???
// Stream data to server
video.play();
};
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
var hdConstraints = {
video: {
mandatory: {
minWidth: 1280,
minHeight: 720,
}
},
audio: false,
};
if (navigator.getUserMedia) {
navigator.getUserMedia(hdConstraints, successCallback, errorCallback);
}
else {
console.log('No getUserMedia available.');
}
看起来当前最好的解决方案确实是使用画布,定期从网络摄像头创建图像并通过websocket发送图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.