{"record":{"id":"69e1b384ff5717ca","repo":"mudler/LocalAI","slug":"width-and-height-must-not-exceed-1280x768","errorCode":null,"errorMessage":"width and height must not exceed 1280x768","messagePattern":"width and height must not exceed 1280x768","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/longcat-video/longcat_utils.py","lineNumber":194,"sourceCode":"def avatar_segments_for_frames(frames):\n    if not frames or frames <= 93:\n        return 1\n    return 1 + math.ceil((frames - 93) / 80)\n\n\ndef avatar_segments_for_duration(duration_seconds, fps=25):\n    if duration_seconds <= 0:\n        return 1\n    return avatar_segments_for_frames(math.ceil(duration_seconds * fps))\n\n\ndef validate_dimensions(width, height):\n    width = width or 832\n    height = height or 480\n    if width < 256 or height < 256:\n        raise ValueError(\"width and height must each be at least 256\")\n    if width > 1280 or height > 768:\n        raise ValueError(\"width and height must not exceed 1280x768\")\n    if width % 16 != 0 or height % 16 != 0:\n        raise ValueError(\"width and height must be divisible by 16\")\n    if width * height > 1280 * 768:\n        raise ValueError(\"requested video dimensions exceed the 1280x768 pixel limit\")\n    return width, height\n","sourceCodeStart":176,"sourceCodeEnd":200,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/longcat-video/longcat_utils.py#L176-L200","documentation":"Raised by validate_dimensions() in longcat-video when width exceeds 1280 or height exceeds 768 on either axis. This is a per-axis ceiling, checked before the combined pixel-budget check.","triggerScenarios":"Calling validate_dimensions with width > 1280 (e.g. 1920) or height > 768 (e.g. 1080), even if the other axis is small enough that total pixels would fit.","commonSituations":"Requesting 1080p/720p-standard resolutions where height 768 is exceeded (1280x720 passes; 1280x800 does not), or reusing image-aspect dimensions for video.","solutions":["Cap width at 1280 and height at 768","Use 1280x720 or 832x480 (the default) which satisfy both axes","Downscale output after generation if a larger canvas is truly needed"],"exampleFix":"# before\nvalidate_dimensions(1920, 704)  # ValueError: must not exceed 1280x768\n\n# after\nvalidate_dimensions(1280, 704)","handlingStrategy":"validation","validationCode":"MAX_W, MAX_H = 1280, 768\nw = min(request.width or 832, MAX_W)\nh = min(request.height or 480, MAX_H)\nvalidate_dimensions(w, h)","typeGuard":"def within_axis_caps(w: int, h: int) -> bool:\n    return (w or 832) <= 1280 and (h or 480) <= 768","tryCatchPattern":"try:\n    w, h = validate_dimensions(w, h)\nexcept ValueError as err:\n    return error_response(str(err), hint='per-axis cap 1280x768; try 1280x720')","preventionTips":["Clamp axes to 1280/768 client-side","Prefer known-good presets (832x480, 1280x720)","Remember 1080p-height values always fail"],"tags":["python","validation","dimensions","longcat-video"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}