ffmpeg installation on macOS for MoviePy fails with SSL error

柔情痞子 提交于 2019-12-09 10:16:49

问题


I'm trying to write a Python program that uses MoviePy on Mac OS 10.11.16 to convert an MP4 file to GIF. 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. 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. 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. I read something about using PyCharm to run the MoviePy code, but I get the same initial error. ffmpeg is currently in my /usr/local/bin folder. Any suggestions are welcome. Thank for your help.

Edit: I'm using Python 3.6.1


回答1:


I was able to find a workaround for macOS by debugging the fetching script:

  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

  2. paste the file to the path: /Users/yourusername/Library/Application\ Support/imageio/ffmpeg/

  3. re-run your code

what didn't solve my problem:

  • upgrading moviepy with pip, then prompting the ffmpeg download through importing movie.editor
  • explicitly importing imageio and executing imageio.plugins.ffmpeg.download()
  • brew install ffmpeg



回答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.




回答3:


I warn you, I know nothing about 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.

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.



来源:https://stackoverflow.com/questions/45467234/ffmpeg-installation-on-macos-for-moviepy-fails-with-ssl-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!