How to create a stun, turn and signaling server - html5-video

Is there a simple guide from where I can start creating a stun / turn and signaling server ?
I spend over a week searching for those things and couldn't find any guide where I can say:
okay, I am on the right track now - this is clear.
So far, everything is so abstract without any examples.
This is what I'm trying to achieve: a simple video stream on my local network where I'll have a server with installed usb camera on it, and an application on my iis which will connect to the usb camera and stream it to the clients, and every time when a client opens the application, will see the video stream from the server camera.
Note: since I want to use it on my local network do I really need a stun/turn server, or is there a guide that shows how to avoid it ?

Media streamed over dedicated servers HTTP/HTTPS rarely needs a NAT traversal solution. Instead, just have your web server with camera attached, on the public Internet or behind your NAT with port-forwarding enabled.
There are LOTS of streaming media solutions available as open source, free downloads, or commercially sold. A good list is here:
https://en.wikipedia.org/wiki/List_of_streaming_media_systems

Related

Is it possible to save a video stream between two peers in webrtc in the server, realtime?

Suppose I have 2 peers exchanging video with webRTC. Now I need both of the streams to be saved as video files in the central server. Is is possible to do it realtime? (Storing/Uploading the video from peers is not an option).
I thought of making a 3 node webRTC connection, with the 3rd node being the server. This way, I can screen record the 3rd node's stream or save it using some other way. But I am not sure about the reliability/feasibility of the implementation.
This is for a mobile application, and I would avoid any method that involves uploading/saving.
PS: I'm using Agora.io for the purpose of video-conference.
in my opinion
you can do it like the record demo:https://webrtc.github.io/samples/src/content/getusermedia/record/.
record each stream to blobs and push them to your server with websocket.
then convert the blobs to a webm file or just add in a video
Agora doesn't offer on-premise recording out of the box but they do provide thee code for you to be able to launch your own on-premise recording using your own server. Agora has the code and instructions to deploy on GitHub: https://github.com/AgoraIO/Basic-Recording
The way it works, once you have set up the Agora Recording SDK, the client would trigger the recording to start, via user interaction (button tap) or some other event (i.e. peer-joined or stream-subscribed) this will trigger the recording service to join the channel and record the streams. _The service outputs the video file once recording has stopped.
you need a WebRTC media server.
WebRTC media servers makes it possible to support more complex
scenarios WebRTC media servers are servers that act as WebRTC clients
but run on the server side. They are termination points for the media
where we’d like to take action. Popular tasks done on WebRTC media
servers include:
Group calling Recording Broadcast and live streaming Gateway to other
networks/protocols Server-side machine learning Cloud rendering
(gaming or 3D) The adventurous and strong hearted will go and develop
their own WebRTC media server. Most would pick a commercial service or
an open source one. For the latter, check out these tips for choosing
WebRTC open source media server framework.
In many cases, the thing developers are looking for is support for
group calling, something that almost always requires a media server.
In that case, you need to decide if you’d go with the classing (and
now somewhat old) MCU mixing model or with the more accepted and
modern SFU routing model. You will also need to think a lot about the
sizing of your WebRTC media server.
For recording WebRTC sessions, you can either do that on the client
side or the server side. In both cases you’ll be needing a server, but
what that server is and how it works will be very different in each
case.
If it is broadcasting you’re after, then you need to think about the
broadcast size of your WebRTC session.
link:https://bloggeek.me/webrtc-server/

PubNub WebRTC demo working in same network but not over internet (even after established connection)

I was going through this PubNub WebRTC demo. https://kevingleason.me/SimpleRTC/minivid.html
Which works fine within same network (same browser or different devices across same network). But I tried using it over internet, I am able to connect a call but can not see anything but a black screen. This is the source for same tutorial
https://github.com/pubnub/SimpleRTC
I have gone through many such application, such as AndroidRTC
and I face same problem (black screen after connection over internet). I am unable to figure out why, any help is appreciated.
You need some sort of signaling mechanism (PubNub, Firebase, or your own software [nodejs seems the preferred choice these days]) to get the webRTC API communicating P2P on your local network. To get webRTC to work from one network to another you need a STUN server/service. Google provides free stun servers (stun:stun.l.google.com:19302). To get webRTC to traverse strict firewall settings and complicated networks you need a TURN server/service like xirsys.com.
This article covers it all ...
http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/

Twilio WebRTC vs DIY WebRTC

Is WebRTC going to be free for web developers to set up video calls on web pages?
why does Twilio having pricing 25c per mins for video calls,
is it going to be too expensive for the small guy to mange video calls on web hosting servers?
any advice from anyone deep into WebRTC already?
Some of the comments above are not well informed.
Someone wrote, since the bandwidth needed in case of media relay is higher as well. This is not entirely true, transmission happens between Peers(Browsers), servers are used just for signalling(relaying IP addresses of connecting peers and some more info), you can ROUTE your transmission from central server(for fail overs), but can surely do without it for free.
WebRTC is Free and you can setup the whole thing on your own without having to shell out even a penny. It is a bit hard and mitigating fail-overs is really difficult, but you can certainly do it for free.
Tokbox or Twilio charge money because these tools abstract some very rigid complexities of setting up, running and managing fail-overs in a WebRTC application.
In TokBox's Case:
You don't need to setup STUN, TURN servers, you don't have to worry
about integration with android or IOS clients, they provide a plugin
for IE too, so out of box you get everything and you just have to
concentrate on your application logic rather than WebRTC nuances.
This is a big plus.
Both RELAY and ROUTED schemes came in the box hence you can write
fail-over scenarios if RELAY communication fails. Although there are
some good JavaScript based frameworks that do this in a much cleaner
manner.
It adds slew of other goodies which help in building android and IOS
clients without any pain.
STUN or TURN Servers are used only for Signalling Purpose, and this signalling happens before any actual transmission. This signal is very small and carries the IP address of both the browsers(machines running browsers). For Transmission the communication is done between Browsers(Peer to Peer) themselves, so no server is involved.
Your relay is not happening from a central server so you don't have
to pay for the outgoing bandwidth cost.
To Setup Turn Server,
Use this server, build it and put it into a Rackspace/Amazon Web
Services instance and you are Good with your TURN
Server. That is It, setup your application and have fun with WebRTC
for FREE.
rfc5766-turn-server
If you wish to Use some more free framework to ease yourself more, check out: EasyRTC and PeerJS
Enjoy Developing with WebRTC....
Twilio developer evangelist here.
Your link at the end of your question points to our WebRTC page, which currently talks about the product Twilio Client. Twilio Client briefly is a way that, using WebRTC within browsers and mobile applications you can make phone calls to real phone numbers. This product does not allow you to conduct video calls.
Twilio Client has a cost because of the ability to call out from a browser to a telephone number. The cost is not in the WebRTC portion, but delivering those minutes to the other leg of the call.
Notably, it's not 25 cents ($0.25) a minute, instead it is just a quarter of a cent ($0.0025) a minute.
With regards to video calls with WebRTC, you can now access the public beta of Twilio Video, a platform to make setting up WebRTC calls much easier.
Twilio Video costs for the signalling infrastructure and you can see the prices here. If a WebRTC connection requires a TURN server to relay the media, that also costs per gigabyte of transfer. Usage of the STUN server is free, the costs for the TURN relay are available here.
Please get in touch with me at philnash#twilio.com if you have any other questions about WebRTC.
WebRTC is a technology placed in a browser. It requires backend infrastructure to support it - specifically, STUN and TURN servers as well as signaling servers.
This boils down to the fact that you pay for WebRTC - same as you pay for hosting your website on a server. The price is higher, since the bandwidth needed in case of media relay is higher as well.
To understand more about WebRTC and how it works (as well as why there's a price tag associated with services such as Twilio for it), you can check this free report: https://bloggeek.me/webrtc-business-people/
WebRTC is already free for developers to use. When we added WebRTC to our product, we used this example code, which made it very simple to build a WebRTC client:
https://shanetully.com/2014/09/a-dead-simple-webrtc-example/
Google and Mozilla provide free STUN servers, and it is easy to set up a TURN server. Most clients will be able to connect via STUN, so you won't end up using too much bandwidth on your TURN server.
To set up your own TURN server, coturn seems to be the easiest to set up:
https://github.com/coturn/coturn
Make sure you read the "WEBRTC USAGE" section in the README.turnserver file.
"STUN or TURN Servers are used only for Signalling Purpose, and this signalling happens before any actual transmission. This signal is very small and carries the IP address of both the browsers(machines running browsers). For Transmission the communication is done between Browsers(Peer to Peer) themselves, so no server is involved."
if that is the case, then you should be able to do this on a standard web server using Java/php. PHP will get the IP address of the guys connected to it. Then its just a matter of storing them in MySQL, then making a javascript that would run when the user go to that page in the site.
I've been looking for a solution around using a VPS because running a dedicated server for signaling is like golfing with a Ferrari instead of a golf cart. I still don't think node is efficient. Its single threaded. so node's fararri can only go 5mph.
Since they went to the web site, the php service already can get their ip address what else does it need? All of the above solutions so far require you to pay for a dedicated app to run on a server connected to the web separately for what 5k of data? What a waste of electrons.
But I'm going to start a new thread that is going to be based on getting webrtc without the buy a "VPS" because we want a VPS-less solution.

WebRTC Relay Server / Broadcast multiple clients

I've got WebRTC peer to peer working but when I want to broadcast a single camera to multiple clients obviously peer to peer isn't suitable.
I've found solutions like
http://lynckia.com
and
http://www.medooze.com/products/mcu/webrtc-support.aspx
But the first I can't get setup (and it seems to have cross browser issues)
the second just feels like we're hitting a nail with a nuclear missile.
All I need is a relay, I don't need to decode / recode streams.
I just need
The Broadcaster to connect to the server (peer to peer)
The clients to connect to the server (peer to peer)
The server to relay the stream from the broadcaster to the clients.
Is there any software out there that offers this solution that I've missed? is there an alternative working and scalable alternative?
Thanks
Jitsi Video Bridge works pretty much exactly how you describe.
On your server you can run Janus, to which your broadcaster can provide a stream via RTP.
Have a look at an example configuration file.
After writing a configuration file which defines how the server receives stream from the broadcaster, you should be able to launch janus in the background via a command line interface tool:
$ janus --daemon --config=config_file.conf
Also, see streaming test demo.
Note: I have not tested this thoroughly.
Have a look at this github-repo inspired from muaz khan's WebRTC p2p scalable broadcast. This can work great on LAN. On internet, I am not sure how well it can work as of now though we are improving it on the go.
If you just want to broadcast from a peer to a set of peers, if they don't care about the latency, the best solution is to covert WebRTC to live streaming, without transcoding just muxing:
Peer(Publisher) ---WebRTC--> Server --RTMP/HLS/DASH--> Peers/Players
If this works good for you, SRS is able to covert WebRTC to live streaming.
Because live streaming allows you to use CDN or TCP to deliver the streams, and the latency is about 3~5s, so this solution is only available when Peers/Players never need to communicate to the Peer(Publisher).
If you want all those peers to talk to each other, it's very complex and need a WebRTC SFU cluster to do this, there will be a huge number of streams. For example, if allows 100 peers to talk to each other, there will be 100x100 = 10k streams.
It's too complicated, so I don't think there is good open-source solution right now(at 2022.02).

Find available RTMP channels on a media server (e.g. Adobe)

I am planning a software application where the user will be able to select a given media channel from a list of RTMP streams available on one or more media servers on the internet. The list should ideally be dynamically created through some kind of service that knows about the available and active channels.
My question is: Would this be possible through some kind of protocol between the service and the media server. I understand that RTMP by itself doesn't allow this. A therefore assume that some outbound mechanism will be required.
No...
...there is no native application discovery in RTMP. If you'd like this kind of functionality you'll need to program some sort of discovery service for which ever streaming server you are running.