mat-hek
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 ![]()
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 ![]()
Happy streaming!
Most Liked
chrismccord
Fantastic work! I can’t wait to play with this.
mat-hek
Not yet. Added to the wishlist though
You may also check out this Membrane plugin: GitHub - membraneframework/membrane_abr_transcoder_plugin: ABR (adaptive bitrate) transcoder, that accepts an h.264 video and outputs multiple variants of it with different qualities. · GitHub
mat-hek
Thanks! Specially for you, thumbnails ![]()
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)
Popular in News & Updates
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









