Comfy-Org/ComfyUI · error · ValueError
Only H264 codec is supported for now
Error message
Only H264 codec is supported for now
What it means
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.
Source
Thrown at comfy_api/latest/_input_impl/video_types.py:107
break
return 0, 0
def write_output_metadata(container: InputContainer, output, metadata: dict | None):
"""Copy the source container's metadata, then overlay the caller's tags."""
for key, value in container.metadata.items():
if metadata is None or key not in metadata:
output.metadata[key] = value
if metadata is not None:
for key, value in metadata.items():
output.metadata[key] = value if isinstance(value, str) else json.dumps(value)
def mp4_output_open_kwargs(path: str | io.BytesIO, format: VideoContainer, codec: VideoCodec) -> dict:
if format != VideoContainer.AUTO and format != VideoContainer.MP4:
raise ValueError("Only MP4 format is supported for now")
if codec != VideoCodec.AUTO and codec != VideoCodec.H264:
raise ValueError("Only H264 codec is supported for now")
# FFmpeg's faststart pass reopens the output by filename, so it cannot be used with file-like objects.
movflags = "use_metadata_tags+faststart" if isinstance(path, (str, os.PathLike)) else "use_metadata_tags"
open_kwargs = {"mode": "w", "options": {"movflags": movflags}}
if isinstance(format, VideoContainer) and format != VideoContainer.AUTO:
open_kwargs["format"] = format.value
elif isinstance(path, io.BytesIO):
open_kwargs["format"] = "mp4" # no file extension to infer the format from
return open_kwargs
class VideoFromFile(VideoInput):
"""
Class representing video input from a file.
"""
def __init__(self, file: str | io.BytesIO, *, start_time: float=0, duration: float=0):
"""
Initialize the VideoFromFile object based off of either a path on disk or a BytesIO objectView on GitHub (pinned to 1c6d8d45b3)
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
Example fix
// before save_video(..., codec=VideoCodec.HEVC) // after save_video(..., codec=VideoCodec.H264)
Defensive patterns
Strategy: validation
Validate before calling
if codec not in (VideoCodec.AUTO, VideoCodec.H264):
codec = VideoCodec.H264 # or reject the request before reaching the writer Type guard
def is_supported_codec(c) -> bool:
return c in (VideoCodec.AUTO, VideoCodec.H264) Prevention
- Limit codec options in node UIs to what the backend implements
- Handle other codecs via external ffmpeg post-processing
When it happens
Trigger: Calling video output with codec=VideoCodec.HEVC (or any non-H264 codec) passed through from a node parameter or API call.
Common situations: 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.
Related errors
- Only MP4 format is supported for now
- H.264 output requires even dimensions, got {out_width}x{out_
- Could not convert the input video to {container.value.upper(
- {type(model).__name__} must implement map_context_window_to_
- ar_video sampler requires 5-D video latents [B,C,T,H,W], got
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/9098e6b9fefe105d.
Report an issue: GitHub.