使用yt_dlp结合Python将YouTube视频转为MP3时遭遇编码器未找到错误的求助
yt_dlp结合Python将YouTube视频转为MP3时遭遇编码器未找到错误的求助
最近我用Python结合yt_dlp把YouTube视频转成纯音频MP3文件,之前一直正常运行,但现在突然报错了,提示音频转换失败:打开输出文件错误:编码器未找到。
我的环境是Windows 11 + Python 3.12,yt_dlp是2025.02.19版本,ffmpeg是7.1版本,两者都是最新状态。
具体错误信息如下:
ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found
下面是我写的下载函数,之前能正常在指定输出文件夹生成MP3文件:
def ydl_download_video(entry, out_path= "O:\\MP3\\00 CHARTS\\NEU\\"): url = entry.get('ylink').strip('\n') artist = entry.get('artist') title = entry.get('title') ydl_opts = { 'format': 'bestaudio/best', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], 'cookiefile': 'all_cookies.txt', 'outtmpl': f'{out_path}{artist} - {title}.%(ext)s' } with yt_dlp.YoutubeDL(ydl_opts) as ydl: ydl.download([url])
执行函数时的控制台完整输出:
Trying to download Track... [youtube] Extracting URL: https://www.youtube.com/watch?v=DlMEn5UU678 [youtube] DlMEn5UU678: Downloading webpage [youtube] DlMEn5UU678: Downloading tv client config [youtube] DlMEn5UU678: Downloading player 7795af42 [youtube] DlMEn5UU678: Downloading tv player API JSON [info] DlMEn5UU678: Downloading 1 format(s): 251 [download] Destination: O:\MP3\00 CHARTS\NEU\Steff Da Campo & Robbie Mendez - Cry (Just A Little).webm [download] 100% of 2.93MiB in 00:00:00 at 9.25MiB/s [ExtractAudio] Destination: O:\MP3\00 CHARTS\NEU\Steff Da Campo & Robbie Mendez - Cry (Just A Little).mp3 ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found ERROR: Postprocessing: audio conversion failed: Error opening output files: Encoder not found
现在文件会正常下载成.webm格式存到输出文件夹,但没法自动转成MP3了。我已经更新了所有相关组件,也谷歌过各种解决方案,但还没找到有效的办法。有没有遇到过同样问题的朋友能给点建议?
备注:内容来源于stack exchange,提问作者Ralf Stresow
相关产品推荐
相关产品推荐

