python - 在 macOS 上为 MoviePy 安装 ffmpeg 失败并出现 SSL 错误

标签 python macos ffmpeg moviepy python-imageio

我正在尝试编写一个 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 和 Static 构建进行安装,但都没有用。似乎自己编译它对我来说有点太先进了(我只是简单地研究了一下)。我在 IDLE 上使用了 imageio.plugins.ffmpeg.download()。我阅读了一些有关使用 PyCharm 运行 MoviePy 代码的内容,但我遇到了相同的初始错误。 ffmpeg 目前在我的 /usr/local/bin 文件夹中。欢迎提出任何建议。感谢您的帮助。

编辑:我正在使用 Python 3.6.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 安装 ffmpeg

关于python - 在 macOS 上为 MoviePy 安装 ffmpeg 失败并出现 SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45467234/

相关文章:

python - 如何聚合一个键的不同值,然后将另一个键的匹配值相加?

ruby - 您的 Ruby 版本是 2.0.0,但您的 Gemfile 指定为 2.1.1

objective-c - 将 Objective-C 终端应用程序从 Mac OS X 移植到 Linux?

JavaScript 命令在 Safari 中未按顺序执行

python - pip 总是重新安装压缩包,即使已经安装

Python mechanize - 提交表单两次

python - 如何在 Python 中拆分字符串,直到从右到左出现特定字符之一?

android - libmp3lame.a 中 undefined symbol _init_xrpow_core_init

python - Python 中的 mp4 元数据提取

php - 如何停止 ffmpeg 写入日志命令行字符串