sgl-project/sglang · error · RuntimeError

generated MiniMax H3 MP4 has invalid size {width}x{height}

Error message

generated MiniMax H3 MP4 has invalid size {width}x{height}

What it means

The video stream's width/height (defaulting to 0 when absent) must both be positive. A 0x0 or negative reported size means the stream metadata is missing dimensions or the file is corrupt, so the adapter raises RuntimeError.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/video_adapter.py:429

        if isinstance(stream, dict) and stream.get("codec_type") == "video"
    ]
    audio_streams = [
        stream
        for stream in streams
        if isinstance(stream, dict) and stream.get("codec_type") == "audio"
    ]
    if len(streams) != 2 or len(video_streams) != 1 or len(audio_streams) != 1:
        raise RuntimeError(
            "generated MiniMax H3 MP4 must contain exactly one video stream and "
            f"one audio stream, got {len(video_streams)} video, "
            f"{len(audio_streams)} audio, and {len(streams)} total streams"
        )
    video_stream = video_streams[0]
    audio_stream = audio_streams[0]
    width = int(video_stream.get("width") or 0)
    height = int(video_stream.get("height") or 0)
    if width <= 0 or height <= 0:
        raise RuntimeError(
            f"generated MiniMax H3 MP4 has invalid size {width}x{height}"
        )
    if expected_size is not None and (width, height) != expected_size:
        raise RuntimeError(
            "generated MiniMax H3 MP4 size does not match the resolved request: "
            f"expected {expected_size[0]}x{expected_size[1]}, got {width}x{height}"
        )
    rate_raw = str(video_stream.get("avg_frame_rate") or "")
    try:
        if "/" in rate_raw:
            numerator, denominator = rate_raw.split("/", 1)
            fps = float(numerator) / float(denominator)
        else:
            fps = float(rate_raw)
    except (TypeError, ValueError, ZeroDivisionError):
        fps = 0.0
    if abs(fps - float(MINIMAX_H3_SUPPORTED_FPS)) > 1e-6:
        raise RuntimeError(

View on GitHub (pinned to 0132848349)

Solutions

  1. Probe the file manually: `ffprobe -select_streams v -show_entries stream=width,height <file>`
  2. Check disk space and generation logs for incomplete writes
  3. Retry the request; corrupt outputs are usually transient
  4. If persistent, investigate the decode/mux stage writing dimension-less streams
Defensive patterns

Strategy: validation

Validate before calling

w,h = video_stream.get("width",0), video_stream.get("height",0)
assert w>0 and h>0

Type guard

def has_positive_dims(vs: dict) -> bool:
    return (vs.get("width") or 0) > 0 and (vs.get("height") or 0) > 0

Prevention

When it happens

Trigger: ffprobe reports no width/height keys on the video stream (defaults to 0), producing width<=0 or height<=0.

Common situations: Truncated or header-only MP4 files; unusual codecs where ffprobe cannot extract dimensions; partially-written outputs.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/0e1e47b64e40255b. Report an issue: GitHub.