{"record":{"id":"9098e6b9fefe105d","repo":"Comfy-Org/ComfyUI","slug":"only-h264-codec-is-supported-for-now","errorCode":null,"errorMessage":"Only H264 codec is supported for now","messagePattern":"Only H264 codec is supported for now","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api/latest/_input_impl/video_types.py","lineNumber":107,"sourceCode":"            break\n    return 0, 0\n\n\ndef write_output_metadata(container: InputContainer, output, metadata: dict | None):\n    \"\"\"Copy the source container's metadata, then overlay the caller's tags.\"\"\"\n    for key, value in container.metadata.items():\n        if metadata is None or key not in metadata:\n            output.metadata[key] = value\n    if metadata is not None:\n        for key, value in metadata.items():\n            output.metadata[key] = value if isinstance(value, str) else json.dumps(value)\n\n\ndef mp4_output_open_kwargs(path: str | io.BytesIO, format: VideoContainer, codec: VideoCodec) -> dict:\n    if format != VideoContainer.AUTO and format != VideoContainer.MP4:\n        raise ValueError(\"Only MP4 format is supported for now\")\n    if codec != VideoCodec.AUTO and codec != VideoCodec.H264:\n        raise ValueError(\"Only H264 codec is supported for now\")\n    # FFmpeg's faststart pass reopens the output by filename, so it cannot be used with file-like objects.\n    movflags = \"use_metadata_tags+faststart\" if isinstance(path, (str, os.PathLike)) else \"use_metadata_tags\"\n    open_kwargs = {\"mode\": \"w\", \"options\": {\"movflags\": movflags}}\n    if isinstance(format, VideoContainer) and format != VideoContainer.AUTO:\n        open_kwargs[\"format\"] = format.value\n    elif isinstance(path, io.BytesIO):\n        open_kwargs[\"format\"] = \"mp4\"  # no file extension to infer the format from\n    return open_kwargs\n\n\nclass VideoFromFile(VideoInput):\n    \"\"\"\n    Class representing video input from a file.\n    \"\"\"\n\n    def __init__(self, file: str | io.BytesIO, *, start_time: float=0, duration: float=0):\n        \"\"\"\n        Initialize the VideoFromFile object based off of either a path on disk or a BytesIO object","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api/latest/_input_impl/video_types.py#L89-L125","documentation":"The video output helper hard-codes H.264 as the only supported codec for the MP4 writer. Any VideoCodec other than AUTO or H264 (e.g. HEVC, VP9, AV1) hits an explicit guard in mp4_output_open_kwargs and raises, because the writer's stream setup (h264 stream, pix_fmt, crf handling) is specialized for H.264.","triggerScenarios":"Calling video output with codec=VideoCodec.HEVC (or any non-H264 codec) passed through from a node parameter or API call.","commonSituations":"UI exposes codec options not yet wired in the backend; users migrating from an ffmpeg wrapper that accepted hevc; automation scripts passing codec names as strings that coerce to other enum values.","solutions":["Use codec=VideoCodec.AUTO or VideoCodec.H264","Limit the codec input list to auto/h264 until other codecs are implemented","Need HEVC/VP9? Export as MP4/H264 here and re-encode externally"],"exampleFix":"// before\nsave_video(..., codec=VideoCodec.HEVC)\n\n// after\nsave_video(..., codec=VideoCodec.H264)","handlingStrategy":"validation","validationCode":"if codec not in (VideoCodec.AUTO, VideoCodec.H264):\n    codec = VideoCodec.H264  # or reject the request before reaching the writer","typeGuard":"def is_supported_codec(c) -> bool:\n    return c in (VideoCodec.AUTO, VideoCodec.H264)","tryCatchPattern":null,"preventionTips":["Limit codec options in node UIs to what the backend implements","Handle other codecs via external ffmpeg post-processing"],"tags":["video","codec","h264","capability-gate"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}