{"record":{"id":"3b2398b53c386f62","repo":"invoke-ai/InvokeAI","slug":"decoded-frame-dimensions-width-x-height-exceed-t","errorCode":null,"errorMessage":"Decoded frame dimensions {width}x{height} exceed the maximum decodable size","messagePattern":"Decoded frame dimensions (.+?)x(.+?) exceed the maximum decodable size","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/util/video_decode_worker.py","lineNumber":74,"sourceCode":"        import os\n        import resource\n\n        pages = int(Path(\"/proc/self/statm\").read_text().split()[0])\n        limit = pages * os.sysconf(\"SC_PAGE_SIZE\") + WORKER_MEMORY_HEADROOM_BYTES\n        _soft, hard = resource.getrlimit(resource.RLIMIT_AS)\n        if hard != resource.RLIM_INFINITY:\n            limit = min(limit, hard)\n        resource.setrlimit(resource.RLIMIT_AS, (limit, hard))\n    except (OSError, ValueError):\n        pass\n\n\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","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/util/video_decode_worker.py#L56-L92","documentation":"_validate_decoded_frame enforces MAX_FRAME_PIXELS on decoded frames and rejects non-positive dimensions. A decoded frame larger than the pixel budget would blow the parent's memory bound, so it is rejected here as a last line of defense after the pre-decode probe check.","triggerScenarios":"A video whose probed dimensions passed but whose actually decoded frame is larger (e.g. rotated video where stored dimensions differ from display dimensions, or a probe that under-reported size).","commonSituations":"Rotated phone videos with rotation metadata (probed WxH swapped versus decoded frame); corrupt metadata in the container; very high-resolution (8K) source videos exceeding the pixel limit.","solutions":["Downscale the video before decoding (e.g. ffmpeg -vf scale=...) to fit within MAX_FRAME_PIXELS","Crop or re-encode the source video to smaller dimensions","Account for rotation metadata by checking the frame after any auto-rotation, not just probe dimensions"],"exampleFix":"// before\nffmpeg -i input.mov -c copy output.mov  # keeps 16K dimensions\n\n// after\nffmpeg -i input.mov -vf \"scale='min(3840,iw)':-2\" output.mov  # cap decoded width","handlingStrategy":"validation","validationCode":"def frame_in_budget(f: np.ndarray) -> bool:\n    h, w = f.shape[:2]\n    return h > 0 and w > 0 and h * w <= MAX_FRAME_PIXELS","typeGuard":"def frame_in_budget(f: np.ndarray) -> bool:\n    h, w = f.shape[:2]\n    return bool(h > 0 and w > 0 and h * w <= MAX_FRAME_PIXELS)","tryCatchPattern":"try:\n    _validate_decoded_frame(frame)\nexcept ValueError as e:\n    if \"exceed the maximum decodable size\" in str(e):\n        frame = cv2.resize(frame, (frame.shape[1] // 2, frame.shape[0] // 2))\n    else:\n        raise","preventionTips":["Pre-decode probe dimensions and reject oversized sources (the worker already does this)","Re-encode large sources with an ffmpeg scale filter before processing","Mind rotation metadata: probed dims may differ from decoded frame dims","Keep MAX_FRAME_PIXELS aligned with your memory budget"],"tags":["video","numpy","resource-limit","validation"],"backgroundTag":"frame-size-limit-exceeded","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}