sgl-project/sglang · error · ValueError

Unsupported video input type: {type(video_file)}

Error message

Unsupported video input type: {type(video_file)}

What it means

Raised by the video-bytes loader when the normalized video input is neither bytes nor a filesystem path string. The loader can only return raw bytes for str/bytes/VideoData.url inputs; anything else (e.g. a tensor, list, None, dict) falls through to this ValueError.

Source

Thrown at python/sglang/srt/utils/common.py:1957

            return video_file
        else:
            return pybase64.b64decode(video_file, validate=True)
    else:
        return None


def get_video_bytes(video_file: Union[str, bytes, VideoData]) -> bytes:
    """Normalize a video input and return its encoded bytes."""
    if isinstance(video_file, VideoData):
        video_file = video_file.url

    source = _normalize_video_input(video_file)
    if isinstance(source, bytes):
        return source
    if isinstance(source, str):
        with open(source, "rb") as f:
            return f.read()
    raise ValueError(f"Unsupported video input type: {type(video_file)}")


def load_video(video_file: Union[str, bytes, VideoData], use_gpu: bool = True):
    if isinstance(video_file, VideoData):
        # preprocess_kwargs is consumed by the multimodal processor, not here.
        video_file = video_file.url

    if isinstance(video_file, (list, tuple, torch.Tensor, np.ndarray)):
        return video_file

    source = _normalize_video_input(video_file)
    if source is None:
        raise ValueError(f"Unsupported video input type: {type(video_file)}")

    device = "cuda" if use_gpu else "cpu"
    try:
        return VideoDecoderWrapper(source, device=device)
    except (ImportError, MemoryError):

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass a local file path string or raw bytes for the video
  2. If you have a VideoData object, ensure its url field is set to a path/URL that _normalize_video_input accepts
  3. Pre-decoded frame tensors/lists should go through load_video (which accepts them), not the bytes loader

Example fix

// before
video_bytes = load_video_bytes(video_file)  # video_file is a list[np.ndarray]
// after
video_bytes = load_video_bytes(str(video_path))  # or pass bytes
Defensive patterns

Strategy: type-guard

Validate before calling

from pathlib import Path
ok = isinstance(v, (str, bytes)) or (hasattr(v, "url") and isinstance(v.url, (str, bytes)))

Type guard

def is_loadable_video_bytes(v) -> bool:
    return isinstance(v, (str, bytes)) or (getattr(v, "url", None) is not None and isinstance(v.url, (str, bytes)))

Prevention

When it happens

Trigger: Calling load_video_bytes (or an API that routes through it) with a video payload that is not a path string, raw bytes, or a VideoData whose .url normalizes to one of those — e.g. passing a pre-decoded tensor/list of frames or None.

Common situations: Multimodal request payloads where the client sends frames/tensors instead of a URL/path, or a VideoData without a url; version changes that changed accepted video input types.

Related errors


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