Hacker News new | ask | show | jobs
by diericx 1898 days ago
In complete sincerity, how is this better than ffmpeg

https://trac.ffmpeg.org/wiki/StreamingGuide

3 comments

It's certainly not better than FFmpeg. But I had a look through the source code and the author seems to have a fairly good grasp of WebRTC. The library looks really useful for anyone that wants to quickly understand WebRTC and how to use librtp and libsrtp. It's mostly a bare-bone wrapper around those libs.
Maybe it would be a good starting point for someone integrating it into ffmpeg
Yep, it looks easy to replace the function h264_get_next_frame(). I think you could get really decent performance if you used ffmpeg to pre-extract all of the frames into sequential files and serve them statically.
WebRTC with STUN is pure p2p where ffmpeg it requires a rtmp or rtsp server
Just for completeness sake this is what docs [1] state:

"For most WebRTC applications to function a server is required for relaying the traffic between peers, since a direct socket is often not possible between the clients (unless they reside on the same local network). <...>"

[1] https://webrtc.org/getting-started/turn-server

It’s a little more nuanced than this.

https://medium.com/the-making-of-whereby/what-kind-of-turn-s... fippo pulled the stats and saw 17%

This also depends on your clients network. You can determine your NAT mapping type[0] and now ahead of time if you need a TURN server.

To understand NAT behaviors more check out [1]

[0] https://github.com/pion/stun/tree/master/cmd/stun-nat-behavi...

[1] https://webrtcforthecurious.com/docs/03-connecting/#nat-mapp...

Modern networks use IPv6 only, so don't have NAT.
... how is STUN pure p2p ? you still need to have a STUN server somewhere no ?
STUN is just for punching holes in your NAT router, and also discovering what is your public IP address. Both things will be needed for the other peer to know where to reach you. And the other way around.

Once this NAT thing has been done by both parts, and the actual communication has started directly P2P, STUN is not needed any more.

You'd also need a TURN server if both peers are behind NAT without UPnP, which is very common. STUN alone wouldn't be enough.
That is partially incorrect, STUN can punch a hole through even when both sides uses NAT in many cases. That is what I would classify as STUN’s main feature.
Note that parent said “ if both peers are behind NAT without UPnP”. As far as I know, there’s no way to punch holes / open ports automatically without UPnP.
> STUN is just for punching holes in your NAT router, and also discovering what is your public IP address.

I know, but what I mean is that "true P2P" on our current internet architecture is not possible, you always need the help of a third party

If we are still in the 90's that definition of "true p2p" would be: two computers with both having public IPs and transferring packets via TCP. But nowadays we are always behind NATs so we became less strict with the definition of what is true p2p
IPv6 is slowly taking over, hopefully in the near future being behind a NAT will be considered abnormal (just like happened with Unicode, we're around 35% = "Unicode 2009", popularity-wise).
Then bittorrent is transcendent p2p?
Your p2p nodes might not be behind NAT. In a lot of populations you can rely on everyone having working v6 for example.

I think the question of what's "pure" p2p is somewhat academic. If your app uses DNS, is it p2p, isn't DNS just a distributed p2p database? Does p2p require that every aspect of your app right down to discovery is distributed among nodes running your app? Is it cheating to use an existing DHT? etc.

You can just use google stun servers they are free to use
Here's a list of public STUN servers (non google too) https://www.voip-info.org/stun/
Careful! P2P streaming video is a (completely non obvious, according to the courts) infringement of the VirNetX patent that for example Apple just had to pay a few billions of dollars for.

If you implement p2p video streaming chances are no company will want to touch it with a ten foot pole.

Um, shouldn't the patent have expired by now ?
Probably not or it would have been on the news and you would start seeing p2p communications again. It’s not rocket science, after all.
But p2p streaming has been around since the mid 2000's ?? (Pre-Microsoft Skype, Miro, Joost, Tribler...)

And for some recent examples : what about Popcorn Time ? Or PeerTube ?

EDIT : Oh, I guess that most of those are technically not "streaming", but "watching while downloading" like YouTube or FTP+VLC ?

The court does not agree with you. A peer to peer communication service, like FaceTime was originally, violates the patents.
Ahh I see
If you're using ffmpeg with rtp, you can use Pion to make it a WebRTC stream: https://github.com/pion/webrtc/tree/master/examples/rtp-to-w...