{"record":{"id":"055dd523a8762d25","repo":"mudler/LocalAI","slug":"requested-video-dimensions-exceed-the-1280x768-pix","errorCode":null,"errorMessage":"requested video dimensions exceed the 1280x768 pixel limit","messagePattern":"requested video dimensions exceed the 1280x768 pixel limit","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/longcat-video/longcat_utils.py","lineNumber":198,"sourceCode":"\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":180,"sourceCodeEnd":200,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/longcat-video/longcat_utils.py#L180-L200","documentation":"Raised by validate_dimensions() in longcat-video as the final check when width*height exceeds 1280*768 (983040 pixels total). Both axes individually fit their caps, but the combined resolution exceeds the model's pixel budget — e.g. 1280x768 is allowed yet 1280x768-equivalent tall aspect (768x1280 fails the height check first) so this fires for combos like 1024x1024.","triggerScenarios":"Calling validate_dimensions with values like 1024x1024 (1048576 > 983040) or 1280x768-borderline products; each axis passes but the product exceeds the limit.","commonSituations":"Square formats (1024x1024) that fit per-axis but blow the total, or trading width for height while keeping high resolution.","solutions":["Reduce one dimension until width*height <= 983040 (e.g. 1024x960 -> 1024x896)","Use 832x480 or 1280x768 which are known-good","Compute the product before submitting and downscale proportionally"],"exampleFix":"# before\nvalidate_dimensions(1024, 1024)  # ValueError: pixel limit\n\n# after\nvalidate_dimensions(1024, 896)   # 917504 <= 983040","handlingStrategy":"validation","validationCode":"PIXEL_BUDGET = 1280 * 768\nif (w or 832) * (h or 480) > PIXEL_BUDGET:\n    scale = (PIXEL_BUDGET / (w * h)) ** 0.5\n    w, h = int(w * scale // 16) * 16, int(h * scale // 16) * 16\nvalidate_dimensions(w, h)","typeGuard":"def within_pixel_budget(w: int, h: int) -> bool:\n    return (w or 832) * (h or 480) <= 1280 * 768","tryCatchPattern":"try:\n    w, h = validate_dimensions(w, h)\nexcept ValueError as err:\n    return error_response(str(err), hint='total pixels must be <= 983040')","preventionTips":["Check width*height before submission for square formats","Downscale proportionally when over budget","Remember the budget is on the product, not per-axis"],"tags":["python","validation","dimensions","longcat-video"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}