Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.66k stars 1.59k forks source link

Looping parameter is missing from write_gif_with_image_io() #629

Closed tjdawson closed 7 years ago

tjdawson commented 7 years ago

I couldn't get my gif to play once or loop a fixed amount of times, after looking at the declaration for this function on line 282 the parameter is missing from imageio.save() so the the variable is never passed through. Modifying it to the following fixed the issue:

def write_gif_with_image_io(clip, filename, fps=None, opt=0, loop=0,
                            colors=None, verbose=True):
    """
    Writes the gif with the Python library ImageIO (calls FreeImage).

    For the moment ImageIO is not installed with MoviePy. You need to install
    imageio (pip install imageio) to use this.

    Parameters
    -----------
    opt

    """

    if colors is None:
        colors=256

    if not IMAGEIO_FOUND:
      raise ImportError("Writing a gif with imageio requires ImageIO installed,"
                         " with e.g. 'pip install imageio'")

    if fps is None:
        fps = clip.fps

    quantizer = 0 if opt!= 0 else 'nq'
    writer = imageio.save(filename, duration=1.0/fps,
                          quantizer=quantizer, palettesize=colors, loop=loop)

    verbose_print(verbose, "\n[MoviePy] Building file %s with imageio\n"%filename)

    for frame in clip.iter_frames(fps=fps, progress_bar=True, dtype='uint8'):

        writer.append_data(frame)
Julian-O commented 7 years ago

I am looking at turning this into a pull request (or you could do so yourself). Are you able to provide a test case that works now and didn't work before (and doesn't require someone to manually view the gif?)

keikoro commented 7 years ago

Looks like the linked PR was merged, so I'm closing this issue. Please reopen or create a new issue if the problems persist.