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

Write_Gif returns errno 2 #62

Closed
selfcommit opened this issue Sep 16, 2014 · 10 comments
Closed

Write_Gif returns errno 2 #62

selfcommit opened this issue Sep 16, 2014 · 10 comments

Comments

@selfcommit
Copy link

Calling write_gif

from moviepy.editor import *

clip_file = "./Import-csv.mp4"

clip = (VideoFileClip("./Import-csv.mp4", audio=False).subclip((0,0.0),(0,16.25)))

clip.write_gif("./Import_csv.gif")

returns the following error:

MoviePy Running:
convert -delay 3 -dispose 1 -loop 0 Import_csv_GIFTEMP*.png -coalesce -fuzz 01% -layers OptimizeTransparency Import_csv.gifTraceback (most recent call last):
File "/Users/doboyle/convert.py", line 7, in <module>
  clip.write_gif("Import_csv.gif")
  File "<string>", line 2, in write_gif
  File "/Library/Python/2.7/site-packages/moviepy/decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "/Library/Python/2.7/site-packages/moviepy/video/VideoClip.py", line 476, in write_gif
    subprocess_call( cmd, verbose = verbose )
  File "/Library/Python/2.7/site-packages/moviepy/tools.py", line 27, in subprocess_call
    proc = sp.Popen(cmd, stderr = sp.PIPE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
[Finished in 25.9s with exit code 1]
@selfcommit
Copy link
Author

Ugh, I tried manipulating a number of different things, but of course resolved it AFTER posting.

clip.write_gif() needed a valid location to write to.

My apologies.

@Zulko
Copy link
Owner

Zulko commented Sep 16, 2014

Cool. A few tips:

  • your gif has by default the same fps as the original video. In your case, 30, that's a bit much. just provide fps=15 for instance in write_gif to change that.
  • you can use write_gif2() instead of write_gif, it's the same in slightly faster (no temporary files, everything is done in the RAM).
  • Keep in mind that GIF generation is much slower than video generation (because ImageMagick tries to compress losslessly) so outputing videofiles is better to preview clips. If you installed moviepy recently and you use the ipython notebook you can preview your clip in the notebook with ipython_display(clip, autoplay=1, loop=1).

@selfcommit
Copy link
Author

Thanks write_gif2 is MUCH better, also saves me having to clear the directory on a failure...

Do you have some sample code on using ipython notebooks? I just grabed ipython but I'm not familiar.

@nico7et8
Copy link

Hi, thanks for the great package !
I'm having the same issue when trying to run moviepy on OSX Mavericks (example1 of "Vector animation with Python").

Traceback (most recent call last):
  File "/Users/nicolas/Projects/vectoranim/test01.py", line 15, in <module>
    clip.write_gif("circle.gif",fps=15, opt="OptimizePlus", fuzz=10)
  File "<string>", line 2, in write_gif
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/video/VideoClip.py", line 435, in write_gif
    dispose= dispose, colors=colors)
  File "<string>", line 2, in write_gif
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/video/io/gif_writers.py", line 186, in write_gif
    stdout=sp.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 858, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1456, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'convert'

And being a bit of a newbie in Python (and in coding, really), I'm not sure what @selfcommit means by "clip.write_gif() needed a valid location to write to". A pointer in the right direction would me much welcome !...

@Zulko
Copy link
Owner

Zulko commented Sep 24, 2014

Hi @nico7et8 , I don't think it is the same as @selfcommit, in your case MoviePy cannot find the program convert, which certainly means that you didn't install ImageMagick on your computer. Tell me if it works once you have installed ImageMagick.

@nico7et8
Copy link

Thanks for such a quick reply !
I have installed ImageMagik but maybe not the right way. I'll check again if I've done everything by the book and see how it works.
Thank you again.

@nico7et8
Copy link

Hi again @Zulko , sorry for the disturbance and thank you for your time.
I've re-installed everything (I'm using Python3.4 on Mavericks) :

  • moviepy
  • ffmpeg (successfully found by conf.py)
  • ImageMagick (convert command works in the terminal, as suggested on the ImageMagick website)
    I've even tried to point IMAGEMAGICK_BINARY to the imageMagik convert file but I get the same error message :
Traceback (most recent call last):
  File "/Users/nicolas/Projects/vectoranim/test01.py", line 15, in <module>
    clip.write_gif("circle.gif",fps=15, opt="OptimizePlus", fuzz=10)
  File "<string>", line 2, in write_gif
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/video/VideoClip.py", line 435, in write_gif
    dispose= dispose, colors=colors)
  File "<string>", line 2, in write_gif
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/decorators.py", line 49, in requires_duration
    return f(clip, *a, **k)
  File "/Users/nicolas/Virtualenvs/python3/lib/python3.4/site-packages/moviepy-0.2.1.8.12-py3.4.egg/moviepy/video/io/gif_writers.py", line 186, in write_gif
    stdout=sp.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 858, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1456, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'convert'

If you have an other minute to spare, any idea or direction would be welcome. Thanks again.

@nico7et8
Copy link

Scratch that, it works !

@Zulko
Copy link
Owner

Zulko commented Sep 24, 2014

Yay ! So what made it work ?

@nico7et8
Copy link

I'm looking into it...
Yes : It must be a very beginner mistake bit :
I had changed the IMAGEMAGICK_BINARY of conf.py in the wrong folder (moviepy instead of moviepy-à.2.1.8.12.py3.4.egg). Sorry, I'm new to all this.
But thank you for your time. Animation and Image/movie processing is the reason I took up python and your package is exactly what I've been looking for. Thanks for all the work !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants