Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 865
shmible Avatar asked Aug 02 '17 17:08

shmible


People also ask

Where is ffmpeg path on Mac?

In Terminal, navigate to the folder containing the ffmpeg file using the "cd" (change directory) command. Type "cd" followed by the file path to your Downloads folder. For example, the path on my system is "/Users/aaron/Downloads".


3 Answers

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
like image 60
whiletrue Avatar answered Oct 17 '22 09:10

whiletrue


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.

like image 44
GJStein Avatar answered Oct 17 '22 08:10

GJStein


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.

like image 30
Bill Bell Avatar answered Oct 17 '22 09:10

Bill Bell