{"record":{"id":"2a6e5c9f56258d84","repo":"Comfy-Org/ComfyUI","slug":"video-duration-must-be-at-most-max-duration-s-go","errorCode":null,"errorMessage":"Video duration must be at most {max_duration}s, got {duration}s","messagePattern":"Video duration must be at most (.+?)s, got (.+?)s","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/validation_utils.py","lineNumber":134,"sourceCode":"        raise ValueError(f\"Video height must be at most {max_height}px, got {height}px\")\n\n\ndef validate_video_duration(\n    video: Input.Video,\n    min_duration: float | None = None,\n    max_duration: float | None = None,\n):\n    try:\n        duration = video.get_duration()\n    except Exception as e:\n        logging.error(\"Error getting duration of video: %s\", e)\n        return\n\n    epsilon = 0.0001\n    if min_duration is not None and min_duration - epsilon > duration:\n        raise ValueError(f\"Video duration must be at least {min_duration}s, got {duration}s\")\n    if max_duration is not None and duration > max_duration + epsilon:\n        raise ValueError(f\"Video duration must be at most {max_duration}s, got {duration}s\")\n\n\ndef validate_video_frame_count(\n    video: Input.Video,\n    min_frame_count: int | None = None,\n    max_frame_count: int | None = None,\n):\n    try:\n        frame_count = video.get_frame_count()\n    except Exception as e:\n        logging.error(\"Error getting frame count of video: %s\", e)\n        return\n\n    if min_frame_count is not None and min_frame_count > frame_count:\n        raise ValueError(f\"Video frame count must be at least {min_frame_count}, got {frame_count}\")\n    if max_frame_count is not None and frame_count > max_frame_count:\n        raise ValueError(f\"Video frame count must be at most {max_frame_count}, got {frame_count}\")\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/validation_utils.py#L116-L152","documentation":"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).","triggerScenarios":"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.","commonSituations":"Full clips fed where only a segment is allowed; forgetting to trim before an image-to-video node; providers tightening max duration between versions.","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."],"exampleFix":"# shell: keep only the first 10 seconds\n# ffmpeg -ss 0 -t 10 -i input.mp4 -c copy output.mp4","handlingStrategy":"validation","validationCode":"duration = video.get_duration()\nif duration is not None and duration > MAX_DUR:\n    raise ValueError(f\"trim first: {duration:.2f}s > {MAX_DUR}s\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim long footage to the provider's max duration before loading","Split long videos into per-segment runs"],"tags":["validation","video","duration"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}