Moviepy: FFMPEG not downloaded

Created on 13 Mar 2017  路  26Comments  路  Source: Zulko/moviepy

Until two days ago, imageio was downloading ffmpeg correctly. It is not doing so anymore.

ERR Traceback (most recent call last):
ERR   File "restapi.py", line 9, in <module>
ERR     from modules.location_from_media_module import location_from_media
ERR     from helpers.flicksys_audio_video import get_video, get_frame, make_url, delete_file
ERR   File "/home/vcap/app/helpers/flicksys_audio_video.py", line 5, in <module>
ERR   File "/app/.heroku/python/lib/python2.7/site-packages/moviepy/editor.py", line 22, in <module>
ERR     from .video.io.VideoFileClip import VideoFileClip
File "/app/.heroku/python/lib/python2.7/site-packages/moviepy/video/io/VideoFileClip.py", line 3, in <module>
ERR     from moviepy.video.VideoClip import VideoClip
ERR   File "/app/.heroku/python/lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 20, in <module>
ERR     from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
ERR   File "/app/.heroku/python/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_writer.py", line 19, in <module>
ERR   File "/app/.heroku/python/lib/python2.7/site-packages/moviepy/config.py", line 38, in <module>
ERR     FFMPEG_BINARY = get_exe()
ERR   File "/app/.heroku/python/lib/python2.7/site-packages/imageio/plugins/ffmpeg.py", line 86, in get_exe
ERR     raise NeedDownloadError('Need ffmpeg exe. '
ERR imageio.core.fetching.NeedDownloadError: Need ffmpeg exe. You can download it by calling:
ERR   imageio.plugins.ffmpeg.download()

Details of deployed server:

IBM Bluemix CloudFoundry App
Runs Ubuntu 14.04 LTS Server
Moviepy installed via pip.

Adding the line imagio.plugins.ffmpeg.download() to my python code has no effect. Also, I'm not sure why it is looking for ffmpeg exe when it is running on a linux server.

3rd-party stale

Most helpful comment

Oh yeah sorry for not addressing that. When do you run the imageio.plugins.ffmpeg.download() ? My best guess would be "not soon enough". Can you try this ?

import imageio
imageio.plugins.ffmpeg.download()
from moviepy.editor import *

And report what happens ?

All 26 comments

Thanks for this. This is the new imageio behavior where imageio gets downloaded only if you run a specific command. Moviepy was very beginner-friendly before when imageio automatically installed ffmpeg, and it would be nice that it keeps being so. I would be for fixing this ASAP and possibly before the next release on PyPI, but I am not sure at which level the check for FFMPEG should be done. One solution would be to make the check/download ffmpeg inside the moviepy.editor module, another in the __init__.py file, both have pros and cons. @almarklein any ideas on where the check for ffmpeg is best placed ?

@Zulko Appreciate the immediate response.

From what I understand, there was a change in imageio behavior and it does not get downloaded from pip requirements automatically anymore (unless a specific command is run), hence no ffmpeg.

Could you highlight on what that command(s) is/are? I've raised an issue on imageio github repo as well.

Oh yeah sorry for not addressing that. When do you run the imageio.plugins.ffmpeg.download() ? My best guess would be "not soon enough". Can you try this ?

import imageio
imageio.plugins.ffmpeg.download()
from moviepy.editor import *

And report what happens ?

I was running it right before the first usage of moviepy. I'll try this approach now. I guess the call imageio.plugins.ffmpeg.download() is blocking and so from moviepy.editor import * will wait for the download to finish?

@Zulko This seems to have worked. The first 10 lines of my code look like this:

import imageio

imageio.plugins.ffmpeg.download()

import wave
import pafy
import os
import moviepy.editor as mpy
import datetime

and it's working.

Altough pycharm is giving me a warning saying pep8 module level import not at top of file for the other imports.

Please do ping me if moviepy adds an internal check for ffmpeg and downloads it accordingly!

Thanks!

This confirms the solution to this problem is to run imageio.plugins.ffmpeg.download() internally in moviepy

This confirms the solution to this problem is to run imageio.plugins.ffmpeg.download() internally in moviepy

Yes, that function is there in part because I was thinking of moviepy :)

