ytdl-org/youtube-dl · error · PostProcessingError

WARNING: unable to obtain file audio codec with ffprobe

Error message

WARNING: unable to obtain file audio codec with ffprobe

What it means

Raised by FFmpegExtractAudioPP.run when get_audio_codec(path) returns None — the probe ran but could not determine the audio codec (e.g. ffprobe reported no audio stream or unparsable output). The message is phrased as a WARNING because historically it was only warned, but here it aborts the audio extraction.

Source

Thrown at youtube_dl/postprocessor/ffmpeg.py:270

        self._nopostoverwrites = nopostoverwrites

    def run_ffmpeg(self, path, out_path, codec, more_opts):
        if codec is None:
            acodec_opts = []
        else:
            acodec_opts = ['-acodec', codec]
        opts = ['-vn'] + acodec_opts + more_opts
        try:
            FFmpegPostProcessor.run_ffmpeg(self, path, out_path, opts)
        except FFmpegPostProcessorError as err:
            raise AudioConversionError(err.msg)

    def run(self, information):
        path = information['filepath']

        filecodec = self.get_audio_codec(path)
        if filecodec is None:
            raise PostProcessingError('WARNING: unable to obtain file audio codec with ffprobe')

        more_opts = []
        if self._preferredcodec == 'best' or self._preferredcodec == filecodec or (self._preferredcodec == 'm4a' and filecodec == 'aac'):
            if filecodec == 'aac' and self._preferredcodec in ['m4a', 'best']:
                # Lossless, but in another container
                acodec = 'copy'
                extension = 'm4a'
                more_opts = ['-bsf:a', 'aac_adtstoasc']
            elif filecodec in ['aac', 'flac', 'mp3', 'vorbis', 'opus']:
                # Lossless if possible
                acodec = 'copy'
                extension = filecodec
                if filecodec == 'aac':
                    more_opts = ['-f', 'adts']
                if filecodec == 'vorbis':
                    extension = 'ogg'
            else:
                # MP3 otherwise.

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Re-run without -x and check with 'ffprobe file' whether there is any audio stream at all
  2. If video-only was selected, use a format that includes audio: -f 'bestvideo+bestaudio/best' or 'bestaudio'
  3. Update ffmpeg/ffprobe to a current build
  4. Re-download the file in case it was truncated

Example fix

# before
youtube-dl -x -f 'bestvideo' URL   # video-only stream, no audio to extract
# after
youtube-dl -x -f 'bestaudio/best' URL
Defensive patterns

Strategy: validation

Validate before calling

import subprocess, json

def has_audio_stream(path):
    out = subprocess.run(['ffprobe', '-v', 'quiet', '-show_streams', '-of', 'json', path],
                         capture_output=True).stdout
    streams = json.loads(out or '{}').get('streams', [])
    return any(s.get('codec_type') == 'audio' for s in streams)

assert has_audio_stream(path), 'nothing to extract'

Try / catch

try:
    ydl.download([url])
except PostProcessingError as e:
    if 'unable to obtain file audio codec' in str(e):
        # usually means the selected format had no audio track
        ydl.params['format'] = 'bestaudio/best'
        ydl.download([url])

Prevention

When it happens

Trigger: Running -x on a file whose audio stream ffprobe cannot identify: the download was still video-only or corrupt, a container with no audio stream, or an ffprobe version too old to recognize the codec.

Common situations: Format selection picked a video-only stream (e.g. DASH video without audio) and then -x tried to extract audio; download interrupted leaving a truncated file; ancient ffprobe builds from distro repos.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/1bd52dff9ebdec8d. Report an issue: GitHub.