Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Python

Data-processing pipelines and ML input/output streams call Mediaway via ctypes/cffi over the mediaway-ffi C ABI. Status: ✅ verified.

Install

pip install mediaway
from mediaway import Codec, Muxer, Packet, Rational, VideoStreamInfo

with Muxer() as muxer:
    video_id = muxer.add_video_track(VideoStreamInfo(
        codec=Codec.H264, width=1920, height=1080,
        frame_rate=Rational(1, 30),
    ))
    with muxer.begin() as live:  # Open -> Live (handle moves; registration impossible)
        live.push_packet(Packet(
            stream_index=video_id, pts=Rational(0, 30),
            payload=b"\x00\x00\x00\x01", key=True,
        ))
        live.flush()
        chunks = []
        while True:
            chunk = live.poll_bytes()  # caller owns byte I/O (sans-io)
            if chunk is None:
                break
            chunks.append(chunk)

mp4 = b"".join(chunks)

Examples live in bindings/python/examples/:

CapabilityExample files
Containercontainer/mux_roundtrip.py
Devicedevice/camera_record.py · capture_microphone.py · capture_screen.py
Pipelinepipeline/encode_audio.py · encode_to_mp4.py · screen_record.py

Build and run instructions: bindings/python/README.md.