【问题标题】:ffmpeg installation on macOS for MoviePy fails with SSL error在 macOS 上为 MoviePy 安装 ffmpeg 失败并出现 SSL 错误
【发布时间】:2018-07-26 07:07:39
【问题描述】:

我正在尝试编写一个 Python 程序,该程序在 Mac OS 10.11.16 上使用 MoviePy 将 MP4 文件转换为 GIF。我用:

import moviepy.editor as mp

我收到一条错误消息,提示我需要致电 imageio.plugins.ffmpeg.download() 以便下载 ffmpeg。我用:

import imageio
imageio.plugins.ffmpeg.download()

这给了我以下错误:

Imageio: 'ffmpeg.osx' was not found on your computer; downloading it now.
Error while fetching file: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>.
Error while fetching file: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>.
Error while fetching file: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>.
Error while fetching file: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>.
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    imageio.plugins.ffmpeg.download()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/imageio/plugins/ffmpeg.py", line 55, in download
    get_remote_file('ffmpeg/' + FNAME_PER_PLATFORM[plat])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/imageio/core/fetching.py", line 121, in get_remote_file
    _fetch_file(url, filename)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/imageio/core/fetching.py", line 177, in _fetch_file
    os.path.basename(file_name))
OSError: Unable to download 'ffmpeg.osx'. Perhaps there is a no internet connection? If there is, please report this problem.

我肯定有互联网连接。我找到了this 链接,并尝试使用 Homebrew 和静态版本进行安装,但都没有成功。似乎自己编译它对我来说有点太高级了(我只是简单地研究了一下)。我在 IDLE 上使用了imageio.plugins.ffmpeg.download()。我读了一些关于使用 PyCharm 运行 MoviePy 代码的内容,但我得到了相同的初始错误。 ffmpeg 目前在我的/usr/local/bin 文件夹中。欢迎任何建议。感谢您的帮助。

编辑:我使用的是 Python 3.6.1

【问题讨论】:

  • 尝试在 imageio 的 GitHub 问题跟踪器上报告它?
  • 如果我下面的解决方案能够帮助您,如果您能接受该解决方案作为答案,我会很高兴

标签: python macos ffmpeg moviepy python-imageio


【解决方案1】:

我能够通过调试获取脚本找到 macOS 的解决方法:

  1. 手动下载构建(这是发生 SSL 错误的地方): https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-osx-v3.2.4

  2. 将文件粘贴到路径:/Users/yourusername/Library/Application\ Support/imageio/ffmpeg/

  3. 重新运行您的代码

什么没有解决我的问题:

  • 用pip升级moviepy,然后通过导入movie.editor提示ffmpeg下载
  • 显式导入imageio并执行imageio.plugins.ffmpeg.download()
  • brew install ffmpeg

【讨论】:

  • 对于第2步,如何将文件粘贴到路径?
  • 您好,很抱歉回复晚了。不幸的是,这对我不起作用。我得到了和我原来的帖子一样的错误。不过,我非常感谢您抽出时间来尝试一下。
  • @MPath,在终端中使用命令“mv source destination”(在聚光灯下键入“终端”打开终端)
【解决方案2】:

我能够使用类似于比尔贝尔的解决方案来解决这个问题。首先,通过运行brew install ffmpeg 确保您的系统上实际安装了ffmpeg。然后,运行which ffmpeg 应该返回类似/usr/local/bin/ffmpeg 的内容。

按照 Bill 的建议,在执行 python 代码之前添加 FFMPEG_BINARY = "/usr/local/bin/ffmpeg",或者添加:

import os    
os.environ["FFMPEG_BINARY"] = "/usr/local/bin/ffmpeg"

在您的代码中。这些在我的机器上工作。

【讨论】:

    【解决方案3】:

    我警告你,我对 Mac OS 一无所知。但这是一种可能性。

    在moviepy文件夹中查看config_defaults.py,这是(在Linux和Windows上)可以为某些可执行文件设置位置的地方。

    添加行

    FFMPEG_BINARY = "/usr/local/bin/ffmpeg.osx"
    

    到文件的底部,我假设 ffmpeg.osx 是您的 FFMPEG 可执行文件的名称。

    【讨论】:

    • 不幸的是,我无法让它与您的方法一起使用。不过,我很感谢您的意见。
    猜你喜欢
    • 2018-03-11
    • 1970-01-01
    • 2019-04-14
    • 2017-08-28
    • 1970-01-01
    • 2012-05-02
    • 2021-07-31
    • 1970-01-01
    • 2016-11-08
    相关资源
    最近更新 更多