{"record":{"id":"944b319ed76b3ea3","repo":"Comfy-Org/ComfyUI","slug":"no-audio-stream-found-in-the-file","errorCode":null,"errorMessage":"No audio stream found in the file.","messagePattern":"No audio stream found in the file\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_audio.py","lineNumber":336,"sourceCode":"        return IO.NodeOutput(audio, ui=UI.PreviewAudio(audio, cls=cls))\n\n    save_flac = execute  # TODO: remove\n\n\ndef f32_pcm(wav: torch.Tensor) -> torch.Tensor:\n    \"\"\"Convert audio to float 32 bits PCM format.\"\"\"\n    if wav.dtype.is_floating_point:\n        return wav\n    elif wav.dtype == torch.int16:\n        return wav.float() / (2 ** 15)\n    elif wav.dtype == torch.int32:\n        return wav.float() / (2 ** 31)\n    raise ValueError(f\"Unsupported wav dtype: {wav.dtype}\")\n\ndef load(filepath: str) -> tuple[torch.Tensor, int]:\n    with av.open(filepath) as af:\n        if not af.streams.audio:\n            raise ValueError(\"No audio stream found in the file.\")\n\n        stream = af.streams.audio[0]\n        sr = stream.codec_context.sample_rate\n        n_channels = stream.channels\n\n        frames = []\n        length = 0\n        for frame in af.decode(streams=stream.index):\n            buf = torch.from_numpy(frame.to_ndarray())\n            if buf.shape[0] != n_channels:\n                buf = buf.view(-1, n_channels).t()\n\n            frames.append(buf)\n            length += buf.shape[1]\n\n        if not frames:\n            raise ValueError(\"No audio frames decoded.\")\n","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_audio.py#L318-L354","documentation":"The load() helper uses PyAV and requires at least one audio stream; af.streams.audio is empty for video-only files, music-less MP4s, or files PyAV cannot map an audio stream in, so it raises before attempting decode.","triggerScenarios":"Calling load() on an MP4/MKV with only a video stream, a corrupted container where the audio track is unrecognized, or a file extension mismatch (video content renamed .wav).","commonSituations":"Pointing LoadAudio at a video file that has no audio; partially downloaded files; containers whose audio codec is unsupported by the installed FFmpeg build.","solutions":["Verify with ffprobe that the file contains an audio stream","Re-mux/re-encode to include audio or extract audio first (ffmpeg -i in.mp4 -vn -c:a flac out.flac)","If the codec is unsupported, install an FFmpeg/PyAV build with that codec enabled","For silent videos, supply audio from another source instead of loading this file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import av\n\ndef has_audio_stream(path: str) -> bool:\n    with av.open(path) as c:\n        return len(c.streams.audio) > 0","typeGuard":null,"tryCatchPattern":"try:\n    wav, sr = load(path)\nexcept ValueError as e:\n    if 'No audio stream' in str(e):\n        supply_audio_from_alternate_source()\n    else:\n        raise","preventionTips":["Pre-screen files with ffprobe/PyAV for an audio stream before loading","Standardize inputs to known audio containers (wav/flac)","Extract audio with ffmpeg -vn when processing video files"],"tags":["audio","pyav","container","no-audio-stream"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}