Comfy-Org/ComfyUI · error · ValueError
frame_idx {} is past the end of the video's audio track
Error message
frame_idx {} is past the end of the video's audio track What it means
The video and audio streams share one time axis in an H3 AV latent: each pixel frame costs FRAME_RESCALE audio latent frames. The node computes the audio room left at resolved_frame_index (max_rt = audio_length - FRAME_RESCALE * resolved_frame_index) and requires at least 1 remaining audio frame, otherwise the guide's audio would start past the end of the track.
Source
Thrown at comfy_extras/nodes_minimax_h3.py:228
if resolved_frame_index < 0 or resolved_frame_index + guide_frames > frame_count:
if guide_frames == 1:
raise ValueError("frame_idx {} is outside the video's {} frames".format(frame_idx, frame_count))
raise ValueError("a {} frame guide clip at frame_idx {} does not fit in the video's {} frames".format(
guide_frames, frame_idx, frame_count))
keyframe = {"resolved_frame_index": resolved_frame_index}
if image is not None:
frames = _resize(image[:guide_frames], width, height, "center")
keyframe["latent"] = vae.encode(frames)
if audio is not None:
if audio_vae is None:
raise ValueError("anchoring guide audio needs the audio_vae input")
audio_latent, audio_rt = _encode_ref_audio(audio_vae, audio)
# the streams share one time axis: FRAME_RESCALE per pixel frame, 1.0 per audio latent frame
max_rt = math.floor(samples.tensors[1].shape[-1] - FRAME_RESCALE * resolved_frame_index)
if max_rt < 1:
raise ValueError("frame_idx {} is past the end of the video's audio track".format(frame_idx))
if audio_rt > max_rt:
audio_latent = audio_latent[..., :max_rt].clone()
keyframe["audio_latent"] = audio_latent
keyframes = list(positive[0][1].get("minimax_keyframes", []))
keyframes.append(keyframe)
positive = node_helpers.conditioning_set_values(positive, {"minimax_keyframes": keyframes})
return io.NodeOutput(positive)
class MiniMaxH3ReferenceToVideo(io.ComfyNode):
"""ref2va: prompt + reference images / videos / audio -> conditioning + AV latent.
References enter the presentation in fixed order: images, then videos (each
soundtrack's <Audio j> label right before its <Video k>), then standalone
audio. Ordinals are 1-based per type, so the prompt refers to them as
<Picture i> / <Video k> / <Audio j>.
"""View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Lower frame_idx so that FRAME_RESCALE * frame_idx < audio latent length.
- Regenerate the AV latent with an audio track long enough to cover the anchor position.
- Anchor audio earlier or extend the audio input so max_rt >= 1.
Defensive patterns
Strategy: validation
Validate before calling
max_rt = math.floor(audio_len - FRAME_RESCALE * resolved_frame_index)
if max_rt < 1:
raise UserFacingError('anchor audio earlier or extend the audio track') Prevention
- Keep FRAME_RESCALE * frame_idx below the audio latent length.
- Ensure AV latents have audio covering the whole video duration.
- Anchor audio near the start for short audio tracks.
When it happens
Trigger: Anchoring audio at a frame_idx whose audio-axis position consumes the entire audio track: resolved_frame_index * FRAME_RESCALE >= audio latent length; typically a late frame_idx combined with a short audio latent.
Common situations: Long videos whose audio latent is short (silent tail); negative indexing to the last frames; mixing latents whose audio and video lengths were generated inconsistently.
Related errors
- frame_idx {} is outside the video's {} frames
- a {} frame guide clip at frame_idx {} does not fit in the vi
- ERROR: audio encoder file is invalid or unsupported embed_di
- ERROR: audio encoder not supported.
- Minimum cutoff must be larger than zero.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/9bf978eb615b604b.
Report an issue: GitHub.