我已经安装了ffmpge,但收到以下DownloadError:错误:找不到ffprobe / avprobe和ffmpeg / avconv。请安装一个

时间:2020-08-01 11:55:38

标签: python audio youtube youtube-dl

从此线程寻求帮助:download only audio from youtube video using youtube-dl in python script

import youtube_dl #installed youtube_dl file

options = {
    'format':'bestaudio/best',
    'extractaudio':True,            #extracting audio
    'audioformat':'mp3',            #file options and format
    'outtmpl':'%(id)s.%(ext)s',     #name the file the ID of the video
    'noplaylist':True,
    'nocheckcertificate':True,
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',# Used ffmpeg for converting the file to mp3
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }]
}

with youtube_dl.YoutubeDL(options) as ydl:
    ydl.download(['https://youtu.be/BZP1rYjoBgI']) #final downloading

Python console output

1 个答案:

答案 0 :(得分:0)

很可能您没有完全安装ffmpeg;它必须在您的PATH中。您可以通过在终端中输入ffmpeg进行检查。

这里有多种可能的解决方案:

  1. 将ffmpeg安装到PATH中,例如,将二进制文件复制到/usr/bin/中。

  2. ffmpeg二进制文件符号链接到PATH中的目录。

  3. 设置PATH,使其包含安装ffmpeg的目录。在Linux和macOS上,this likely involved editing ~/.profile or /etc/environment,然后再次登录。在Windows上,editing the registry works

  4. 通过在您的youtube-dl配置中添加'ffmpeg_location': '/replace/this/with/the/real/path/to/your/ffmpeg'来指定配置中ffmpeg的确切位置。自然,这只会解决youtube-dl的问题,而不能解决其他依赖ffmpeg的应用程序。