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

lawik
It is my pleasure to announce the official release of the new generation of NervesHub with the v2.0.0 release. Containers are tagged. :p...
New
mobileoverlord
New versions of the Kiosk systems are out. These systems update official Nerves systems with a local web browser for rendering user inter...
New
bartblast
I’m excited to announce Hologram v0.5.0, a major evolution of the full-stack Elixir web framework! This release brings massive performanc...
New
zachdaniel
Had a great time at Jax.Ex! Gave a talk called “Model your Domain, Derive the Rest”. Thanks to the folks at HashRocket for having me!
New
zachdaniel
Hey folks! AshEvents Release We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps. Check o...
New
bartblast
Hi friends, I wanted to share an update on Hologram that’s been on my mind lately. After nearly 3 years of full-time work on Hologram, ...
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
hugobarauna
Welcome to the second day of Livebook Launch Week! :tada: Today we will discuss all the new Machine Learning capabilities in Elixir and ...
New
hugobarauna
Learn how to use Livebook to build a Machine Learning app and deploy it to Hugging Face in less than 15 minutes. If you have any questio...
New
Jskalc
LiveVue v1.0 released After four release candidates and a lot of community feedback, LiveVue 1.0 is stable :tada: I’ve built a dedicated...
New

Other popular topics Top

New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement