iawia002/lux · error

no audio format found after filtering

Error message

no audio format found after filtering

What it means

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.

Source

Thrown at extractors/youtube/youtube.go:183

	url, err := e.client.GetStreamURL(video, f)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	size := f.ContentLength
	if size == 0 {
		size, _ = request.Size(url, referer)
	}
	return &extractors.Part{
		URL:  url,
		Size: size,
		Ext:  ext,
	}, nil
}

func getVideoAudio(v *youtube.Video, mimeType string) (*youtube.Format, error) {
	audioFormats := v.Formats.Type(mimeType).Type("audio")
	if len(audioFormats) == 0 {
		return nil, errors.New("no audio format found after filtering")
	}
	audioFormats.Sort()
	return &audioFormats[0], nil
}

func getStreamExt(streamType string) string {
	// video/webm; codecs="vp8.0, vorbis" --> webm
	exts := utils.MatchOneOf(streamType, `(\w+)/(\w+);`)
	if exts == nil || len(exts) < 3 {
		return ""
	}
	return exts[2]
}

View on GitHub (pinned to dd00f6d258)

Solutions

  1. Retry the extraction — the available format set varies between requests and a later attempt often has a matching audio format
  2. 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)
  3. Prefer the combined formats (AudioChannels > 0) for such videos instead of adaptive video-only streams
  4. If it fails consistently for one video, treat it as unavailable and skip

Example fix

// before
func getVideoAudio(v *youtube.Video, mimeType string) (*youtube.Format, error) {
    audioFormats := v.Formats.Type(mimeType).Type("audio")
    if len(audioFormats) == 0 {
        return nil, errors.New("no audio format found after filtering")
    }
    audioFormats.Sort()
    return &audioFormats[0], nil
}

// after (fall back to any audio container)
func getVideoAudio(v *youtube.Video, mimeType string) (*youtube.Format, error) {
    audioFormats := v.Formats.Type(mimeType).Type("audio")
    if len(audioFormats) == 0 {
        audioFormats = v.Formats.Type("audio")
    }
    if len(audioFormats) == 0 {
        return nil, errors.New("no audio format found after filtering")
    }
    audioFormats.Sort()
    return &audioFormats[0], nil
}
Defensive patterns

Strategy: fallback

Try / catch

streams, err := youtube.Extract(url, opts) // (*extractors.Data)
if err != nil && strings.Contains(err.Error(), "no audio format found") {
    time.Sleep(2 * time.Second)
    streams, err = youtube.Extract(url, opts) // format list differs per fetch; retry
    if err != nil {
        return err // consistently absent audio: skip this video
    }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.


AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15). Data as JSON: /api/errors/4f97ca718c3969eb. Report an issue: GitHub.