invoke-ai/InvokeAI · error · ValueError
Video reports invalid dimensions {width}x{height}
Error message
Video reports invalid dimensions {width}x{height} What it means
After a successful probe, _assert_decodable_dims checks that width and height are both positive. A video reporting 0 or negative dimensions has unusable metadata, so decoding is refused with this ValueError before any frame allocation.
Source
Thrown at invokeai/app/util/video_decode_worker.py:88
if frame.ndim != 3 or frame.shape[2] != 3:
raise ValueError(f"Decoded frame must be RGB; got shape {frame.shape}")
height, width = frame.shape[:2]
if height <= 0 or width <= 0 or height * width > MAX_FRAME_PIXELS:
raise ValueError(f"Decoded frame dimensions {width}x{height} exceed the maximum decodable size")
def _assert_decodable_dims(video_path: Path) -> None:
"""Refuses to decode frames from a video whose reported dimensions exceed the bound.
If the dimensions cannot be probed, decoding is refused because the parent's frame
record bound and PIL checks run only after the decoder has allocated the frame.
"""
try:
width, height, _duration, _fps = _probe(video_path)[:4]
except Exception as error:
raise ValueError(f"Unable to validate video dimensions for {video_path}") from error
if width <= 0 or height <= 0:
raise ValueError(f"Video reports invalid dimensions {width}x{height}")
if width * height > MAX_FRAME_PIXELS:
raise ValueError(f"Video dimensions {width}x{height} exceed the maximum decodable size")
def _extract_frame(video_path: Path, frame_index: int) -> Optional[Image.Image]:
"""Extracts a single frame from a video file as a PIL Image. Returns None on failure.
Tries imageio's FFMPEG plugin first since it's the same encoder we use for output,
then falls back to cv2 — uploaded videos with unusual codecs may need that path.
"""
try:
# iio.imread with index=N seeks to that frame directly. Returns RGB HxWxC uint8.
frame = iio.imread(video_path, plugin="FFMPEG", index=frame_index)
_validate_decoded_frame(frame)
return Image.fromarray(frame)
except Exception:
pass
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Verify the file actually contains a video stream (ffprobe <file>)
- Re-encode or re-obtain the source video
- Add an explicit ffprobe-based pre-check upstream to reject invalid files before calling the worker
Defensive patterns
Strategy: validation
Validate before calling
import cv2
def dims_valid(path) -> bool:
cap = cv2.VideoCapture(str(path))
ok = cap.isOpened()
if ok:
w, h = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
ok = w > 0 and h > 0
cap.release()
return ok Type guard
def dims_valid(w: int, h: int) -> bool:
return w > 0 and h > 0 Try / catch
try:
_assert_decodable_dims(video_path)
except ValueError as e:
if "invalid dimensions" in str(e):
logger.error("bad metadata for %s", video_path) # quarantine file
else:
raise Prevention
- Reject zero-byte/header-only files early (check file size > 0)
- Confirm a video stream exists with ffprobe
- Re-encode files written by crashed encoders
- Quarantine files that fail dimension checks instead of retrying
When it happens
Trigger: A probe returning CAP_PROP_FRAME_WIDTH/HEIGHT of 0, typical of files whose container opens but whose stream metadata is missing, zero-sized, or corrupt.
Common situations: Zero-byte or header-only video files; streams without a video track (audio-only files); corrupt metadata written by a crashed encoder.
Related errors
- Unable to validate video dimensions for {video_path}
- Video at {video_path} reports an invalid duration {duration}
- Video metadata not found
- video_concat requires at least two input videos.
- All inputs must share the same dimensions. Got: {sorted(widt
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/867d99e01436a4b2.
Report an issue: GitHub.