Comfy-Org/ComfyUI · error · ValueError

No audio frames decoded.

Error message

No audio frames decoded.

What it means

After a container reports an audio stream, load() iterates af.decode; if zero frames come back the frames list stays empty and torch.cat would fail, so the helper raises this explicit error. It indicates a header-only or truncated audio stream.

Source

Thrown at comfy_extras/nodes_audio.py:353

        if not af.streams.audio:
            raise ValueError("No audio stream found in the file.")

        stream = af.streams.audio[0]
        sr = stream.codec_context.sample_rate
        n_channels = stream.channels

        frames = []
        length = 0
        for frame in af.decode(streams=stream.index):
            buf = torch.from_numpy(frame.to_ndarray())
            if buf.shape[0] != n_channels:
                buf = buf.view(-1, n_channels).t()

            frames.append(buf)
            length += buf.shape[1]

        if not frames:
            raise ValueError("No audio frames decoded.")

        wav = torch.cat(frames, dim=1)
        wav = f32_pcm(wav)
        return wav, sr

class LoadAudio(IO.ComfyNode):
    @classmethod
    def define_schema(cls):
        input_dir = folder_paths.get_input_directory()
        os.makedirs(input_dir, exist_ok=True)
        files = folder_paths.filter_files_content_types(os.listdir(input_dir), ["audio", "video"])
        return IO.Schema(
            node_id="LoadAudio",
            search_aliases=["import audio", "open audio", "audio file"],
            display_name="Load Audio",
            category="audio",
            essentials_category="Audio",
            inputs=[

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Re-download or re-mux the file (ffmpeg -i in.flac out.flac) to rebuild packet structure
  2. Verify the file plays in ffplay/VLC and has nonzero audio duration
  3. Update PyAV/FFmpeg if the codec is nominally supported but yields no frames
  4. Fall back to extracting audio via ffmpeg CLI and loading the result
Defensive patterns

Strategy: validation

Validate before calling

import av

def audio_stream_has_packets(path: str) -> bool:
    with av.open(path) as c:
        if not c.streams.audio:
            return False
        s = c.streams.audio[0]
        return s.duration is None or s.duration > 0

Try / catch

try:
    wav, sr = load(path)
except ValueError as e:
    if 'No audio frames' in str(e):
        wav, sr = load_via_ffmpeg_extract(path)  # ffmpeg -vn -acodec flac
    else:
        raise

Prevention

When it happens

Trigger: Decoding a truncated/corrupted download where the stream header exists but no packets follow; audio streams with zero-length duration; DRM-protected content that decodes to nothing; seek-past-end before decode.

Common situations: Interrupted downloads, files copied while still being written, streaming recordings finalized without their index, or unusual codecs that PyAV opens but cannot decode with the bundled FFmpeg.

Related errors


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