Skip to content

vllm_omni.diffusion.utils.media_utils

Video/audio muxing utilities using PyAV (no ffmpeg binary dependency).

FragmentedMP4Muxer

Incrementally mux video frames into one fragmented MP4 byte stream.

close

close() -> bytes

Flush delayed encoder packets, close the container, and return final bytes.

mux_video_frames

mux_video_frames(video_frames: ndarray) -> bytes

Mux a batch of uint8 RGB frames and return newly written MP4 bytes.

finalize_streaming_video_bytes

finalize_streaming_video_bytes(
    video_bytes: bytes,
    *,
    input_format: str,
    fps: float = 25.0,
    video_codec_options: dict[str, str] | None = None,
) -> bytes

Convert streamed video bytes into a progressive MP4 for local playback.

mux_video_audio_bytes

mux_video_audio_bytes(
    video_frames: ndarray,
    audio_waveform: ndarray | None = None,
    *,
    fps: float = 25.0,
    audio_sample_rate: int = 44100,
    video_codec: str = "h264",
    audio_codec: str = "aac",
    crf: str = "18",
    video_codec_options: dict[str, str] | None = None,
) -> bytes

Mux video frames and optional audio waveform into MP4 bytes.

Parameters:

Name Type Description Default
video_frames ndarray

uint8 array of shape (T, H, W, 3) (RGB).

required
audio_waveform ndarray | None

float32 array – mono (N,) or (N, C) / (C, N).

None
fps float

Video frame rate.

25.0
audio_sample_rate int

Audio sample rate in Hz.

44100
video_codec str

Video codec name.

'h264'
audio_codec str

Audio codec name.

'aac'
crf str

Constant rate factor for the video encoder.

'18'

Returns:

Type Description
bytes

Raw MP4 bytes ready to be written to disk or streamed.