mat-hek

mat-hek

Membrane Core Team

Boombox - a simple streaming library on top of Membrane

Hi everyone,

I’d like to share with you a new library from the Membrane team - Boombox. It’s a simple streaming tool built on top of Membrane. It’s not as flexible as Membrane, but simpler to learn :wink:
For example, receiving an RTMP stream and broadcasting it via HLS is as simple as

Mix.install([:boombox])

Boombox.run(input: "rtmp://localhost:5432", output: "index.m3u8")

Boombox also allows you to interact with media in the Elixir code using a Stream-based API. For example, here’s how to generate a video and send it to a browser over WebRTC using Boombox and Image:

Mix.install([:boombox, :image, :req])

image =
  Req.get!("https://avatars.githubusercontent.com/u/25247695?s=200&v=4").body
  |> Image.open!()

angle = Stream.iterate(0, fn a -> rem(a + 3, 360) end)

timestamps =
  Stream.iterate(0, fn pts -> pts + div(Membrane.Time.seconds(1), 60) end)

Stream.zip(angle, timestamps)
|> Stream.map(fn {angle, pts} ->
  image = Image.rotate!(image, angle) |> Image.thumbnail!(200)
  %Boombox.Packet{kind: :video, payload: image, pts: pts}
end)
|> Boombox.run(
  input: {:stream, video: :image, audio: false},
  output: {:webrtc, "ws://localhost:8830"}
)

And there’s much more - see examples.

More info in the blog post.

We hope that Boombox will make media streaming in Elixir easier for everyone and smooth out the learning curve for Membrane :wink:

Happy streaming!

Most Liked

chrismccord

chrismccord

Creator of Phoenix

Fantastic work! I can’t wait to play with this.

mat-hek

mat-hek

Membrane Core Team

Thanks! Specially for you, thumbnails :tada:

Boombox.run(input: "file.mp4", output: {:stream, video: :image, audio: false})
|> Stream.chunk_by(fn packet -> div(packet.pts, Membrane.Time.seconds(2)) end)
|> Stream.map(fn chunk -> hd(chunk).payload |> Image.thumbnail!(200) end)
|> Stream.with_index()
|> Enum.each(fn {thumbnail, i} -> Image.write(thumbnail, "thumb_#{i}.jpg") end)

Where Next?

Popular in News & Updates Top

fhunleth
We recently released Nerves 1.4.0 and an update to the Nerves new project generator, nerves_bootstrap. The biggest change is support for ...
New
fhunleth
We recently released Nerves 1.5.0 and corresponding updates to the Nerves new project generator, nerves_bootstrap and our official system...
New
jjcarstens
I know you might be thinking ¬ “Why make another SSH daemon wrapper when there already exists many like sshex and esshd??” Well, grea...
New
hugobarauna
This post introduces the new data features in Livebook 0.9: fast data exploration through integration with Explorer, interactive data tab...
New
fhunleth
It looks like it’s finally safe to announce that Nerves supports Erlang/OTP 26 and Elixir 1.15! We’ve updated dozens of Nerves and close...
New
mat-hek
I’m thrilled to announce that for the first time, we’re organizing RTC.ON - the conference about Membrane and multimedia streaming :tada:...
New
zachdaniel
Hey folks! In order to give the new AshSqlite a trial run and make sure its got some real usage, AshHq’s multi-package search has been re...
New
zachdaniel
Hey everyone! Work is progressing nicely on bulk updates & destroys, which are the primary missing features before I switch to focus ...
New
zachdaniel
Ash 3.1 Released! Major themes Generators! These are just the first entries into a powerful new suite of tools. Check out the generator d...
New
mat-hek
Hi there! So far we’ve been posting news about Membrane & multimedia mostly on X/Twitter, but from now on we’d like to share them on ...
New

Other popular topics Top

josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement