mudler/LocalAI · error · ValueError
num_frames must not be negative
Error message
num_frames must not be negative
What it means
ValueError from longcat-video's generation RPC: num_frames is a proto int that must be >= 0. Zero means 'derive frame count automatically' (from audio duration or defaults); negative values are meaningless and rejected before dispatch to the base or avatar generation path.
Source
Thrown at backend/python/longcat-video/backend.py:273
try:
params, ignored_params = select_known_options(
dict(request.params), REQUEST_PARAMS
)
if ignored_params:
print(
f"longcat-video ignoring unknown request param(s): {', '.join(ignored_params)}",
file=sys.stderr,
)
os.makedirs(os.path.dirname(request.dst) or ".", mode=0o750, exist_ok=True)
if hasattr(context, "add_callback"):
context.add_callback(interrupt_if_cancelled)
if request.start_image and not os.path.isfile(request.start_image):
raise ValueError("start_image is not a readable staged file")
if request.num_frames < 0:
raise ValueError("num_frames must not be negative")
if self.model_kind == MODEL_KIND_BASE:
if request.audio:
raise ValueError(
"audio input requires a LongCat-Video-Avatar-1.5 model"
)
self._generate_base(request, params)
else:
self._generate_avatar(request, params, context)
return backend_pb2.Result(
message="Video generated successfully", success=True
)
except ValueError as err:
return self._fail(context, grpc.StatusCode.INVALID_ARGUMENT, str(err))
except Exception as err:
print(f"Error generating LongCat video: {err}", file=sys.stderr)
traceback.print_exc()View on GitHub (pinned to 44413a9d06)
Solutions
- Send num_frames=0 to let the backend choose the frame count automatically
- Clamp client-side computed frame counts to >= 0 before building the request
Example fix
# before req.num_frames = requested_frames # can be -1 # after req.num_frames = max(0, requested_frames)
Defensive patterns
Strategy: validation
Validate before calling
def sanitize_video_request(req):
if req.num_frames < 0:
req.num_frames = 0 # 0 = backend default/derived
return req Try / catch
try:
stub.GenerateVideo(req)
except grpc.RpcError as e:
if "num_frames" in (e.details() or ""):
req.num_frames = 0
stub.GenerateVideo(req)
else:
raise Prevention
- Clamp all numeric request fields at your API boundary before they reach gRPC
- Treat 0 as 'auto' and document that; forbid negative values in client schemas
When it happens
Trigger: Sending VideoRequest with num_frames=-1 intending 'unlimited' or 'auto' (the correct auto value is 0); computing num_frames from user input that can go negative (e.g. duration*fps - offset).
Common situations: Client arithmetic produces a negative count; users coming from APIs where -1 means 'default'.
Related errors
- resolution must be 480p or 720p
- start_image is not a readable staged file
- audio input requires a LongCat-Video-Avatar-1.5 model
- audio is required for LongCat-Video-Avatar-1.5
- dataset_source is required (path to a preprocessed dataset)
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/f3617fd11331d5dc.
Report an issue: GitHub.