mat-hek

mat-hek

Membrane Core Team

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!

Showing Posts 1 to 10

chrismccord

chrismccord

Creator of Phoenix

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

mat-hek

mat-hek OP

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)
kip

kip

ex_cldr Core Team

You can just do Image.open() on a binary too (at least for most common image formats).

Great project, can’t wait to give this a spin!

mat-hek

mat-hek OP

Membrane Core Team

Thanks, that’s much better! And thanks again for Image, it’s been a pleasure to use and docs are wonderful :wink:

zachallaun

zachallaun

This is very cool!

I have a locally-running project that’s using MediaMTX to convert some IP camera RTSP streams to WebRTC (WHEP), which I then display in-browser using LiveView JS hooks. It looks like Boombox doesn’t quite replace this yet, but I’m looking forward to the day when I can plug something like this into my application and Phoenix router and have everything done in Elixir-land. :smile:

mat-hek

mat-hek OP

Membrane Core Team

Receiving RTSP and forwarding via WebRTC is already supported:

Boombox.run(input: "rtsp://my.rtsp.stream/", output: {:webrtc, "ws://signaling_url"})

but it’s point-to-point and WHEP is not there yet. But it’s going to change soon :wink:

zachallaun

zachallaun

Yep! I was looking through some issues yesterday and saw that work was being done in membrane_plugin_webrtc and elsewhere :slight_smile:

What I’d eventually love would be something like…

# my_app/application.ex
children = [
  {Boombox, inputs: [cam1: "rtsp://...", cam2: "rtsp://..."], name: MyApp.Boombox}
  # ...
]

# my_app_web/router.ex
boombox_routes "/cams", boombox: MyApp.Boombox

and be able to hit /cams/cam1/whep to get things going :eyes:. This is just be spitballing, though – everything y’all are doing is insanely cool regardless!

mat-hek

mat-hek OP

Membrane Core Team

This is very helpful, please keep doing it :smiley: I’d love to hear about more potential use cases that people have

rhcarvalho

rhcarvalho

Fantastic! Does Boombox support transcoding RTMP input to include multiple resolutions in the HLS output? Perhaps offloading the transcoding job to a different server/service?

— All posts loaded —

Where Next? Top

Trending in News & Updates Top

sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
bartblast
I’ll be using this thread to share Hologram patch release announcements. Minor releases will continue to get dedicated threads with blog ...
New
sorenone
This release unifies configuration for queues, repos, and services, swaps opaque timing integers for readable durations, and backports pe...
New
pcharbon
:heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::hea...
New
jvoegele
Bond brings Design by Contract to Elixir: preconditions, postconditions and invariants as executable specifications, checked at runtime a...
New
webofbits
Aludel 0.7.0 is released :tada: Since 0.5.0, Aludel has grown into a much more complete LLM evaluation toolkit for Elixir and Phoenix app...
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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews