我有同样的问题。在挖掘之后,源代码中的函数声明中缺少imageio.save()
的循环参数。我提交moviepy的GitHub的页面上的问题,但你可以通过导航到moviepy\video\is\gif_writers.py
并用以下替换为write_gif_with_image_io()
(线256-289)的声明解决这个问题你自己:
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)
尝试循环= 0(参见:HTTPS ://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html#moviepy.video.VideoClip.VideoClip.write_gif) – Tom