invoke-ai/InvokeAI · error · ValueError
Cannot determine frame count for {self.video.video_name}: pr
Error message
Cannot determine frame count for {self.video.video_name}: probe returned duration={duration}, fps={source_fps}. What it means
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.
Source
Thrown at invokeai/app/invocations/video_frame_extract_range.py:150
description=("Last frame to keep, inclusive. -1 = last frame. Negative indices count from the end."),
ui_component=UIComponent.VideoFrameIndex,
)
fps: int = InputField(
default=0,
ge=0,
le=120,
description="Output frame rate. 0 = match the source video's frame rate "
"(falls back to 16 fps if the source rate can't be probed).",
)
def invoke(self, context: InvocationContext) -> ExtractVideoRangeOutput:
video_path = context.videos.get_path(self.video.video_name)
width, height, duration, source_fps = probe_video(video_path)
n_frames = decoder_frame_count(video_path)
if n_frames is None:
if not source_fps or duration <= 0:
raise ValueError(
f"Cannot determine frame count for {self.video.video_name}: "
f"probe returned duration={duration}, fps={source_fps}."
)
n_frames = int(round(duration * source_fps))
if n_frames <= 0:
raise ValueError(f"Video {self.video.video_name} has no decodable frames (probed {n_frames}).")
start = self._resolve_index(self.start_frame, n_frames, "start_frame")
end = self._resolve_index(self.end_frame, n_frames, "end_frame")
if end < start:
raise ValueError(
f"end_frame ({self.end_frame} → {end}) must be >= start_frame "
f"({self.start_frame} → {start}) after resolving negative indices."
)
# Derive the output frame rate from the source video when ``fps`` is 0
# (the default), so a trimmed clip plays back at the same speed as its
# source. Fall back to 16 fps (the Wan video default) when the sourceView on GitHub (pinned to 0b6a024f2f)
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
Example fix
// before # fragmented.mp4 has no duration metadata VideoFrameExtractRange(video=frag, start_frame=0, end_frame=-1) // after ffmpeg -i fragmented.mp4 -c copy repaired.mp4 VideoFrameExtractRange(video=repaired, start_frame=0, end_frame=-1)
Defensive patterns
Strategy: fallback
Validate before calling
probe = probe_video(path)
if decoder_frame_count(path) is None and (not probe.fps or probe.duration <= 0):
raise ValueError(f'{path}: frame count undeterminable; re-encode first') Type guard
def has_known_length(probe) -> bool:
return bool(probe.fps) and probe.duration > 0 Try / catch
try:
out = range_extract.invoke(context)
except ValueError as e:
if 'Cannot determine frame count' in str(e):
run_ffmpeg(['-i', path, '-c', 'copy', repaired_path])
out = rebuild(video=repaired_path).invoke(context)
else:
raise Prevention
- Verify duration and fps via ffprobe at ingest
- Avoid unfinalized/fragmented recordings as inputs
- Keep decoder_frame_count as primary source of truth
When it happens
Trigger: invoke(): decoder_frame_count(video_path) is None and probe_video returns source_fps falsy or duration <= 0.
Common situations: Corrupt containers without duration metadata; fragmented/unfinalized recordings; streams without fps info.
Related errors
- Clip {i} has {n_frames} frames but the requested transitions
- Cannot resolve negative frame index for video {self.video.vi
- Video {self.video.video_name} has no decodable frames (probe
- Video {self.video.video_name} has no decodable frames (probe
- Wan VAE decode produced {num_frames} frames; expected {t_pix
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/d6fa4cb19b8da7df.
Report an issue: GitHub.