python - 我已经安装了 ffmpge 但收到以下 DownloadError : ERROR: ffprobe/avprobe and ffmpeg/avconv not found. 请安装一个

标签 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

最佳答案

很可能,您没有完全安装 ffmpeg;它必须在您的 PATH 中.您可以通过键入 ffmpeg 进行检查在一个终端。
这里有多种可能的解决方案:

  • 将 ffmpeg 安装到您的 PATH ,例如通过将二进制文件复制到 /usr/bin/ .
  • 符号链接(symbolic link)ffmpeg二进制到您的PATH 中的目录.
  • 设置您的 PATH以便它包含您安装 ffmpeg 的目录。在 Linux 和 macOS 上,this likely involved editing ~/.profile or /etc/environment 并再次登录。在 Windows 上,editing the registry works .
  • 通过添加 'ffmpeg_location': '/replace/this/with/the/real/path/to/your/ffmpeg' 在您的配置中指定精确的 ffmpeg 位置到您的 youtube-dl 配置。当然,这只会解决 youtube-dl 的问题,而不是其他依赖 ffmpeg 的应用程序。
  • 关于python - 我已经安装了 ffmpge 但收到以下 DownloadError : ERROR: ffprobe/avprobe and ffmpeg/avconv not found. 请安装一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63204915/

    相关文章:

    Python:解码文件中的base64多个字符串

    python - 使用 Python 解析来自 AWS SDK 的 Cloudformation 字符串响应

    python - 主窗口小部件调整大小(Pyside)

    javascript - WebView 不会触发 YouTube 中的导航事件

    python - 获取 YouTube 数据 API 的 Python 代码中的关键错误和导入错误

    python - 从程序中使用 Python 的 `timeit` 但功能与命令行相同?

    Java 音频不会使用正确的参数初始化 TargetDataLine

    c# - 在控制台上播放声音 - C#

    Linux正弦波音频发生器

    php - 如何在 php 中使用 youtube api 为播放列表设置缩略图?