[英]ffmpeg installation on macOS for MoviePy fails with SSL error
I'm trying to write a Python program that uses MoviePy on Mac OS 10.11.16 to convert an MP4 file to GIF. 我正在尝试编写一个在Mac OS 10.11.16上使用MoviePy将Python文件转换为GIF的Python程序。 I use:
我用:
import moviepy.editor as mp
and I get an error saying I need to call imageio.plugins.ffmpeg.download()
so I can download ffmpeg. 我得到一个错误,说我需要调用
imageio.plugins.ffmpeg.download()
所以我可以下载ffmpeg。 I use: 我用:
import imageio
imageio.plugins.ffmpeg.download()
which gives me the following error: 这给了我以下错误:
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.
I definitely have an internet connection. 我绝对有互联网连接。 I found this link, and tried installing with Homebrew and Static builds, but neither have worked.
我找到了这个链接,并尝试使用Homebrew和Static版本进行安装,但两者都没有用。 It seems like compiling it myself would be a little too advanced for me (I've only briefly looked into it).
似乎自己编译它对我来说有点太先进(我只是简单地研究过它)。 I used
imageio.plugins.ffmpeg.download()
on IDLE. 我在IDLE上使用了
imageio.plugins.ffmpeg.download()
。 I read something about using PyCharm to run the MoviePy code, but I get the same initial error. 我读了一些关于使用PyCharm来运行MoviePy代码的内容,但是我得到了相同的初始错误。 ffmpeg is currently in my
/usr/local/bin
folder. ffmpeg目前在我的
/usr/local/bin
文件夹中。 Any suggestions are welcome. 欢迎任何建议。 Thank for your help.
谢谢您帮忙。
Edit: I'm using Python 3.6.1 编辑:我正在使用Python 3.6.1
manually download the built (this is where the SSL error occurs): https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-osx-v3.2.4 手动下载内置的(这是发生SSL错误的地方): https : //github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-osx-v3.2.4
paste the file to the path: /Users/yourusername/Library/Application\\ Support/imageio/ffmpeg/
将文件粘贴到路径:
/Users/yourusername/Library/Application\\ Support/imageio/ffmpeg/
re-run your code 重新运行您的代码
movie.editor
movie.editor
提示ffmpeg下载 imageio.plugins.ffmpeg.download()
imageio.plugins.ffmpeg.download()
brew install ffmpeg
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
. 首先,通过运行
brew install ffmpeg
确保ffmpeg
实际安装在您的系统上。 Then, running which ffmpeg
should return something like /usr/local/bin/ffmpeg
. 然后,运行
which ffmpeg
应返回类似/usr/local/bin/ffmpeg
。
As Bill suggests, add FFMPEG_BINARY = "/usr/local/bin/ffmpeg"
before executing your python code or alternatively add: 比尔建议,在执行你的python代码之前添加
FFMPEG_BINARY = "/usr/local/bin/ffmpeg"
,或者添加:
import os
os.environ["FFMPEG_BINARY"] = "/usr/local/bin/ffmpeg"
in your code. 在你的代码中。 These worked on my machine.
这些在我的机器上工作。
I warn you, I know nothing about Mac OS. 我警告你,我对Mac OS 一无所知 。 But here's a possibility.
但这是一种可能性。
Look in config_defaults.py
, in the moviepy folder, which is where (on Linux and Windows) one can set the locations for certain executables. 看在
config_defaults.py
,在moviepy文件夹,这就是(在Linux和Windows),可以设置某些可执行文件的位置。
Add the line 添加行
FFMPEG_BINARY = "/usr/local/bin/ffmpeg.osx"
to the bottom of the file, where I assume that ffmpeg.osx
is the name of your FFMPEG executable. 到文件的底部,我假设
ffmpeg.osx
是你的FFMPEG可执行文件的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.