{"record":{"id":"cc30dcabd4f3ce0b","repo":"invoke-ai/InvokeAI","slug":"unable-to-open-video-at-video-path","errorCode":null,"errorMessage":"Unable to open video at {video_path}","messagePattern":"Unable to open video at (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"invokeai/app/util/video_decode_worker.py","lineNumber":156,"sourceCode":"        duration = float(meta.get(\"duration\", 0.0)) if meta.get(\"duration\") is not None else 0.0\n        size = meta.get(\"size\")\n        if size is None:\n            # Fall through to cv2 — imageio didn't give us dimensions.\n            raise ValueError(\"imageio probe missing 'size'\")\n        width, height = int(size[0]), int(size[1])\n        fps: Optional[float] = float(fps_raw) if fps_raw and fps_raw > 0 else None\n        codec_raw = meta.get(\"codec\")\n        codec = str(codec_raw).lower() if codec_raw else None\n        return width, height, duration, fps, codec\n    except Exception:\n        pass\n\n    import cv2\n\n    capture = cv2.VideoCapture(str(video_path))\n    if not capture.isOpened():\n        capture.release()\n        raise FileNotFoundError(f\"Unable to open video at {video_path}\")\n    try:\n        width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))\n        height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))\n        frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))\n        fps_raw = capture.get(cv2.CAP_PROP_FPS)\n        fps_v2: Optional[float] = float(fps_raw) if fps_raw and fps_raw > 0 else None\n        duration = (frame_count / fps_v2) if (fps_v2 and frame_count > 0) else 0.0\n        fourcc = int(capture.get(cv2.CAP_PROP_FOURCC))\n        codec = \"\".join(chr((fourcc >> (8 * index)) & 0xFF) for index in range(4)).strip().lower() or None\n    finally:\n        capture.release()\n    return width, height, duration, fps_v2, codec\n\n\ndef _count(video_path: Path) -> Optional[int]:\n    \"\"\"Return the exact decoded frame count, or None if neither backend can determine it.\n\n    Tries imageio's improps first (works for a handful of codecs that expose nframes in","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/util/video_decode_worker.py#L138-L174","documentation":"_probe opens the video with cv2.VideoCapture to read metadata. If the capture cannot be opened, it releases the handle and raises FileNotFoundError naming the path. Note it is a FileNotFoundError even when the file exists but is unreadable as video by OpenCV.","triggerScenarios":"Calling _probe (directly or via _assert_decodable_dims/main) on a nonexistent path, a path without read permission, an unsupported/corrupt container, or a codec the bundled OpenCV FFmpeg can't demux.","commonSituations":"Wrong path or typo; file deleted between listing and probing; proprietary codecs (e.g. some HEVC/ProRes variants) missing from the FFmpeg build; OpenCV built without FFmpeg video I/O support.","solutions":["Check os.path.exists() and permissions on the path first","Run ffprobe <path> to confirm OpenCV/FFmpeg can read the container and codec","Reinstall/rebuild opencv-python (pip install --force-reinstall opencv-python) if video I/O backends are missing","Re-encode with ffmpeg to a standard codec (h264 mp4)"],"exampleFix":"// before\n_probe(Path(\"missing.mp4\"))\n\n// after\np = Path(\"missing.mp4\")\nif not p.exists() or not p.is_file():\n    raise FileNotFoundError(f\"Video file not found: {p}\")\n_probe(p)","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\ndef openable(path) -> bool:\n    p = Path(path)\n    return p.exists() and p.is_file() and p.stat().st_size > 0 and os.access(p, os.R_OK)","typeGuard":null,"tryCatchPattern":"try:\n    _probe(video_path)\nexcept FileNotFoundError as e:\n    logger.error(\"cannot open video: %s\", e)\n    # skip / re-encode / surface user error","preventionTips":["Check path existence and permissions before calling the worker","Verify decodability with ffprobe; re-encode exotic codecs to h264 mp4","Ensure opencv-python (with FFmpeg) is installed, not a backend-less build","Watch for files removed between discovery and probing (TOCTOU)"],"tags":["opencv","video","filenotfound","ffmpeg"],"backgroundTag":"cannot-open-video-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}