{"record":{"id":"4f97ca718c3969eb","repo":"iawia002/lux","slug":"no-audio-format-found-after-filtering","errorCode":null,"errorMessage":"no audio format found after filtering","messagePattern":"no audio format found after filtering","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extractors/youtube/youtube.go","lineNumber":183,"sourceCode":"\turl, err := e.client.GetStreamURL(video, f)\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\tsize := f.ContentLength\n\tif size == 0 {\n\t\tsize, _ = request.Size(url, referer)\n\t}\n\treturn &extractors.Part{\n\t\tURL:  url,\n\t\tSize: size,\n\t\tExt:  ext,\n\t}, nil\n}\n\nfunc getVideoAudio(v *youtube.Video, mimeType string) (*youtube.Format, error) {\n\taudioFormats := v.Formats.Type(mimeType).Type(\"audio\")\n\tif len(audioFormats) == 0 {\n\t\treturn nil, errors.New(\"no audio format found after filtering\")\n\t}\n\taudioFormats.Sort()\n\treturn &audioFormats[0], nil\n}\n\nfunc getStreamExt(streamType string) string {\n\t// video/webm; codecs=\"vp8.0, vorbis\" --> webm\n\texts := utils.MatchOneOf(streamType, `(\\w+)/(\\w+);`)\n\tif exts == nil || len(exts) < 3 {\n\t\treturn \"\"\n\t}\n\treturn exts[2]\n}\n","sourceCodeStart":165,"sourceCodeEnd":197,"githubUrl":"https://github.com/iawia002/lux/blob/dd00f6d258d80b6684a0b9402d7124e5c18ef42f/extractors/youtube/youtube.go#L165-L197","documentation":"For YouTube adaptive video-only formats (AudioChannels == 0), the extractor looks for an audio format whose MIME type contains the same container as the video part (getVideoAudio(video, part.Ext), e.g. ext 'webm' → audio/webm, 'mp4' → audio/mp4). If no audio format with that container exists among the video's formats, this error is returned. It is a stream-selection mismatch: there is audio, just not in the matching container.","triggerScenarios":"A video whose only audio stream is audio/webm while the video-only part being processed has ext mp4 (or vice versa); videos exposing no separate adaptive audio at all (some live streams, restricted videos returning a reduced format list).","commonSituations":"YouTube changing which formats a client receives; age-restricted or region-restricted videos returning a stripped format list; format availability differing between fetches, making this error intermittent.","solutions":["Retry the extraction — the available format set varies between requests and a later attempt often has a matching audio format","Fall back to any audio format regardless of container when the same-container filter finds nothing (audio is re-muxed anyway since NeedMux is set)","Prefer the combined formats (AudioChannels > 0) for such videos instead of adaptive video-only streams","If it fails consistently for one video, treat it as unavailable and skip"],"exampleFix":"// before\nfunc getVideoAudio(v *youtube.Video, mimeType string) (*youtube.Format, error) {\n    audioFormats := v.Formats.Type(mimeType).Type(\"audio\")\n    if len(audioFormats) == 0 {\n        return nil, errors.New(\"no audio format found after filtering\")\n    }\n    audioFormats.Sort()\n    return &audioFormats[0], nil\n}\n\n// after (fall back to any audio container)\nfunc getVideoAudio(v *youtube.Video, mimeType string) (*youtube.Format, error) {\n    audioFormats := v.Formats.Type(mimeType).Type(\"audio\")\n    if len(audioFormats) == 0 {\n        audioFormats = v.Formats.Type(\"audio\")\n    }\n    if len(audioFormats) == 0 {\n        return nil, errors.New(\"no audio format found after filtering\")\n    }\n    audioFormats.Sort()\n    return &audioFormats[0], nil\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"streams, err := youtube.Extract(url, opts) // (*extractors.Data)\nif err != nil && strings.Contains(err.Error(), \"no audio format found\") {\n    time.Sleep(2 * time.Second)\n    streams, err = youtube.Extract(url, opts) // format list differs per fetch; retry\n    if err != nil {\n        return err // consistently absent audio: skip this video\n    }\n}","preventionTips":["Prefer combined formats (with audio) when the target video is known to lack matching audio-only streams","Retry once before giving up — the format set varies between fetches","If you vendor the extractor, add the any-container audio fallback in getVideoAudio"],"tags":["youtube","format-selection","audio","adaptive-formats","fallback"],"backgroundTag":null,"analyzedSha":"dd00f6d258d80b6684a0b9402d7124e5c18ef42f","analyzedAt":"2026-08-15T16:57:31.080Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}