Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Stream Video From My USB Webcam To A Remote HTML Page

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

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.

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.

like image 893
X0r0N Avatar asked Sep 02 '15 07:09

X0r0N


People also ask

Can I use USB camera with Raspberry Pi?

Rather than using the Raspberry Pi camera module, you can use a standard USB webcam to take pictures and video on the Raspberry Pi. Note that the quality and configurability of the camera module is highly superior to a standard USB webcam.


1 Answers

Use a framework like livecam.

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.

Usage:

// npm install livecam

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

webcam_server.broadcast();
like image 136
Dean Meehan Avatar answered Nov 16 '22 00:11

Dean Meehan