Comfy-Org/ComfyUI · warning · ValueError

Audio duration must be between 2 and 20 seconds, got {audio_

Error message

Audio duration must be between 2 and 20 seconds, got {audio_duration:.1f}s.

What it means

Client-side ValueError in the v2.5 LTX audio-to-video node: the input audio's duration, computed as waveform length / sample_rate, must be between 2 and 20 seconds inclusive. Out-of-range audio is rejected before any upload or API call.

Source

Thrown at comfy_api_nodes/nodes_ltxv.py:564

                IO.Hidden.unique_id,
            ],
            is_api_node=True,
            price_badge=V25_A2V_PRICE_BADGE,
        )

    @classmethod
    async def execute(
        cls,
        audio: Input.Audio,
        model: dict,
        prompt: str,
        seed: int = 42,
        image: Input.Image | None = None,
    ) -> IO.NodeOutput:
        validate_string(prompt, min_length=1, max_length=10000)
        audio_duration = audio["waveform"].shape[-1] / audio["sample_rate"]
        if not 2 <= audio_duration <= 20:
            raise ValueError(f"Audio duration must be between 2 and 20 seconds, got {audio_duration:.1f}s.")
        image_uri = None
        if image is not None:
            if get_number_of_images(image) != 1:
                raise ValueError("Currently only one input image is supported.")
            image_uri = (await upload_images_to_comfyapi(cls, image, max_images=1, mime_type="image/png"))[0]
        return await _v25_submit_and_poll(
            cls,
            "audio-to-video",
            AudioToVideoRequest(
                prompt=prompt,
                model=V25_MODELS_MAP[model["model"]],
                resolution=model["resolution"],
                audio_uri=await upload_audio_to_comfyapi(cls, audio),
                image_uri=image_uri,
            ),
        )

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Trim or pad the audio to 2–20 seconds before the node.
  2. Verify sample_rate matches the actual waveform rate so the duration computation is correct.
  3. Remove trailing silence/padding that inflates duration past 20s.

Example fix

// before: 30s clip
audio = load_audio("song.wav")  # 30.0s -> raises
// after: trim to 10s
waveform = audio["waveform"][..., : audio["sample_rate"] * 10]
audio = {"waveform": waveform, "sample_rate": audio["sample_rate"]}  # 10.0s -> passes
Defensive patterns

Strategy: validation

Validate before calling

dur = audio["waveform"].shape[-1] / audio["sample_rate"]
if not 2 <= dur <= 20:
    raise ValueError(f"Trim audio to 2-20s (got {dur:.1f}s)")

Type guard

def audio_within_ltx_range(audio: dict) -> bool:
    d = audio["waveform"].shape[-1] / audio["sample_rate"]
    return 2 <= d <= 20

Prevention

When it happens

Trigger: Executing the audio-to-video node with audio['waveform'].shape[-1] / audio['sample_rate'] < 2 or > 20 — e.g. a 1-second clip, a 30-second song, or audio loaded with a wrong sample_rate metadata making the computed duration fall outside the window.

Common situations: Trimming music too aggressively (< 2s); feeding full songs (> 20s); audio tensors with padded silence inflating duration; mismatched sample_rate between loader and tensor.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/79c209c4b10b53ad. Report an issue: GitHub.