Boombox

This package is a Python API of Boombox - a high-level tool for audio & video streaming tool based on the Membrane Framework. Boombox allows for transforming one stream format into another using a simple declarative interface. It also allows for interacting with the media directly in the code, for example modifying video streams with AI.

To transform a stream started simply create a Boombox object with desired input and output, which are defined through endpoints. For example:

from boombox import Boombox, MP4, RTMP

boombox = Boombox(
    input=RTMP("rtmp://my.stream.source:2137/app/key"),
    output=MP4("path/to/target.mp4")
)
boombox.wait()

When this code is run, Boombox will become a RTMP server, wait for clients to connect and save the acquired stream to a .mp4 file at the provided location.

To interact with raw media in the code, the RawData endpoint can be used. Boombox will then produce or accept packets of raw media data. These packets are AudioPacket and VideoPacket objects.

You can define a RawData output and read the stream through a generator:

boombox = Boombox(
    input=any_input_endpoint
    output=RawData(video=True, audio=True)
)

for packet in boombox.read():
    process_packet(packet)

Or define a RawData output and write packets to Boombox with Boombox.write():

with Boombox(
    input=RawData(video=True, audio=True)
    output=any_output_endpoint
) as boombox:
    for packet in some_packet_generator():
        boombox.write(packet)

These operations can also be combined - read from boombox, process the stream and write it to another boombox. A demo showing an example of this can be found here. It utilizes AI tools to make a WebRTC stream “anonymous” - it uses multiple AI models to blur the users face, distorts their voice and transcribes their speech. More details inside the demo.