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 failing #296

Closed
ajmagat opened this issue May 25, 2016 · 4 comments
Closed

write_gif failing #296

ajmagat opened this issue May 25, 2016 · 4 comments
Labels
documentation Related to documentation in official project docs or individual docstrings.

Comments

@ajmagat
Copy link

ajmagat commented May 25, 2016

Hey Guys,

I'm trying to follow the first part of the tutorial here http://zulko.github.io/blog/2014/01/23/making-animated-gifs-from-video-files-with-python/ but can't seem to get it working.

I realize there have been updates since the writing of the article, but was wondering if I was just possibly doing something wrong, or if the write_gif functionality isn't working / has some dependencies I am unaware of.

Thanks for any help

from moviepy.editor import *
clip = (VideoFileClip("frozen_trailer.mp4").subclip((1, 22.65), (1, 23.2)).resize(0.3))

TypeError                                 Traceback (most recent call last)
<ipython-input-3-822a7eb596ad> in <module>()
----> 1 clip.write_gif("small_gif.mp4")

<decorator-gen-170> in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose, colors, tempfiles)

/Library/Python/2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     52         raise ValueError("Attribute 'duration' not set")
     53     else:
---> 54         return f(clip, *a, **k)
     55 
     56 

<decorator-gen-169> in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose, colors, tempfiles)

/Library/Python/2.7/site-packages/moviepy/decorators.pyc in convert_masks_to_RGB(f, clip, *a, **k)
     20     if clip.ismask:
     21         clip = clip.to_RGB()
---> 22     return f(clip, *a, **k)
     23 
     24 @decorator.decorator

/Library/Python/2.7/site-packages/moviepy/video/VideoClip.pyc in write_gif(self, filename, fps, program, opt, fuzz, verbose, loop, dispose, colors, tempfiles)
    460         if program == 'imageio':
    461             write_gif_with_image_io(self, filename, fps=fps, opt=opt, loop=loop,
--> 462                                     verbose=verbose, colors=colors)
    463 
    464         elif tempfiles:

/Library/Python/2.7/site-packages/moviepy/video/io/gif_writers.py in write_gif_with_image_io(clip, filename, fps, opt, loop, colors, verbose)
    283     quantizer = 'wu' if opt!= 'nq' else 'nq'
    284     writer = imageio.save(filename, duration=1.0/fps,
--> 285                           quantizer=quantizer, palettesize=colors)
    286 
    287     verbose_print(verbose, "\n[MoviePy] Building file %s with imageio\n"%filename)

/Library/Python/2.7/site-packages/imageio/core/functions.pyc in get_writer(uri, format, mode, **kwargs)
    150 
    151     # Return its writer object
--> 152     return format.get_writer(request)
    153 
    154 

/Library/Python/2.7/site-packages/imageio/core/format.pyc in get_writer(self, request)
    169             raise RuntimeError('Format %s cannot write in mode %r' % 
    170                                (self.name, select_mode))
--> 171         return self.Writer(self, request)
    172 
    173     def can_read(self, request):

/Library/Python/2.7/site-packages/imageio/core/format.pyc in __init__(self, format, request)
    205             self._request = request
    206             # Open the reader/writer
--> 207             self._open(**self.request.kwargs.copy())
    208 
    209         @property

TypeError: _open() got an unexpected keyword argument 'duration' 
@devonhk
Copy link

devonhk commented Jun 22, 2016

Try something like this

from moviepy.editor import VideoFileClip

clip = VideoFileClip(media_path).subclip(
    t_start=1,   # time in seconds
    t_end=3
).resize(.40)
clip.write_gif('test.gif')

This works for me

@cvn
Copy link

cvn commented Jan 18, 2017

I just had this same problem. It was the output file extension. Changing small_gif.mp4 to small_gif.gif would fix the error above.

@keikoro
Copy link
Collaborator

keikoro commented Feb 19, 2017

@ajmagat, did you mange to fix this with the info provided here?

@pydo Could you summarise what you did to fix this? Is this something that could/should be added to the documentation so usage is clearer?

@keikoro keikoro added the documentation Related to documentation in official project docs or individual docstrings. label Feb 19, 2017
@ghost
Copy link

ghost commented Mar 13, 2017

No response in 23 days, so closing issue.

@ghost ghost closed this as completed Mar 13, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation in official project docs or individual docstrings.
Projects
None yet
Development

No branches or pull requests

4 participants