invoke-ai/InvokeAI · error · FileNotFoundError

Video at {video_path} reports invalid dimensions {width}x{he

Error message

Video at {video_path} reports invalid dimensions {width}x{height}

What it means

probe_video_with_codec validates probed dimensions: width/height must be positive and width*height must not exceed MAX_VIDEO_FRAME_PIXELS. If ffprobe returns non-positive or absurdly large dimensions, the video is rejected as FileNotFoundError to prevent downstream OOM or division errors.

Source

Thrown at invokeai/app/util/video_thumbnails.py:431

    they come from the uploaded container, and the upload path persists them and sizes
    thumbnail decoding by them. A non-finite or non-positive fps is coerced to None
    (unknown) rather than rejected, matching the decoder's own unknown-fps behavior.
    """
    result = _run_worker(["probe", str(video_path)], timeout)
    if result is None:
        raise FileNotFoundError(f"Unable to open video at {video_path}")
    try:
        width = int(result["width"])
        height = int(result["height"])
        duration = float(result["duration"])
        fps_raw = result.get("fps")
        fps: Optional[float] = float(fps_raw) if fps_raw else None
        codec_raw = result.get("codec")
        codec = str(codec_raw).lower() if codec_raw else None
    except (KeyError, TypeError, ValueError, OverflowError) as e:
        raise FileNotFoundError(f"Unable to open video at {video_path}") from e
    if width <= 0 or height <= 0 or width * height > MAX_VIDEO_FRAME_PIXELS:
        raise FileNotFoundError(f"Video at {video_path} reports invalid dimensions {width}x{height}")
    if not math.isfinite(duration) or duration < 0:
        raise FileNotFoundError(f"Video at {video_path} reports an invalid duration {duration}")
    if fps is not None and (not math.isfinite(fps) or fps <= 0):
        fps = None
    return width, height, duration, fps, codec


def probe_video(
    video_path: Path, timeout: float = VIDEO_DECODE_TIMEOUT_SECONDS
) -> tuple[int, int, float, Optional[float]]:
    """Returns validated video metadata without the codec."""
    width, height, duration, fps, _codec = probe_video_with_codec(video_path, timeout)
    return width, height, duration, fps


def decoder_frame_count(video_path: Path, timeout: float = VIDEO_DECODE_TIMEOUT_SECONDS) -> Optional[int]:
    """Returns the exact decoded frame count, or None if it cannot be determined in time.

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Inspect the file with ffprobe -show_streams and confirm the video stream's width/height.
  2. Remove or reject files exceeding the pixel cap; ask users to downscale (e.g. 4K max).
  3. Remux/re-encode with ffmpeg to fix broken stream headers.
  4. If legitimate huge videos are required, raise MAX_VIDEO_FRAME_PIXELS consciously with memory budgeting.

Example fix

# before
w, h, dur, fps, codec = probe_video(path)
# after
w, h, dur, fps, codec = probe_video(path)
if w * h > 8_294_400:  # 4K guard of your own
    raise ValueError(f"{path} exceeds supported resolution {w}x{h}")
Defensive patterns

Strategy: validation

Validate before calling

def check_dimensions(path, max_pixels=8_294_400):
    import subprocess, json
    out = subprocess.run(["ffprobe","-v","error","-select_streams","v:0","-print_format","json","-show_streams",path], capture_output=True)
    streams = json.loads(out.stdout or "{}").get("streams", [])
    if not streams:
        raise ValueError(f"{path}: no video stream")
    w, h = streams[0].get("width", 0), streams[0].get("height", 0)
    if w <= 0 or h <= 0:
        raise ValueError(f"{path}: invalid dimensions {w}x{h}")
    if w * h > max_pixels:
        raise ValueError(f"{path}: {w}x{h} exceeds pixel cap")

Type guard

def has_valid_dimensions(probe: dict) -> bool:
    w, h = probe.get("width", 0), probe.get("height", 0)
    return w > 0 and h > 0 and w * h <= 8_294_400

Try / catch

try:
    w, h, dur, fps, codec = probe_video(path)
except FileNotFoundError as e:
    raise ValueError("video dimensions are invalid or oversized; transcode before use") from e

Prevention

When it happens

Trigger: Calling probe_video on a video whose ffprobe stream reports width or height of 0 or negative, or a frame size whose pixel count exceeds MAX_VIDEO_FRAME_PIXELS (e.g. 64K resolution or fabricated metadata).

Common situations: Corrupted stream metadata (streams without a video track), exotic/oversized resolutions users uploaded, test fixtures with fake ffprobe output, or probing audio-only files where width/height default to 0.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/8a948f46babb1dbc. Report an issue: GitHub.