简体   繁体   English

如何将网络摄像头数据流传输到服务器?

[英]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.

相关问题 如何将服务器网络摄像头流式传输到servlet - How to stream server webcam to servlet WebRTC:如何将网络摄像头数据作为数据流? - WebRTC: how to get the webcam data as a stream of data? 将webcam.js数据发送到python服务器 - Sending webcam.js data to python server 在使用网络摄像头输入进行面部识别(opencv4nodejs)时,如何在服务器(javascript)上记录和下载/上传网络摄像头 stream? - How do I record AND download / upload the webcam stream on server (javascript) WHILE using the webcam input for facial recognition (opencv4nodejs)? 用于网站实施的网络摄像头图像流 - Webcam image stream for website implementation 如何使用javascript和python3上传网络摄像头视频流并在它们到达服务器后立即发送字节? - How to upload a webcam stream of video and send bytes as soon as they arrive to the server using javascript and python3? 如何在HTML 5中将网络摄像头流式传输到客户端 - How to stream webcam to client in HTML 5 记录(并停止)已经运行的网络摄像头/媒体流 - Record (and stop) an already running Webcam/Media Stream 重新连接网络摄像头时,WebRTC会继续播放视频流 - WebRTC continue video stream when webcam is reconnected HTML5网络摄像头流以某种方式中断 - HTML5 Webcam Stream broke somehow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM