{"record":{"id":"1bd52dff9ebdec8d","repo":"ytdl-org/youtube-dl","slug":"warning-unable-to-obtain-file-audio-codec-with-ff","errorCode":null,"errorMessage":"WARNING: unable to obtain file audio codec with ffprobe","messagePattern":"WARNING: unable to obtain file audio codec with ffprobe","errorType":"exception","errorClass":"PostProcessingError","httpStatus":null,"severity":"error","filePath":"youtube_dl/postprocessor/ffmpeg.py","lineNumber":270,"sourceCode":"        self._nopostoverwrites = nopostoverwrites\n\n    def run_ffmpeg(self, path, out_path, codec, more_opts):\n        if codec is None:\n            acodec_opts = []\n        else:\n            acodec_opts = ['-acodec', codec]\n        opts = ['-vn'] + acodec_opts + more_opts\n        try:\n            FFmpegPostProcessor.run_ffmpeg(self, path, out_path, opts)\n        except FFmpegPostProcessorError as err:\n            raise AudioConversionError(err.msg)\n\n    def run(self, information):\n        path = information['filepath']\n\n        filecodec = self.get_audio_codec(path)\n        if filecodec is None:\n            raise PostProcessingError('WARNING: unable to obtain file audio codec with ffprobe')\n\n        more_opts = []\n        if self._preferredcodec == 'best' or self._preferredcodec == filecodec or (self._preferredcodec == 'm4a' and filecodec == 'aac'):\n            if filecodec == 'aac' and self._preferredcodec in ['m4a', 'best']:\n                # Lossless, but in another container\n                acodec = 'copy'\n                extension = 'm4a'\n                more_opts = ['-bsf:a', 'aac_adtstoasc']\n            elif filecodec in ['aac', 'flac', 'mp3', 'vorbis', 'opus']:\n                # Lossless if possible\n                acodec = 'copy'\n                extension = filecodec\n                if filecodec == 'aac':\n                    more_opts = ['-f', 'adts']\n                if filecodec == 'vorbis':\n                    extension = 'ogg'\n            else:\n                # MP3 otherwise.","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/postprocessor/ffmpeg.py#L252-L288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run without -x and check with 'ffprobe file' whether there is any audio stream at all","If video-only was selected, use a format that includes audio: -f 'bestvideo+bestaudio/best' or 'bestaudio'","Update ffmpeg/ffprobe to a current build","Re-download the file in case it was truncated"],"exampleFix":"# before\nyoutube-dl -x -f 'bestvideo' URL   # video-only stream, no audio to extract\n# after\nyoutube-dl -x -f 'bestaudio/best' URL","handlingStrategy":"validation","validationCode":"import subprocess, json\n\ndef has_audio_stream(path):\n    out = subprocess.run(['ffprobe', '-v', 'quiet', '-show_streams', '-of', 'json', path],\n                         capture_output=True).stdout\n    streams = json.loads(out or '{}').get('streams', [])\n    return any(s.get('codec_type') == 'audio' for s in streams)\n\nassert has_audio_stream(path), 'nothing to extract'","typeGuard":null,"tryCatchPattern":"try:\n    ydl.download([url])\nexcept PostProcessingError as e:\n    if 'unable to obtain file audio codec' in str(e):\n        # usually means the selected format had no audio track\n        ydl.params['format'] = 'bestaudio/best'\n        ydl.download([url])","preventionTips":["Always select an audio-bearing format (-f bestaudio/best) when using -x","Keep ffprobe current so modern codecs are recognized","Discard and re-download truncated files before post-processing"],"tags":["ffmpeg","audio-extraction","ffprobe","postprocessor"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}