Interact with raw media using RawData endpoints
masterFor direct media manipulation (e.g., applying AI effects to video or audio), use the RawData endpoint. This allows Boombox to produce or accept AudioPacket and VideoPacket objects.
There are two primary patterns for raw data interaction:
- Reading from Boombox: Define a
RawDataoutput and iterate over the stream using theboombox.read()generator. - Writing to Boombox: Define a
RawDatainput and use theboombox.write(packet)method to feed packets into the stream. This is typically used within awithcontext manager.
# Pattern 1: Reading raw packets from a stream
boombox = Boombox(
input=any_input_endpoint,
output=RawData(video=True, audio=True)
)
for packet in boombox.read():
process_packet(packet)
# Pattern 2: Writing raw packets to a stream
with Boombox(
input=RawData(video=True, audio=True),
output=any_output_endpoint
) as boombox:
for packet in some_packet_generator():
boombox.write(packet)