mmaelzer / mjpeg-camera

A node.js library and/or server for connecting to, recording from, and streaming mjpeg cameras.
71 stars 23 forks source link

Display on a Reactjs app #16

Open Luisquii opened 2 years ago

Luisquii commented 2 years ago

Hi,

My goal is to display in a Reactjs web app the images that my camera is streaming as MJPEG (10 per second)

Also I want to take a picture everytime I press a button.

I have the IP, username, password and url where my camera is streaming.

Am I supposed to run this library on Express backend?

I have tried it but I'm not seeing that the file is writed on /frames or /motion

Sometimes when I try to snapshot I get the next error:

videostream.on('data', this.onFrame.bind(this)); ^ TypeError: Cannot read properties of undefined (reading 'on') at Camera.start (C:\Users\100032595\Documents\GitHub\welcomi_localweb\welcomi_localweb\backend\node_modules\mjpeg->camera\mjpeg-camera.js:50:15)

Is a Hikvision camera and I followed the next doc to get the MJPEG stream: HIKVISION

mmaelzer commented 2 years ago

Hi, first off, apologies on the delay.

This library assumes you are running in a node.js environment, so an Express backend could be one way to tackle this. Take a look at the camera server found in this repo to see an example of running mjpeg-camera on a server.

If you want to stream purely from a browser, you should be able to use browserify to get support for the node.js modules used by mjpeg-camera and its dependency mjpeg-consumer.

I'm unsure what's causing your specific error since I can't see the code, but do take a look at the camera server in case it helps.