Soroush Khosravi
Soroush Khosravi

Reputation: 917

Broadcast web cam with socket.io?

I can get stream from browser with these lines of code:

var socket = io.connect('127.0.0.1:9000');
navigator.getUserMedia  = navigator.getUserMedia ||
                          navigator.webkitGetUserMedia ||
                          navigator.mozGetUserMedia ||
                          navigator.msGetUserMedia;


var cam;
navigator.getUserMedia({video: true, audio: true}, function(stream) {
    //var call = peer.call('another-peers-id', stream);
        //call.on('stream', function(remoteStream) {
        // Show stream in some video/canvas element.
    //});
    cam = stream;
    console.log(stream);
}, function(err) {
    console.log('Failed to get local stream' ,err);
});

Now I want to send live stream to socket.io server and then broadcast it with socket.io server.
Is there any simple code to do it ?

Upvotes: 9

Views: 6975

Answers (1)

Delaney
Delaney

Reputation: 111

I tried for a few days to get something like this working, and after going down the rabbit hole I ended up just firing up an instance of Wowza media server on AWS (following these instructions) and managing the server with my node instance instead of trying to do the video.

It worked beautifully. Scales well (auto-scaling even), relatively easy to deploy, and has great support on their forums. A++, would code again.

Also, ultimately you're probably going to need to do some transcoding/scaling/watermarking if this is to be a commercial project, and Wowza leverages NVENC on the GPU on Amazon's graphics instances, which just blows anything else out of the water.

Upvotes: 1

Related Questions