如何将视频从 USB 网络摄像头流式传输到远程 HTML 页面 [英] How Do I Stream Video From My USB Webcam To A Remote HTML Page

查看:117
本文介绍了如何将视频从 USB 网络摄像头流式传输到远程 HTML 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个程序,将视频从我的 USB 网络摄像头通过互联网传输到网页.

I want to create a program that will stream video from my USB webcam over the internet to a web page.

目前,我使用一个网络服务,当触发时调用 fswebcam 来捕获图像,保存到数据存储,转换为 base64 二进制并将该数据发送到 HTML 页面,在那里它被渲染成'img' 的 'src' 属性.HTML 页面具有每秒调用一次此服务的 JavaScript.

Currently, I use a webservice that when triggered, calls fswebcam to capture an image, save to data store, convert to base64 binary and send that data over to the HTML page where it is rendered into the 'src' attribute of 'img'. The HTML page has JavaScript that calls this service once per second.

正如你所知道的那样,这是一种可怕的方式.如果可以的话,我宁愿有一个适当的流.但我不知道有哪些技术可以实现这一点.

As you can tell this is a horrible way to do this. I would rather have a proper stream if I can. But I don't know what technologies are available to achieve this.

Web 服务是用 nodeJS 编写的.服务器在 raspberry pi 2 上运行.我没有把这个问题放在 raspberry pi forum 中,因为我认为这是一个普遍的 Linux/programming 问题.

The webservice is written in nodeJS. The server is running on a raspberry pi 2. I didn't put this question in the raspberry pi forum because I think it's a general Linux/programming issue.

推荐答案

使用像 livecam.

使用 GStreamer 和 Node.js 的网络摄像头直播解决方案

Webcam live-streaming solution using GStreamer and Node.js

此模块允许您通过网络流式传输网络摄像头以供浏览器使用和/或流式传输到文件.请参阅文档了解更多信息.

This module allows you to stream your webcam over a network to be consumed by your browser and/or streamed to a file. See documentation for more inforamtion.

用法:

// npm install livecam

const LiveCam = require('livecam');
const webcam_server = new LiveCam({
    'start' : function() {
        console.log('WebCam server started!');
    }
});

webcam_server.broadcast();

这篇关于如何将视频从 USB 网络摄像头流式传输到远程 HTML 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