{"record":{"id":"d6fa4cb19b8da7df","repo":"invoke-ai/InvokeAI","slug":"cannot-determine-frame-count-for-self-video-video","errorCode":null,"errorMessage":"Cannot determine frame count for {self.video.video_name}: probe returned duration={duration}, fps={source_fps}.","messagePattern":"Cannot determine frame count for (.+?): probe returned duration=(.+?), fps=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/video_frame_extract_range.py","lineNumber":150,"sourceCode":"        description=(\"Last frame to keep, inclusive. -1 = last frame. Negative indices count from the end.\"),\n        ui_component=UIComponent.VideoFrameIndex,\n    )\n    fps: int = InputField(\n        default=0,\n        ge=0,\n        le=120,\n        description=\"Output frame rate. 0 = match the source video's frame rate \"\n        \"(falls back to 16 fps if the source rate can't be probed).\",\n    )\n\n    def invoke(self, context: InvocationContext) -> ExtractVideoRangeOutput:\n        video_path = context.videos.get_path(self.video.video_name)\n        width, height, duration, source_fps = probe_video(video_path)\n\n        n_frames = decoder_frame_count(video_path)\n        if n_frames is None:\n            if not source_fps or duration <= 0:\n                raise ValueError(\n                    f\"Cannot determine frame count for {self.video.video_name}: \"\n                    f\"probe returned duration={duration}, fps={source_fps}.\"\n                )\n            n_frames = int(round(duration * source_fps))\n        if n_frames <= 0:\n            raise ValueError(f\"Video {self.video.video_name} has no decodable frames (probed {n_frames}).\")\n\n        start = self._resolve_index(self.start_frame, n_frames, \"start_frame\")\n        end = self._resolve_index(self.end_frame, n_frames, \"end_frame\")\n        if end < start:\n            raise ValueError(\n                f\"end_frame ({self.end_frame} → {end}) must be >= start_frame \"\n                f\"({self.start_frame} → {start}) after resolving negative indices.\"\n            )\n\n        # Derive the output frame rate from the source video when ``fps`` is 0\n        # (the default), so a trimmed clip plays back at the same speed as its\n        # source. Fall back to 16 fps (the Wan video default) when the source","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/video_frame_extract_range.py#L132-L168","documentation":"Thrown in VideoFrameExtractRange.invoke when the total frame count is needed but cannot be determined: decoder_frame_count returned None and the probe fallback has invalid fps or non-positive duration. A range extraction requires knowing how many frames exist to resolve start/end indices.","triggerScenarios":"invoke(): decoder_frame_count(video_path) is None and probe_video returns source_fps falsy or duration <= 0.","commonSituations":"Corrupt containers without duration metadata; fragmented/unfinalized recordings; streams without fps info.","solutions":["Re-encode to a standard MP4/H.264 so both duration and fps are readable","Use ffprobe to verify the file reports valid duration and fps","Provide a complete, finalized source file (finalize camera recordings)","Extract frames by time range from a working source instead"],"exampleFix":"// before\n# fragmented.mp4 has no duration metadata\nVideoFrameExtractRange(video=frag, start_frame=0, end_frame=-1)\n// after\nffmpeg -i fragmented.mp4 -c copy repaired.mp4\nVideoFrameExtractRange(video=repaired, start_frame=0, end_frame=-1)","handlingStrategy":"fallback","validationCode":"probe = probe_video(path)\nif decoder_frame_count(path) is None and (not probe.fps or probe.duration <= 0):\n    raise ValueError(f'{path}: frame count undeterminable; re-encode first')","typeGuard":"def has_known_length(probe) -> bool:\n    return bool(probe.fps) and probe.duration > 0","tryCatchPattern":"try:\n    out = range_extract.invoke(context)\nexcept ValueError as e:\n    if 'Cannot determine frame count' in str(e):\n        run_ffmpeg(['-i', path, '-c', 'copy', repaired_path])\n        out = rebuild(video=repaired_path).invoke(context)\n    else:\n        raise","preventionTips":["Verify duration and fps via ffprobe at ingest","Avoid unfinalized/fragmented recordings as inputs","Keep decoder_frame_count as primary source of truth"],"tags":["video","probe","frame-count"],"backgroundTag":"unresolvable-frame-index","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}