{"record":{"id":"4df149a07e2f90fe","repo":"invoke-ai/InvokeAI","slug":"unable-to-validate-video-dimensions-for-video-pat","errorCode":null,"errorMessage":"Unable to validate video dimensions for {video_path}","messagePattern":"Unable to validate video dimensions for (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/util/video_decode_worker.py","lineNumber":86,"sourceCode":"\ndef _validate_decoded_frame(frame: np.ndarray) -> None:\n    if frame.ndim != 3 or frame.shape[2] != 3:\n        raise ValueError(f\"Decoded frame must be RGB; got shape {frame.shape}\")\n    height, width = frame.shape[:2]\n    if height <= 0 or width <= 0 or height * width > MAX_FRAME_PIXELS:\n        raise ValueError(f\"Decoded frame dimensions {width}x{height} exceed the maximum decodable size\")\n\n\ndef _assert_decodable_dims(video_path: Path) -> None:\n    \"\"\"Refuses to decode frames from a video whose reported dimensions exceed the bound.\n\n    If the dimensions cannot be probed, decoding is refused because the parent's frame\n    record bound and PIL checks run only after the decoder has allocated the frame.\n    \"\"\"\n    try:\n        width, height, _duration, _fps = _probe(video_path)[:4]\n    except Exception as error:\n        raise ValueError(f\"Unable to validate video dimensions for {video_path}\") from error\n    if width <= 0 or height <= 0:\n        raise ValueError(f\"Video reports invalid dimensions {width}x{height}\")\n    if width * height > MAX_FRAME_PIXELS:\n        raise ValueError(f\"Video dimensions {width}x{height} exceed the maximum decodable size\")\n\n\ndef _extract_frame(video_path: Path, frame_index: int) -> Optional[Image.Image]:\n    \"\"\"Extracts a single frame from a video file as a PIL Image. Returns None on failure.\n\n    Tries imageio's FFMPEG plugin first since it's the same encoder we use for output,\n    then falls back to cv2 — uploaded videos with unusual codecs may need that path.\n    \"\"\"\n    try:\n        # iio.imread with index=N seeks to that frame directly. Returns RGB HxWxC uint8.\n        frame = iio.imread(video_path, plugin=\"FFMPEG\", index=frame_index)\n        _validate_decoded_frame(frame)\n        return Image.fromarray(frame)\n    except Exception:","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/util/video_decode_worker.py#L68-L104","documentation":"_assert_decodable_dims probes a video's dimensions before decoding so oversized frames are rejected before the decoder allocates memory. If the probe itself throws for any reason, the function refuses to decode rather than risk an unbounded frame allocation, wrapping the underlying error in this ValueError (original chained via __cause__).","triggerScenarios":"cv2 failing to read metadata from a corrupt/truncated file, an unsupported codec, a partially downloaded file, or any exception inside _probe other than the is-opened failure (which raises FileNotFoundError instead).","commonSituations":"Broken or incomplete video files; exotic codecs OpenCV's FFmpeg build can't probe; permission or I/O errors mid-read; zero-byte placeholder files.","solutions":["Inspect the chained cause (err.__cause__) to find the actual probe failure","Repair/re-encode the file (e.g. ffmpeg -i bad.mp4 -c copy fixed.mp4) or re-download it","Check file permissions and that the path points to a complete video file","Verify the codec is supported by the installed OpenCV/FFmpeg build"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import subprocess\ndef probe_ok(path) -> bool:\n    r = subprocess.run([\"ffprobe\", \"-v\", \"error\", str(path)], capture_output=True)\n    return r.returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    _assert_decodable_dims(video_path)\nexcept ValueError as e:\n    logger.error(\"dimension probe failed for %s: cause=%r\", video_path, e.__cause__)\n    # mark file undecodable / skip","preventionTips":["Inspect e.__cause__ for the real probe failure","Pre-validate files with ffprobe before submitting to the worker","Repair truncated downloads via re-encode (ffmpeg -c copy) or re-download","Check codec support of the installed OpenCV/FFmpeg build"],"tags":["video","opencv","validation","corrupt-file"],"backgroundTag":"video-probe-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}