How do I stream webcam video from my c++ app to my webserver?

I'm trying to stream video captured from my webcam using open cv (c++) to my Node.js server using web sockets.

Here's what I got so far:

- I'm capturing (and analyzing frames) with OpenCV (C++).
- Successfully using Microsoft's cpprest lib to send and receive messages between my c++ application capturing the webcam frames, to my nodejs server.

What I think I should:

Would sending each frame captured in my c++ while loop to my node server though web sockets be the most optimal way of streaming video? Or is there a better way?

Note that I'm trying to stick to my node.js server, so I'm guessing web sockets is the correct route to take?

Happy new year to all :)
Last edited on
Web sockets are fine, and nothing wrong with node- it makes things easy. You should consider compressing that stream before sending it otherwise you will have a pretty massive throughput depending on the resolution.

If you don't need realtime (or you are okay with a bit of lag time) you should consider bundling the data into packets(don't send a continuous stream, send bursts of larger data instead) for the sake of efficiency
Thanks wizebin, I actually figured it out and you're right, websockets work fine and I only get very little bit of normal lag on a local server.

I convert the image file to base64, send it to the node js server and from there to the client where it will render it on on a 2D canvas (browser).
Topic archived. No new replies allowed.