Comfy-Org/ComfyUI · error · ValueError
Audio duration must be at least {min_duration}s, got {dur +
Error message
Audio duration must be at least {min_duration}s, got {dur + eps:.2f}s What it means
Raised by validate_audio_duration() in comfy_api_nodes/util/validation_utils.py when an AUDIO input is shorter than the provider's minimum. Duration is computed as waveform.shape[-1] / sample_rate with a one-sample epsilon (1/sr) added so that a waveform containing exactly min_duration of samples passes. The check runs before the API call so short audio fails fast locally.
Source
Thrown at comfy_api_nodes/util/validation_utils.py:169
raise ValueError(f"Video frame count must be at most {max_frame_count}, got {frame_count}")
def get_number_of_images(images):
if isinstance(images, torch.Tensor):
return images.shape[0] if images.ndim >= 4 else 1
return len(images)
def validate_audio_duration(
audio: Input.Audio,
min_duration: float | None = None,
max_duration: float | None = None,
) -> None:
sr = int(audio["sample_rate"])
dur = int(audio["waveform"].shape[-1]) / sr
eps = 1.0 / sr
if min_duration is not None and dur + eps < min_duration:
raise ValueError(f"Audio duration must be at least {min_duration}s, got {dur + eps:.2f}s")
if max_duration is not None and dur - eps > max_duration:
raise ValueError(f"Audio duration must be at most {max_duration}s, got {dur - eps:.2f}s")
def validate_string(
string: str,
strip_whitespace=True,
field_name="prompt",
min_length=None,
max_length=None,
):
if string is None:
raise Exception(f"Field '{field_name}' cannot be empty.")
if strip_whitespace:
string = string.strip()
if min_length and len(string) < min_length:
raise Exception(
f"Field '{field_name}' cannot be shorter than {min_length} characters; was {len(string)} characters long."View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Extend the audio to at least min_duration seconds: pad with silence (e.g. an audio-pad/empty-audio node) or supply a longer recording.
- Verify the actual duration in Python: len(audio['waveform'].shape[-1]) / audio['sample_rate'] before wiring it in.
- Check the node's tooltip for the provider's minimum and use a provider/node with a lower minimum if your content is intentionally short.
- If silence-trim or VAD nodes are shortening the clip, disable or re-tune them upstream.
Example fix
# before: 1.2 s audio into validate_audio_duration(audio, 3.0, 29.0)
# raises: Audio duration must be at least 3.0s, got 1.20s
# after: pad audio with silence to >= 3 s before the node
sr = audio['sample_rate']
need = int(3.0 * sr) - audio['waveform'].shape[-1]
if need > 0:
audio['waveform'] = torch.cat([audio['waveform'], torch.zeros(1, 1, need)], dim=-1) Defensive patterns
Strategy: validation
Validate before calling
def audio_duration(audio) -> float:
return audio['waveform'].shape[-1] / audio['sample_rate']
if audio_duration(a) + 1.0 / a['sample_rate'] < MIN_DUR:
a['waveform'] = torch.nn.functional.pad(a['waveform'], (0, int(MIN_DUR * a['sample_rate']) - a['waveform'].shape[-1])) Try / catch
try: validate_audio_duration(audio, min_duration=MIN) except ValueError as e: raise RuntimeError(f'Short audio: {e}') from e Prevention
- Compute duration from waveform length / sample_rate before wiring audio in.
- Pad short clips with silence to clear provider minimums.
- Watch silence-trim nodes shrinking clips below the limit.
When it happens
Trigger: Passing an AUDIO tensor to a node that calls validate_audio_duration(audio, min_duration=X) — e.g. Wan/Kling lip-sync nodes enforce min 2-3 s, sync.so nodes use max only, bytedance clips cap at 30 s. A 1.0 s clip into a node with min_duration=2.0 raises because dur + 1/sr < 2.0.
Common situations: User records or crops a very short voice line for lip-sync; a TTS upstream node produces a trailing-silence-trimmed clip shorter than expected; or a silence-trim node removes most of the audio. Common after switching providers, since minima differ (1.5 s, 2 s, 3 s).
Related errors
- Audio duration must be at most {max_duration}s, got {dur - e
- Too many reference audios: {total_audios} (audios={len(refer
- Reference audio {i} is too short: {dur:.1f}s. Minimum durati
- Total reference audio duration is {total_audio_duration:.1f}
- Audio duration must be between 2 and 20 seconds, got {audio_
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/56160f74ea65505e.
Report an issue: GitHub.