Comfy-Org/ComfyUI · error · ValueError
Video duration must be at most {max_duration}s, got {duratio
Error message
Video duration must be at most {max_duration}s, got {duration}s What it means
ValueError from validate_video_duration when the video exceeds the API's maximum duration. Duration is read via video.get_duration() and compared against max_duration + 0.0001s epsilon; exceeding it raises before upload, since providers bill by length and cap generations (e.g., 5s or 10s for most video APIs).
Source
Thrown at comfy_api_nodes/util/validation_utils.py:134
raise ValueError(f"Video height must be at most {max_height}px, got {height}px")
def validate_video_duration(
video: Input.Video,
min_duration: float | None = None,
max_duration: float | None = None,
):
try:
duration = video.get_duration()
except Exception as e:
logging.error("Error getting duration of video: %s", e)
return
epsilon = 0.0001
if min_duration is not None and min_duration - epsilon > duration:
raise ValueError(f"Video duration must be at least {min_duration}s, got {duration}s")
if max_duration is not None and duration > max_duration + epsilon:
raise ValueError(f"Video duration must be at most {max_duration}s, got {duration}s")
def validate_video_frame_count(
video: Input.Video,
min_frame_count: int | None = None,
max_frame_count: int | None = None,
):
try:
frame_count = video.get_frame_count()
except Exception as e:
logging.error("Error getting frame count of video: %s", e)
return
if min_frame_count is not None and min_frame_count > frame_count:
raise ValueError(f"Video frame count must be at least {min_frame_count}, got {frame_count}")
if max_frame_count is not None and frame_count > max_frame_count:
raise ValueError(f"Video frame count must be at most {max_frame_count}, got {frame_count}")
View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Trim the video to max_duration or shorter (ffmpeg -ss 0 -t 10 -i in.mp4 -c copy out.mp4).
- Split long footage into segments and run the node per segment.
- Verify the effective duration with ffprobe after export.
Example fix
# shell: keep only the first 10 seconds # ffmpeg -ss 0 -t 10 -i input.mp4 -c copy output.mp4
Defensive patterns
Strategy: validation
Validate before calling
duration = video.get_duration()
if duration is not None and duration > MAX_DUR:
raise ValueError(f"trim first: {duration:.2f}s > {MAX_DUR}s") Prevention
- Trim long footage to the provider's max duration before loading
- Split long videos into per-segment runs
When it happens
Trigger: validate_video_duration(video, max_duration=N) with duration > N + epsilon — e.g., a 12-second clip passed to a node accepting at most 10 seconds.
Common situations: Full clips fed where only a segment is allowed; forgetting to trim before an image-to-video node; providers tightening max duration between versions.
Related errors
- Reference video {i} is too short: {dur:.1f}s. Minimum durati
- Total reference video duration is {total_video_duration:.1f}
- Video duration must be at least {min_duration}s, got {durati
- Failed to slice video:\nSource duration: {video.get_duration
- ar_video sampler requires 5-D video latents [B,C,T,H,W], got
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/2a6e5c9f56258d84.
Report an issue: GitHub.