Comfy-Org/ComfyUI · error · ValueError

Video width must be at most {max_width}px, got {width}px

Error message

Video width must be at most {max_width}px, got {width}px

What it means

ValueError from validate_video_dimensions when the video's width exceeds the allowed maximum. Dimensions are read via video.get_dimensions(); exceeding max_width raises before the upload/API call, saving a round-trip rejection from the provider.

Source

Thrown at comfy_api_nodes/util/validation_utils.py:112


def validate_video_dimensions(
    video: Input.Video,
    min_width: int | None = None,
    max_width: int | None = None,
    min_height: int | None = None,
    max_height: int | None = None,
):
    try:
        width, height = video.get_dimensions()
    except Exception as e:
        logging.error("Error getting dimensions of video: %s", e)
        return

    if min_width is not None and width < min_width:
        raise ValueError(f"Video width must be at least {min_width}px, got {width}px")
    if max_width is not None and width > max_width:
        raise ValueError(f"Video width must be at most {max_width}px, got {width}px")
    if min_height is not None and height < min_height:
        raise ValueError(f"Video height must be at least {min_height}px, got {height}px")
    if max_height is not None and height > max_height:
        raise ValueError(f"Video height must be at most {max_height}px, got {height}px")


def validate_video_duration(
    video: Input.Video,
    min_duration: float | None = None,
    max_duration: float | None = None,
):
    try:
        duration = video.get_duration()
    except Exception as e:
        logging.error("Error getting duration of video: %s", e)
        return

    epsilon = 0.0001

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Downscale/re-encode the video to width <= max_width before the node.
  2. Trim the export resolution in your video editor or via ffmpeg: ffmpeg -i in.mp4 -vf scale=2048:-2 out.mp4.
  3. Choose a provider supporting higher resolutions if you need full width.

Example fix

# shell: downscale before loading
# ffmpeg -i input.mp4 -vf scale=2048:-2 output.mp4
Defensive patterns

Strategy: validation

Validate before calling

width, _ = video.get_dimensions()
if width > MAX_W:
    raise ValueError(f"downscale first: {width}px > {MAX_W}px")

Prevention

When it happens

Trigger: validate_video_dimensions(video, max_width=N) with width > N — e.g., 4K (3840px) footage into a node capping max_width=2048.

Common situations: 4K/UHD source clips; upscaled video; screen recordings at native monitor width exceeding provider caps.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/dc4cb3da1d268217. Report an issue: GitHub.