But you should only have to run imageio.plugins.ffmpeg.download() once per computer, I think

yes, though the function caches the download, so calling it a second time will not start a new download.

You just need to catch this particular NeedDownloadError error and run imageio.plugins.ffmpeg.download(), rerun the failed command, then resume normally. that will be done only once because then this error wont be raised.

even better, yes :)

@Zulko you say to catch the NeedDownLoadError and then run the command imageio.plugins.ffmpeg.download() to download the ffmpeg.win32.exe file, if i understand correclty.
What if and an other file missing and the programm raise an NeedDownLoadError again?
or this cannot be happen?

@gpantelis You don't need to catch it. Just add these two lines at the very top of the file where you are using moviepy and you should be done.

import imageio
imageio.plugins.ffmpeg.download()

@Zulko are there any other dependencies which can raise a NeedDownloadError exception?

I'm not sure I was very clear. What we'll do is, inside MoviePy, catch that particular exception that appears in this issue, as this is the first ffmpeg-missing-related exception that appears when moviepy boots up. This way there wont be a need for any external hack.

@Zulko Yup, got it. The hack is a temporary solution!

@Zulko is there something stopping this issue from getting closed?

PS: Great job with this package!

I think we should actually sort this out, so that the end user doesn't need to manually install it. It is clearly an issue for some people, as my answer here is regularly upvoted, and the question has been asked on Github several times.

@tburrows13 I'm using your answer in my script. I was just wondering why hasn't it been accepted yet.

If you mean you鈥檙e wondering why this issue hasn鈥檛 been closed, it鈥檚 because there was discussion about a permanent fix, which hasn鈥檛 been implemented yet. As it鈥檚 such a simple fix, I鈥檒l try to push it this week, then close this issue.

Also note: at imageio we're considering adding a plugin based on pyav, mostly because we have a lot of issues with using ffmpeg directly. This would be an optional dependency for imageio, but I can imagine that if moviepy made it a direct dependency, everything would just work. See also https://github.com/imageio/imageio/issues/115.

@tburrows13 You said _"But you should only have to run imageio.plugins.ffmpeg.download() once per computer, I think"_

That doesn't sound so good. So, if I am distributing a desktop software with moviepy, every user that buys the software has to go through this nonsense of downloading something for an hour before they can use the software? This is not realistic.

@tengerdata that's not as bad as this, first because it doesnt take an hour, more like seconds, and second because you could simply run imageio.plugins.ffmpeg.download() as part of the installation process of your desktop software.

@tengerdata, in fact, this issue should probably be closed. In #731 when you import moviepy.editor, it calls imageio.plugins.ffmpeg.download() for you. This is in version 0.2.3.3. And as @Zulko said, it only takes a few seconds.

I guess you might want to be including the ffmpeg binary with your packaged application... in which case you should be able to provide your own binary and link to moviepy by either editing config_defaults.py or setting the environment variable yourself. I confess I don鈥檛 really know how these work.

@tengerdata The packaging of ffmpeg is for various reasons out of scope of imageio and moviepy. If you distribute an app, it's your job to ship ffmpeg along with it. We've tried to make this process easy. Also note that you can install ffmpeg using conda install ffmpeg -c conda-forge.

It was suggested before that we close this issue, can this be closed now?

For the record, since about a year, the way to install ffmpeg support for imageio is to pip/conda install imageio-ffmpeg. That lib is a lower-level wrapper arount ffmpeg and solves the packaging problem using binary wheels.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gicehajunior picture Gicehajunior  路  3Comments

Netherdrake picture Netherdrake  路  4Comments

Deng-deng-deng-deng picture Deng-deng-deng-deng  路  3Comments

arianaa30 picture arianaa30  路  4Comments

djevo1 picture djevo1  路  3Comments