7

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

whiletrue
  • 10,500
  • 6
  • 27
  • 47
shmible
  • 71
  • 1
  • 3

3 Answers3

12

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
Community
  • 1
  • 1
whiletrue
  • 10,500
  • 6
  • 27
  • 47
  • For step 2, how does one paste the file to the path? –  Jul 24 '18 at 08:20
  • 1
    Hi, I'm sorry for the late response. Unfortunately this does not work for me. I get the same errors as in my original post. However, I really appreciate that you took the time to try this out. – shmible Jul 25 '18 at 07:25
  • @MPath, use the command "mv source destination" in the terminal (type "Terminal" in spotlight to open a terminal) – whiletrue Aug 09 '18 at 09:57
3

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.

GJStein
  • 648
  • 5
  • 13
1

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.

Bill Bell
  • 21,021
  • 5
  • 43
  • 58
  • Unfortunately, I wasn't able to get it to work with your approach. I appreciate your input though. – shmible Aug 06 '17 at 00:44