Jeykey

Jeykey

I’m currently doing some research about live streaming and live video (like Twitch, YouTube Live, etc.). There are a lot of different technologies and tools out there for implementing real time video & audio in the web and mobile.

I found WebRTC and originally thougth it was a good fit. But after learning the details, I found a lot of complications with things like TURN servers and the overall need for a lot of different servers and services. As far as I understand it, the sending client could actually be more demanded with more viewers which is a no-go for this type of application.
Looking for simpler solutions I found protocols like HLS and RTP but I found issues with delay and a lack of Elixir implementations for both of them.

Looking around I also found a tutorial using NodeJS and normal websockets, just sending the raw images in Base64 (or other encoding) over the websocket. I have some performance concerns about this, but I have no data to know how fast Websockets and more specifically Phoenix Channels perform.
Since I saw that UDP seems to be the better option, I looked into :gen_utp, but it seems like a lot of the inifrastructure would have to be implemented, since there aren’t any frameworks.

Does anybody have any experience using Elixir or Phoenix for video live streams could give me some advice?

Showing Posts 1 to 10

peck

peck

you may want to take a look at mux and their competitors. They’ve solved a lot of these problems and will let you focus on the goals of your product vs getting bogged down in the details of video streaming.

Also, be sure to do your math. Bandwidth gets very expensive very quickly with video at level of scale, you don’t want to be hit with a giant bill at the end of the month that your customers payments aren’t able to cover.

mat-hek

mat-hek

Membrane Core Team

Hi @Jeykey, Membrane has a pure elixir implementation of RTP - see the demo and we recently created a bunch of components for streaming via HLS. We’re now documenting and polishing them, so they should be available shortly :wink: We’re also preparing an article about building a Twitch-like app with Membrane, watch the membrane tag if you’re interested.

Whatever solution you end up with, definitely don’t send raw images, especially in base64, as it will generate huge traffic and won’t scale at all (maybe unless you have very low resolution and framerate)

10
Post #2
Jeykey

Jeykey OP

From what I’ve read so far, HLS seems to have quite a high latency. Whats your experience and is it suitable for something like Twitch?

mat-hek

mat-hek

Membrane Core Team

I believe Twitch itself uses either DASH or HLS, and so does Youtube/Facebook live. That’s because of scaling - those protocols basically split the stream into small chunks and serve them via HTTP, so you can quite easily set up a CDN in between and handle thousands of viewers. But yes, that also introduces higher latency - usually about 10 seconds - and while I suppose you can get better, it is not going to be even close to RTP’s 200-500 milliseconds. If the lowest possible latency is required, the solution is to use RTP on both sides. I see two options there:

  1. Peer to peer - streamer sends directly to each viewer - can handle a few receivers and strains the sender, but is relatively easy to implement with WebRTC - requires only a signalling server, such as Membrane WebRTC server and JS clients
  2. RTP between streamer and server and RTP between server and each viewer - if you want to have browser clients you still need to use WebRTC, but this time via WebRTC gateway on the server. And this will not scale as easily as HLS/DASH.
Jeykey

Jeykey OP

In the Discord Blog I read that they use WebRTC but run all their traffic through a Gateway for moderation and for protecting the IP addresses of the users. Why would you want to use a technologie designed for P2P in a Client / Server architecture?

mat-hek

mat-hek

Membrane Core Team

For two main reasons

  • it’s widely supported, in particular by all the popular browsers
  • P2P and client-server scenarios don’t really differ in terms of the itermediary protocol - when you make server a peer, client-server is still P2P from that point of view
Jeykey

Jeykey OP

I understand some of the advantages of WebRTC, but I’m still somewhat confused about how to use it in a centralized server architecture, like the one described by Discord.

Routing audio/video through media servers offers other advantages as well, such as moderation.

Are they describing a TURN server, or another solution?
They also talk a lot about WebSockets end using Elixir, at least for their Signaling server.
What is the involvement of Elixir in their (or another WebRTC) application?
Could you also transfer video & audio through Websockets?

mat-hek

mat-hek

Membrane Core Team

Are they describing a TURN server, or another solution?

TURN stands for Traversal Using Relay NAT, so it seems they have something beyond TURN. Nevertheless, the architecture is probably similar.

They also talk a lot about WebSockets end using Elixir, at least for their Signaling server.

WebRTC doesn’t standardize technologies to be used in the signalling layer, so the use of WebSockets is absolutely valid.

What is the involvement of Elixir in their (or another WebRTC) application?

Don’t really understand this question. It’s possible to implement entire WebRTC stack in Elixir, we aim to do that at Membrane.

Could you also transfer video & audio through Websockets?

Video or audio is just a stream of data, so you can transfer (send and receive) them anyhow. The problem is that live streaming is way more complex than just sending and receiving data. You can see this talk by @mspanc to have some overview. Proper tooling can handle significant part of that complexity.

jayjun

jayjun

@mat-hek I look forward to your article. What do you think of this blog post’s approach?

mat-hek

mat-hek

Membrane Core Team

Well, that’s the article I was speaking of, it’s by my teammate and I reviewed it :stuck_out_tongue: So personally I think the approach is perfect :smiley: I posted about that in the membrane thread but it looks like it’s not visible enough there. @AstonJ can it be separated?

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews