mudler/LocalAI · error · ValueError

width and height must each be at least 256

Error message

width and height must each be at least 256

What it means

Raised by validate_dimensions() in longcat-video when either width or height is below 256px. Defaults are 832x480 when falsy, so this fires only when an explicit small value was passed. It is the first of four ordered checks (min size, max size, divisibility, pixel budget).

Source

Thrown at backend/python/longcat-video/longcat_utils.py:192


def avatar_segments_for_frames(frames):
    if not frames or frames <= 93:
        return 1
    return 1 + math.ceil((frames - 93) / 80)


def avatar_segments_for_duration(duration_seconds, fps=25):
    if duration_seconds <= 0:
        return 1
    return avatar_segments_for_frames(math.ceil(duration_seconds * fps))


def validate_dimensions(width, height):
    width = width or 832
    height = height or 480
    if width < 256 or height < 256:
        raise ValueError("width and height must each be at least 256")
    if width > 1280 or height > 768:
        raise ValueError("width and height must not exceed 1280x768")
    if width % 16 != 0 or height % 16 != 0:
        raise ValueError("width and height must be divisible by 16")
    if width * height > 1280 * 768:
        raise ValueError("requested video dimensions exceed the 1280x768 pixel limit")
    return width, height

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Set both dimensions to at least 256 (e.g. 256x256 minimum)
  2. Pass 0/None/empty to fall back to the 832x480 default rather than an explicit tiny value
  3. Scale up small source assets to >=256 before requesting generation

Example fix

# before
validate_dimensions(192, 1080)  # ValueError: at least 256

# after
validate_dimensions(256, 1080)
Defensive patterns

Strategy: validation

Validate before calling

def clean_dims(w, h):
    w = w or 832
    h = h or 480
    if w < 256 or h < 256:
        raise ValueError('each dimension must be >= 256')
    return w, h

w, h = clean_dims(request.width, request.height)
validate_dimensions(w, h)

Type guard

def dims_ok(w: int, h: int) -> bool:
    return (w or 832) >= 256 and (h or 480) >= 256

Try / catch

try:
    w, h = validate_dimensions(request.width, request.height)
except ValueError as err:
    return error_response(str(err), hint='minimum 256x256; default 832x480')

Prevention

When it happens

Trigger: Calling validate_dimensions(width, height) with width < 256 or height < 256, e.g. 128x720 thumbnails or 832x240 for a short video.

Common situations: Generating low-resolution previews/thumbnails, swapping width and height assumptions, or reusing image-generation dimensions (which allow smaller sizes) for the video pipeline.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/0a39f436abd4e4ba. Report an issue: GitHub.