Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFMPEG not downloaded #493

Closed
kartikarora opened this issue Mar 13, 2017 · 26 comments
Closed

FFMPEG not downloaded #493

kartikarora opened this issue Mar 13, 2017 · 26 comments
Labels
lib-misc Issues pertaining to misc. 3rd-party libraries. stale For issues lacking activity, whose creators have become unresponsive,...

Comments

@kartikarora
Copy link

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.

@Zulko
Copy link
Owner

Zulko commented Mar 13, 2017

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 ?

@kartikarora
Copy link
Author

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

@Zulko
Copy link
Owner

Zulko commented Mar 13, 2017

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 ?

@kartikarora
Copy link
Author

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?

@kartikarora
Copy link
Author

@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!

@Zulko
Copy link
Owner

Zulko commented Mar 13, 2017

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

@almarklein
Copy link

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 :)

@tburrows13
Copy link
Collaborator

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

@almarklein
Copy link

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

@Zulko
Copy link
Owner

Zulko commented Mar 14, 2017

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.

@almarklein
Copy link

even better, yes :)

@gpantelis
Copy link
Contributor

@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?

@kartikarora
Copy link
Author

@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?

@Zulko
Copy link
Owner

Zulko commented Mar 14, 2017

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.

@kartikarora
Copy link
Author

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

@keikoro keikoro added the lib-misc Issues pertaining to misc. 3rd-party libraries. label Nov 25, 2017
@joaofguerreiro
Copy link

joaofguerreiro commented Feb 28, 2018

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

PS: Great job with this package!

@tburrows13
Copy link
Collaborator

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.

@joaofguerreiro
Copy link

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

@tburrows13
Copy link
Collaborator

If you mean you’re wondering why this issue hasn’t been closed, it’s because there was discussion about a permanent fix, which hasn’t been implemented yet. As it’s such a simple fix, I’ll try to push it this week, then close this issue.

@almarklein
Copy link

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 imageio/imageio#115.

@tengerdata
Copy link

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

@Zulko
Copy link
Owner

Zulko commented May 22, 2018

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

@tburrows13
Copy link
Collaborator

@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’t really know how these work.

@almarklein
Copy link

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

@keikoro
Copy link
Collaborator

keikoro commented Dec 16, 2018

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

@keikoro keikoro added the stale For issues lacking activity, whose creators have become unresponsive,... label Dec 16, 2018
willprice added a commit to torchvideo/torchvideo that referenced this issue Feb 19, 2019
Previous versions were broken due to a breaking change in imageio

See Zulko/moviepy#493 for more
willprice added a commit to torchvideo/torchvideo that referenced this issue Aug 9, 2019
Previous versions were broken due to a breaking change in imageio

See Zulko/moviepy#493 for more
@almarklein
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib-misc Issues pertaining to misc. 3rd-party libraries. stale For issues lacking activity, whose creators have become unresponsive,...
Projects
None yet
Development

No branches or pull requests

8 participants