Streaming video from HTML5 to node.js

Viewed 1946

I have a node.js server which uses the "ws" npm package. From HTML5 I can get the users webcam stream but how do I send the webcam stream through a HTML5 websocket to my node.js server?

Currently I have this code on the server:

wss.on('connection', function(ws) {
  ws.on('message', function(data, flags) {
    console.log("Message received");
  });
});

And on the client this code:

var ws = new WebSocket('ws://localhost:8080');

ws.onopen = function() {
  ws.send(stream);
}

Where the stream is from navigator.getUserMedia with video: true.

Thanks in advance!

1 Answers
Related