{"record":{"id":"c90e4124815a8fc4","repo":"Comfy-Org/ComfyUI","slug":"could-not-convert-the-input-video-to-container-va","errorCode":null,"errorMessage":"Could not convert the input video to {container.value.upper()} for upload; the file may be corrupted or use an unsupported codec. Try re-exporting it as MP4 (H.264). Original error: {e}","messagePattern":"Could not convert the input video to (.+?) for upload; the file may be corrupted or use an unsupported codec\\. Try re-exporting it as MP4 \\(H\\.264\\)\\. Original error: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/upload_helpers.py","lineNumber":164,"sourceCode":"        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\n\n_3D_MIME_TYPES = {\n    \"glb\": \"model/gltf-binary\",\n    \"obj\": \"model/obj\",\n    \"fbx\": \"application/octet-stream\",\n}\n\n\nasync def upload_3d_model_to_comfyapi(\n    cls: type[IO.ComfyNode],","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/upload_helpers.py#L146-L182","documentation":"upload_video_to_comfyapi re-encodes the input via video.save_to(BytesIO, format=container, codec=codec) before uploading. Any exception from that PyAV encode is wrapped as ValueError advising the file may be corrupted or use an unsupported codec, with the original error appended.","triggerScenarios":"save_to failing: source undecodable (corrupt file, wrong extension), a codec the local PyAV/FFmpeg build cannot decode (e.g. HEVC 10-bit, VP9 without support), or the target encode parameters invalid for the stream (odd dimensions, unusual pixel format).","commonSituations":"Downloading a partial file and uploading it; HEVC/ProRes/AV1 sources on FFmpeg builds without those decoders; videos from phones with HDR metadata; codec enum mismatch between container and codec (e.g. WEBM container with H264 codec).","solutions":["Read the 'Original error:' suffix — it names the exact PyAV failure.","Re-export the source as MP4 with H.264 and yuv420p: ffmpeg -i in.mov -c:v libx264 -pix_fmt yuv420p -c:a aac out.mp4.","Ensure container and codec arguments are compatible (mp4+h264, webm+vp9).","Upgrade the PyAV/av package if the codec is supported by newer FFmpeg builds."],"exampleFix":"// before\nurl = await upload_video_to_comfyapi(cls, video, container=Types.VideoContainer.WEBM, codec=Types.VideoCodec.H264)  # codec not allowed in webm\n\n// after\nurl = await upload_video_to_comfyapi(cls, video, container=Types.VideoContainer.MP4, codec=Types.VideoCodec.H264)","handlingStrategy":"try-catch","validationCode":"import av\n\nwith av.open(path) as c:\n    v = c.streams.video[0]\n    if v.codec.name not in ('h264', 'vp9'):\n        raise ValueError(f'Pre-convert source codec {v.codec.name} to H.264 first')","typeGuard":null,"tryCatchPattern":"try:\n    url = await upload_video_to_comfyapi(cls, video, container=Types.VideoContainer.MP4, codec=Types.VideoCodec.H264)\nexcept ValueError as e:\n    if 'Could not convert the input video' in str(e):\n        # re-encode externally and retry\n        raise\n    raise","preventionTips":["Pre-encode uploads to MP4/H.264/yuv420p before the workflow.","Match container and codec parameters (mp4+h264, webm+vp9) — never mix families.","Install a full-featured PyAV/FFmpeg build when handling HEVC/ProRes/AV1 sources."],"tags":["video","upload","codec","pyav","encode"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}