Boombox — a simple streaming library on top of Membrane
Mateusz Front•Sep 17, 2024•3 min readLast week, at the RTC.On Conference, I had the pleasure of announcing a new Elixir library created by the Membrane team: Boombox. In this article, I’ll shortly explain what Boombox is and the motivation behind creating it.
Meet Boombox
Boombox lets you stream multimedia using various protocols and formats: WebRTC, RTMP, RTSP, HLS, and MP4. Let’s consider a scenario when someone sends their stream over RTMP (like from OBS) and broadcasts it to a wider public via HLS:

It can be done with a single call to Boombox:
Boombox.run(input: "rtmp://localhost:5432", output: "path/to/index.m3u8")It will receive the RTMP stream and generate an HLS (.m3u8) playlist. Boombox can be called using CLI too:
boombox -i rtmp://localhost:5432 -o path/to/index.m3u8Boombox also allows you to interact with the stream in the Elixir code. For example, to generate a video and send it to a browser over WebRTC:

The snippet below generates a spinning image video and streams it via WebRTC:
Mix.install([:boombox, :image, :req])
{:ok, image} =
Req.get!("https://avatars.githubusercontent.com/u/25247695?s=200&v=4")
.body
|> Vix.Vips.Image.new_from_buffer()
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"}
)To receive the stream in the browser, you can use our exemplary HTML snippet.
More examples are available here.
Why Boombox?
Explicitness and flexibility have always been top priorities of Membrane. It didn’t come without tradeoffs, in particular, a quite high entry level and steep learning curve. Boombox provides many of the Membrane capabilities with a much simpler API. You don’t need to learn how to create a Membrane pipeline, which plugins to use, and how to connect them. Just do Boombox.run(...) and that’s it. It’s almost like if media streaming was easy…
But it rarely is. As your project grows, you’ll probably need to learn more about media and need more flexibility than just specifying input and output. The good news is that Boombox is just a thin wrapper over Membrane! You can always create a Membrane pipeline using exactly the same components as Boombox and customize it however you will. Moreover, we’re going to make Boombox and Membrane interact better by allowing you to actually plug Boombox into a Membrane pipeline.
But for now, start simple, with Boombox.run 😉
Try it out!
Boombox is early stages and we’re still polishing the sharp corners. But it’s built on solid foundations and ready for early adopters! Please try it out and report any problems via GitHub or Discord.
Happy streaming!













