{"record":{"id":"28380b08f58a98a2","repo":"Comfy-Org/ComfyUI","slug":"only-mp4-format-is-supported-for-now","errorCode":null,"errorMessage":"Only MP4 format is supported for now","messagePattern":"Only MP4 format is supported for now","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api/latest/_input_impl/video_types.py","lineNumber":105,"sourceCode":"            return frames[0].sample_rate, frames[0].layout.nb_channels\n        if i >= max_packets:\n            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):","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api/latest/_input_impl/video_types.py#L87-L123","documentation":"mp4_output_open_kwargs builds PyAV open options for video output and currently supports only the MP4 container. Passing any VideoContainer enum value other than AUTO or MP4 (e.g. WEBM, MKV, AVI) raises 'Only MP4 format is supported for now' — a deliberate capability gate, not a runtime failure.","triggerScenarios":"Calling the video transcode/output path with format=VideoContainer.WEBM (or any non-MP4, non-AUTO container) from a node option or API parameter.","commonSituations":"Frontend exposes a container dropdown copied from another tool; user scripts pass webm/mkv hoping for support; version upgrades that added the enum before the encoders.","solutions":["Select MP4 (or AUTO, which resolves to mp4) as the output container","Restrict the UI/API option list to MP4/AUTO until other containers are implemented","For other containers, transcode externally with ffmpeg after saving MP4"],"exampleFix":"// before\nsave_video(..., format=VideoContainer.WEBM)\n\n# after\nsave_video(..., format=VideoContainer.MP4)","handlingStrategy":"validation","validationCode":"if format not in (VideoContainer.AUTO, VideoContainer.MP4):\n    format = VideoContainer.MP4  # or surface an option error in the UI before calling","typeGuard":"def is_supported_container(f) -> bool:\n    return f in (VideoContainer.AUTO, VideoContainer.MP4)","tryCatchPattern":null,"preventionTips":["Keep the container dropdown limited to mp4/auto until more are supported","Test new enum values against the writer before exposing them in the UI"],"tags":["video","container","mp4","capability-gate"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}