我有同樣的問題。在挖掘之後,源代碼中的函數聲明中缺少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