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

Cannot convert mov to gif #55

Closed
mekza opened this issue Aug 2, 2014 · 4 comments
Closed

Cannot convert mov to gif #55

mekza opened this issue Aug 2, 2014 · 4 comments

Comments

@mekza
Copy link
Contributor

mekza commented Aug 2, 2014

In [1]: from moviepy.editor import *

In [2]: clip = (VideoFileClip("timelapse.mov").subclip(1,37).speedx(6).fx( vfx.blackwhite, preserve_luminosity=True))

In [3]: clip.write_gif('timelapse.gif',loop=1,program='ImageMagick')

MoviePy: building GIF file timelapse.gif
----------------------------------------
Generating GIF frames.
|----------| 0/145   0% [elapsed: 00:00 left: ?, ? iters/sec]---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-35e583d45ded> in <module>()
----> 1 clip.write_gif('timelapse.gif',loop=1,program='ImageMagick')

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/moviepy-0.2.1.8.05-py2.7.egg/moviepy/video/VideoClip.pyc in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose)
    455             name = "%s_GIFTEMP%04d.png"%(fileName, i+1)
    456             tempfiles.append(name)
--> 457             self.save_frame(name, t, savemask=True)
    458 
    459         verbose_print(verbose, "Done generating GIF frames.\n")

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/moviepy-0.2.1.8.05-py2.7.egg/moviepy/video/VideoClip.pyc in save_frame(self, filename, t, savemask)

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/moviepy-0.2.1.8.05-py2.7.egg/moviepy/decorators.pyc in time_can_be_tuple(f, clip, *a, **k)
     91     a = map(fun,a)
     92     k = dict( [(m, fun(n)) for m,n in k.items()])
---> 93     return f(clip, *a, **k)

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/moviepy-0.2.1.8.05-py2.7.egg/moviepy/video/VideoClip.pyc in save_frame(self, filename, t, savemask)
    132             mask = 255 * self.mask.get_frame(t)
    133             im = np.dstack([im, mask]).astype('uint8')
--> 134         ffmpeg_write_image(filename, im)
    135 
    136 

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/moviepy-0.2.1.8.05-py2.7.egg/moviepy/video/io/ffmpeg_writer.pyc in ffmpeg_write_image(filename, image, logfile)
    204         err = "\n".join(["MoviePy running : %s"%cmd,
    205                           "WARNING: this command returned an error:",
--> 206                           proc.stderr.read().decode('utf8')])
    207         raise IOError(err)
    208 

ValueError: I/O operation on closed file

There is no mention of it in documentation. I will add an exception before trying to convert.

@Zulko
Copy link
Owner

Zulko commented Aug 2, 2014

Thanks for the report ! Apparently there were a few broken things. It's fixed now, just update MoviePy and tell me if it works.
Remarks:

  • you don't neep loop=1, it's the default.
  • preserve_luminosity doesn't do anything in this case.
  • You may want to decrease the fps in write_gif() to have a lighter GIF.

@Zulko
Copy link
Owner

Zulko commented Aug 12, 2014

So did it work ?

@mekza
Copy link
Contributor Author

mekza commented Aug 12, 2014

Yes it did. Sorry for my late reply.

@mekza mekza closed this as completed Aug 12, 2014
@Zulko
Copy link
Owner

Zulko commented Aug 12, 2014

No probs. Cheers.

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

2 participants