7

我正在尝试编写一个 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.

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

编辑:我正在使用 Python 3.6.1

4

3 回答 3

12

通过调试获取脚本,我能够找到 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,然后通过import提示ffmpeg下载movie.editor
  • 显式导入 imageio 并执行imageio.plugins.ffmpeg.download()
  • brew install ffmpeg
于 2018-05-10T11:30:15.817 回答
2

I was able to solve this question using a solution similar to Bill Bell's. First, make sure that ffmpeg is actually installed on your system by running brew install ffmpeg. Then, running which ffmpeg should return something like /usr/local/bin/ffmpeg.

As Bill suggests, add FFMPEG_BINARY = "/usr/local/bin/ffmpeg" before executing your python code or alternatively add:

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

in your code. These worked on my machine.

于 2018-07-25T23:07:39.150 回答
1

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

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

添加行

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

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

于 2017-08-03T21:41:23.330 回答