Comfy-Org/ComfyUI · error · ValueError
Two keyframes resolve to the same output frame ({a}) for a {
Error message
Two keyframes resolve to the same output frame ({a}) for a {duration} video (valid range 0-{maxframe}); give each keyframe a distinct position. What it means
Raised by the Luma Ray 3.2 keyframe video node (comfy_api_nodes/nodes_luma.py:1261) when two keyframes resolve (after rounding to 24fps frame indexes and clamping) to the same output frame. The upstream API requires distinct keyframe_indexes, so duplicates are rejected before upload.
Source
Thrown at comfy_api_nodes/nodes_luma.py:1261
# Resolve each keyframe to an output-frame index, then order by position
# (so the user can chain keyframes in any order — the position is what places them)
placed: list[tuple[int, torch.Tensor]] = []
for item in items:
if item.mode == LUMA_KEYFRAME_MODE_SECONDS:
if item.value > duration_seconds:
raise ValueError(
f"Keyframe position {item.value:g}s is past the end of the {duration} video; "
f"use 0-{duration_seconds:g}s (or switch the keyframe to fraction mode)."
)
idx = round(item.value * 24)
else:
idx = round(item.value * maxframe)
placed.append((max(0, min(maxframe, idx)), item.image))
placed.sort(key=lambda p: p[0])
indexes = [idx for idx, _ in placed]
for a, b in zip(indexes, indexes[1:]):
if a == b:
raise ValueError(
f"Two keyframes resolve to the same output frame ({a}) for a {duration} video "
f"(valid range 0-{maxframe}); give each keyframe a distinct position."
)
refs: list[Luma2ImageRef] = []
for _, image in placed:
url = await upload_image_to_comfyapi(cls, image, mime_type="image/png")
refs.append(Luma2ImageRef(url=url))
request = Luma2GenerationRequest(
prompt=prompt,
model="ray-3.2",
type="video",
video=Luma2VideoOptions(resolution=resolution, duration=duration, keyframes=refs, keyframe_indexes=indexes),
)
return await _ray32_generate(cls, request)
class LumaRay32VideoEditNode(IO.ComfyNode):
@classmethodView on GitHub (pinned to 1c6d8d45b3)
Solutions
- Spread the two colliding keyframes apart by at least 1/24s (one frame).
- Check the reported frame index {a} against each keyframe's position to find the pair.
- Remove redundant keyframes at effectively the same timestamp.
Defensive patterns
Strategy: validation
Validate before calling
maxframe = 120 if duration == "5s" else 240
idxs = sorted(
max(0, min(maxframe, round(i.value * 24 if i.mode == "seconds" else i.value * maxframe)))
for i in items
)
if len(set(idxs)) != len(idxs):
raise ValueError(f"Keyframe frame collision at frame {[f for f in idxs if idxs.count(f) > 1][0]}") Prevention
- Space keyframes at least 1/24s apart; remember positions are rounded to integer frame indexes.
- Duplicate positions also arise from clamping — keep positions strictly inside 0..maxframe.
When it happens
Trigger: Two keyframes with positions that round to the same frame index: e.g. 2.00s and 2.04s on a 5s video (both → frame 48), or two fraction-mode keyframes at 0.5 in a short video; clamping also merges any out-of-range positions at frame 0 or maxframe.
Common situations: User adds keyframes at near-identical timestamps; fraction values like 0.33/0.34 rounding together on 5s (120 frames); duplicate chain entries.
Related errors
- Connect at least 2 Luma Ray 3.2 Keyframe nodes (use Luma Ray
- Ray 3.2 supports at most 64 keyframes; got {len(items)}.
- Keyframe position {item.value:g}s is past the end of the {du
- At least one of first_image and last_image requires an input
- Looping is only available with 5s duration on Ray 3.2.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/695562af4dbce053.
Report an issue: GitHub.