{"record":{"id":"9bf978eb615b604b","repo":"Comfy-Org/ComfyUI","slug":"frame-idx-is-past-the-end-of-the-video-s-audio","errorCode":null,"errorMessage":"frame_idx {} is past the end of the video's audio track","messagePattern":"frame_idx (.+?) is past the end of the video's audio track","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_minimax_h3.py","lineNumber":228,"sourceCode":"        if resolved_frame_index < 0 or resolved_frame_index + guide_frames > frame_count:\n            if guide_frames == 1:\n                raise ValueError(\"frame_idx {} is outside the video's {} frames\".format(frame_idx, frame_count))\n            raise ValueError(\"a {} frame guide clip at frame_idx {} does not fit in the video's {} frames\".format(\n                guide_frames, frame_idx, frame_count))\n\n        keyframe = {\"resolved_frame_index\": resolved_frame_index}\n        if image is not None:\n            frames = _resize(image[:guide_frames], width, height, \"center\")\n            keyframe[\"latent\"] = vae.encode(frames)\n\n        if audio is not None:\n            if audio_vae is None:\n                raise ValueError(\"anchoring guide audio needs the audio_vae input\")\n            audio_latent, audio_rt = _encode_ref_audio(audio_vae, audio)\n            # the streams share one time axis: FRAME_RESCALE per pixel frame, 1.0 per audio latent frame\n            max_rt = math.floor(samples.tensors[1].shape[-1] - FRAME_RESCALE * resolved_frame_index)\n            if max_rt < 1:\n                raise ValueError(\"frame_idx {} is past the end of the video's audio track\".format(frame_idx))\n            if audio_rt > max_rt:\n                audio_latent = audio_latent[..., :max_rt].clone()\n            keyframe[\"audio_latent\"] = audio_latent\n\n        keyframes = list(positive[0][1].get(\"minimax_keyframes\", []))\n        keyframes.append(keyframe)\n        positive = node_helpers.conditioning_set_values(positive, {\"minimax_keyframes\": keyframes})\n        return io.NodeOutput(positive)\n\n\nclass MiniMaxH3ReferenceToVideo(io.ComfyNode):\n    \"\"\"ref2va: prompt + reference images / videos / audio -> conditioning + AV latent.\n\n    References enter the presentation in fixed order: images, then videos (each\n    soundtrack's <Audio j> label right before its <Video k>), then standalone\n    audio. Ordinals are 1-based per type, so the prompt refers to them as\n    <Picture i> / <Video k> / <Audio j>.\n    \"\"\"","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_minimax_h3.py#L210-L246","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"max_rt = math.floor(audio_len - FRAME_RESCALE * resolved_frame_index)\nif max_rt < 1:\n    raise UserFacingError('anchor audio earlier or extend the audio track')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["minimax-h3","audio","frame-index","time-axis"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}