WebRTC live video stream node.js - javascript

I am searching for a way to stream video with webRTC. I am very new to webRTC. I have seen a lot of applications on the web that have p2p video chat. The tutorials I follow explain how WebRTC working for the client, but they do not show what use a backend script. And that's exactly what I'm looking for, a backend script (preferably node.js) that ensures that I can stream live video (getUsersMedia) to the client.
Marnix Bouhuis

Its really simple to get started, checkout a simple demo here
1.You need a WebRTC supported browser. Chrome and firefox are best at now
A signalling server to exchange a media options. SocketIO with Nodejs
TURN and STUN server to solve NAT and Symmetric NAT (Only if you public)
MCU, if you want to limit the bandwidth usage. It give flexibility to a star network rather than mesh network in normal p2p

Related

Live Audio Streaming over HTML5/NodeJS

I'm trying to make a website that will serve as a VoIP recorder app. It will take audio from the microphone, transmit the audio to the server and the server only, and then the server will handle the redistribution of audio to it's connected clients.
Here's what I've tried already:
WebRTC (from what I can tell, it's peer-to-peer only)
MediaRecorder - timeSlice to Socket.IO (only the first packet is playable due to header information)
MediaRecorder - Stopping every few milliseconds, transmitting the audio, and starting again. (is extremely choppy)
The stack I'm set on is NodeJS with Express, but I'm extremely open to any packages that will help.
As far as possibility, I know it is possible because Discord wrote in their own blog that they explicitly do not send packets peer-to-peer because they have large numbers of connected users.
Below is the way I imagine it being setup:
Anyways, hope someone can help - I've been stuck on this for a while. Thanks!
WebRTC is NOT only P2P. You can put a WebRTC Peer on a server (and then have it do fan-out). This is what all major conferencing solutions do. SFU is a very popular deployment style, mesh isn't the only thing you can do.
You can go down the MediaRecorder path, but you are going to hit issues with congestion control/backpressure.

Is there API that can make possible for a browser to PUSH media chunk to another browser

I am a beginner and I am trying to set up a peer-assisted media streaming system, that will work over the web browser. I wish to a server to 'push' media segments to a few clients and then any of these client browsers to push media segment to other client browsers.
I got to know that HTTP/2.0 can make this possible, but I found examples on a server to a client browser.
I came across WebRTC technology. however, could not find anything like PUSH technique among client browser.
I came across WebSocket technology. I found that it does PUSHing from the only server to the client.
Kindly direct.
You should use WebRTC + Socket or any other signaling media system to do it.
WebRTC will send the media peer to peer and the signaling server should manage which connections to make and when. I've seen similar product on the web yet.
WebSocket is not fast enought to stream media. WebRTC is far better when talking about media.

How does Youtube/Facebook live stream from web browser works

I'm looking at a way to implement video encoder using web browser. Youtube and Facebook already allow you to go live directly from the web browser. I'm wondering how do they do that?
There are a couple of solutions I've researched:
Using web socket: using web browser to encode the video (using mediarecorder api) and push the encoded video to the server to be broadcast.
Using WebRTC: web browser as a WebRTC peer and another server as the other end to receive the stream and re-broadcast (transcode) using other means (rtmp, hls).
Is there any other tech to implement this that those guys (YouTube, Facebook) are using? Or they also use one of these things?
Thanks
WebRTCHacks has a "how does youtube use webrtc" post here which examines some of the technical details of their implementation.
In addition one of their engineers gave a Talk at WebRTC Boston describing the system which is available on Youtube
Correct, you've hit on two ways to do this. (Note that for the MediaRecorder method, you can use any other method to get the data to the server. Web Sockets is one way... so is a regular HTTP PUT of segments. Or, you could even use a data channel of a WebRTC connection to the server.)
Pretty much everyone uses the WebRTC method, as there are some nice built-in benefits:
Low latency (at the cost of some quality)
Dynamic bitrate
Well-optimized on the client
Able to automatically scale output if there are not enough system resources to continue encoding at a higher frame size
The downsides of the WebRTC method:
Ridiculously complicated stack to maintain server-side.
Lower quality (due to emphasis on low latency, BUT you can tweak this by fiddling with the SDP yourself)
If you go the WebRTC route, consider gstreamer. If you want to go the Web Socket route, I've written a proxy to receive the data and send it off to FFmpeg to be copied over to RTMP. You can find it here: https://github.com/fbsamples/Canvas-Streaming-Example

WebRTC video streaming through a server

I wanna run the stream from client side then join from server to client
. How can I stream the video through a server to another Viewers? Is this possible?
I would like to try and point you in the right direction.
First, lets understand a little more about how WebRTC works.
In WebRTC you have a websocket that is called the bridge, the bridge's role is to help broker a connection between two or more peers.
Generaly speaking, the bridge uses STUN/TURN servers along with SDP Protocol to help establish the connections between peers.
STUN servers are used to establish p2p udp conenctions by punch holes through NAT.
If the STUN fails to punch a whole (ie there is a firewall), a TURN server is used as a hub & spoke (ie relays data though the TURN server).
The full WebRTC stack includes video/audio streaming with vp8/vp9/h264 codecs & data is packaged using RTP.
Lucky for you there is a node-js library that implments almost the entire stack.
https://github.com/js-platform/node-webrtc
The library essentially provides you a WebRTC data channel.
There is no support for "Media Streams" and thus I assume you need to build the encoding/decoding and RTP packaging yourself.
However, there is a discussion here on how to stream audio/video with the data channel:
https://github.com/js-platform/node-webrtc/issues/156
Now, your specific question, how to stream from a "server"?
Well WebRTC is generally p2p, however you could setup a "Server Peer" and designate it as having a source channel only (ie there is no input channel).
This peer then becomes the "server" and all the other peers can view its contents when they connect.
Hope that helps.
Cheers!

How to implement video conferencing feature inside a website using webRTC?

Recently I was working on a webRTC project that displays media stream in users browser. However this was only on the client side. What if I want to stream this media to other users browser. As I looked around I found that it was possible by connecting to peers and setting up signalling servers (STUN & TURN). I went through all details that was mentioned on one of the articles on html5rocks website.
I am making use of simplewebRTC but that isn't enough I have to set up my own signalling server in order to be actually able to video chat.
My question is what actually is needed in order to implement a live video chat application embedded within website apart from the api provided by webRTC and how do I set up my own signailling server.
signalmaster was built as a signaling server for simplewebrtc and used by talky.io. It's a node application, start it with "node server.js" and then hook up simplewebrtc to the socket.io endpoint provided.
STUN and TURN servers are not signaling servers. They just help with punching a hole through NAT. The most popular option is rfc-5766-turn-server, restund performs quite well too.
You should provide more detail about your project to get a good answer. Are you planning on making only browser to browser calls? SIP calls? These would be a factor in the signalling server you choose. I went with a SIP signalling server (SIPML5.org) and integrated it with an Asterisk server for call control. This also let me integrate my existing corporate telepresence devices into the PBX. If you want to read up on the basics of signalling and on Webrtc in general Muaz Khan has done some very good work on it.
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Signaling.md

Categories

Resources