{"record":{"id":"c6f6affc2cfa1897","repo":"Comfy-Org/ComfyUI","slug":"could-not-verify-video-duration-from-source-e","errorCode":null,"errorMessage":"Could not verify video duration from source: {e}","messagePattern":"Could not verify video duration from source: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/upload_helpers.py","lineNumber":154,"sourceCode":"    container: Types.VideoContainer = Types.VideoContainer.MP4,\n    codec: Types.VideoCodec = Types.VideoCodec.H264,\n    max_duration: int | None = None,\n    wait_label: str | None = \"Uploading\",\n) -> str:\n    \"\"\"\n    Uploads a single video to ComfyUI API and returns its download URL.\n    Uses the specified container and codec for saving the video before upload.\n    \"\"\"\n    if max_duration is not None:\n        try:\n            actual_duration = video.get_duration()\n            if actual_duration > max_duration:\n                raise ValueError(\n                    f\"Video duration ({actual_duration:.2f}s) exceeds the maximum allowed ({max_duration}s).\"\n                )\n        except Exception as e:\n            logging.error(\"Error getting video duration: %s\", str(e))\n            raise ValueError(f\"Could not verify video duration from source: {e}\") from e\n\n    upload_mime_type = f\"video/{container.value.lower()}\"\n    filename = f\"{uuid.uuid4()}.{container.value.lower()}\"\n\n    # Convert VideoInput to BytesIO using specified container/codec\n    video_bytes_io = BytesIO()\n    try:\n        video.save_to(video_bytes_io, format=container, codec=codec)\n    except Exception as e:\n        raise ValueError(\n            f\"Could not convert the input video to {container.value.upper()} for upload; \"\n            f\"the file may be corrupted or use an unsupported codec. \"\n            f\"Try re-exporting it as MP4 (H.264). Original error: {e}\"\n        ) from e\n    video_bytes_io.seek(0)\n\n    return await upload_file_to_comfyapi(cls, video_bytes_io, filename, upload_mime_type, wait_label)\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/upload_helpers.py#L136-L172","documentation":"When max_duration is set, upload_video_to_comfyapi must first read the source duration; if video.get_duration() itself throws, the helper wraps it as ValueError('Could not verify video duration from source: ...'). Note the inner over-limit ValueError is also caught here, so its message appears in the chain — but the primary trigger is get_duration() failing.","triggerScenarios":"VideoInput.get_duration() raising on unreadable/corrupt media, a container without duration metadata, a codec PyAV cannot probe, or a stream whose duration is unknown (live capture, some WebM/MKV files).","commonSituations":"Corrupted or truncated video files; screen recordings or pipe-produced streams missing header duration; exotic containers; a file with a mismatched extension.","solutions":["Read the appended original error — it names why probing failed.","Re-mux the file to set duration metadata: ffmpeg -i in.mp4 -c copy out.mp4.","Re-export as standard MP4 (H.264/AAC) if the container is exotic.","Verify the file plays in ffprobe/VLC before uploading."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try:\n    duration = video.get_duration()\nexcept Exception:\n    raise ValueError('Source has no readable duration metadata; re-mux with ffmpeg -c copy')","typeGuard":null,"tryCatchPattern":"try:\n    url = await upload_video_to_comfyapi(cls, video, max_duration=10)\nexcept ValueError as e:\n    if 'Could not verify video duration' in str(e):\n        # fix metadata, then retry\n        raise\n    if 'exceeds the maximum' in str(e):\n        raise  # user must trim\n    raise","preventionTips":["Re-mux recordings lacking duration headers: ffmpeg -i in.mp4 -c copy out.mp4.","Validate that ffprobe reports a duration for any clip before feeding it to upload nodes.","Avoid pipe-generated streams without finalized headers as upload sources."],"tags":["video","upload","probe","metadata"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}