{"record":{"id":"0e4bf4846e276485","repo":"ytdl-org/youtube-dl","slug":"audio-conversion-failed","errorCode":null,"errorMessage":"audio conversion failed: ","messagePattern":"audio conversion failed: ","errorType":"exception","errorClass":"PostProcessingError","httpStatus":null,"severity":"error","filePath":"youtube_dl/postprocessor/ffmpeg.py","lineNumber":334,"sourceCode":"                more_opts += ['-f', 'wav']\n\n        prefix, sep, ext = path.rpartition('.')  # not os.path.splitext, since the latter does not work on unicode in all setups\n        new_path = prefix + sep + extension\n\n        information['filepath'] = new_path\n        information['ext'] = extension\n\n        # If we download foo.mp3 and convert it to... foo.mp3, then don't delete foo.mp3, silly.\n        if (new_path == path\n                or (self._nopostoverwrites and os.path.exists(encodeFilename(new_path)))):\n            self._downloader.to_screen('[ffmpeg] Post-process file %s exists, skipping' % new_path)\n            return [], information\n\n        try:\n            self._downloader.to_screen('[ffmpeg] Destination: ' + new_path)\n            self.run_ffmpeg(path, new_path, acodec, more_opts)\n        except AudioConversionError as e:\n            raise PostProcessingError(\n                'audio conversion failed: ' + e.msg)\n        except Exception:\n            raise PostProcessingError('error running ' + self.basename)\n\n        # Try to update the date time for extracted audio file.\n        if information.get('filetime') is not None:\n            self.try_utime(\n                new_path, time.time(), information['filetime'],\n                errnote='Cannot update utime of audio file')\n\n        return [path], information\n\n\nclass FFmpegVideoConvertorPP(FFmpegPostProcessor):\n    def __init__(self, downloader=None, preferedformat=None):\n        super(FFmpegVideoConvertorPP, self).__init__(downloader)\n        self._preferedformat = preferedformat\n","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/postprocessor/ffmpeg.py#L316-L352","documentation":"Raised by FFmpegExtractAudioPP.run when run_ffmpeg fails with AudioConversionError: the ffmpeg invocation itself errored (FFmpegPostProcessorError was caught in run_ffmpeg and re-wrapped). The suffix e.msg carries the underlying ffmpeg output, so 'audio conversion failed: <ffmpeg error>' tells you what ffmpeg rejected.","triggerScenarios":"-x/--audio-format conversion where ffmpeg exits non-zero: target codec not available in the ffmpeg build (e.g. no libmp3lame), corrupt input file, unreadable output path, or an outdated ffmpeg (<1.0) that does not understand the options used.","commonSituations":"Distros shipping ffmpeg without libmp3lame (mp3 extraction fails); ffmpeg 0.x builds predating required version '1.0'; output directories without write permission; input files with unsupported codecs.","solutions":["Read the ffmpeg error appended after the colon — it names the exact problem","Install a full-featured ffmpeg build (with libmp3lame for --audio-format mp3)","Update ffmpeg to >= 1.0 as check_version warns","Verify the output directory is writable and the input file is not truncated"],"exampleFix":"# before (ffmpeg without libmp3lame)\nyoutube-dl -x --audio-format mp3 URL\n# after (full build)\nsudo apt-get install ffmpeg   # Debian: enables libmp3lame\nyoutube-dl -x --audio-format mp3 URL","handlingStrategy":"try-catch","validationCode":"import subprocess\n\ndef ffmpeg_has_encoder(codec):\n    out = subprocess.run(['ffmpeg', '-hide_banner', '-encoders'], capture_output=True).stdout.decode()\n    return codec in out\n\nif target == 'mp3' and not ffmpeg_has_encoder('libmp3lame'):\n    target = 'm4a'  # pick a codec this build supports","typeGuard":null,"tryCatchPattern":"try:\n    ydl.download([url])\nexcept PostProcessingError as e:\n    if str(e).startswith('audio conversion failed:'):\n        # e.msg tail contains ffmpeg's own error; usually a missing encoder\n        log.error('ffmpeg said: %s — install full ffmpeg build', str(e).split(':', 1)[1])","preventionTips":["Use a full ffmpeg build (libmp3lame etc.) in environments that convert audio","Update ffmpeg to at least 1.0; heed the version warning youtube-dl prints","Parse the ffmpeg suffix after 'audio conversion failed:' — it names the real cause"],"tags":["ffmpeg","audio-conversion","codec","postprocessor"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}