Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Zulko/moviepy
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed May 29, 2018
2 parents 8ea97da + cb1a965 commit 4473cfc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ If you are reporting a bug, please ensure moviepy is updated to the latest versi
### Specifications

- Python Version:
- Moviepy Version
- Moviepy Version:
- Platform Name:
- Platform Version:
18 changes: 13 additions & 5 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ def write_videofile(self, filename, fps=None, codec=None,
audio_nbytes, audio_bufsize,
audio_codec, bitrate=audio_bitrate,
write_logfile=write_logfile,
verbose=verbose, progress_bar=progress_bar)
verbose=verbose,
progress_bar=progress_bar)

ffmpeg_write_video(self, filename, fps, codec,
bitrate=bitrate,
Expand Down Expand Up @@ -394,7 +395,8 @@ def write_images_sequence(self, nameformat, fps=None, verbose=True,
@convert_masks_to_RGB
def write_gif(self, filename, fps=None, program='imageio',
opt='nq', fuzz=1, verbose=True,
loop=0, dispose=False, colors=None, tempfiles=False):
loop=0, dispose=False, colors=None, tempfiles=False,
progress_bar=True):
""" Write the VideoClip to a GIF file.
Converts a VideoClip into an animated GIF using ImageMagick
Expand Down Expand Up @@ -430,6 +432,9 @@ def write_gif(self, filename, fps=None, program='imageio',
Useful on computers with little RAM. Can only be used with
ImageMagick' or 'ffmpeg'.
progress_bar
If True, displays a progress bar
Notes
-----
Expand All @@ -447,7 +452,8 @@ def write_gif(self, filename, fps=None, program='imageio',

if program == 'imageio':
write_gif_with_image_io(self, filename, fps=fps, opt=opt, loop=loop,
verbose=verbose, colors=colors)
verbose=verbose, colors=colors,
progress_bar=progress_bar)
elif tempfiles:
# convert imageio opt variable to something that can be used with
# ImageMagick
Expand All @@ -459,11 +465,13 @@ def write_gif(self, filename, fps=None, program='imageio',
write_gif_with_tempfiles(self, filename, fps=fps,
program=program, opt=opt1, fuzz=fuzz,
verbose=verbose, loop=loop,
dispose=dispose, colors=colors)
dispose=dispose, colors=colors,
progress_bar=progress_bar)
else:
write_gif(self, filename, fps=fps, program=program,
opt=opt, fuzz=fuzz, verbose=verbose, loop=loop,
dispose=dispose, colors=colors)
dispose=dispose, colors=colors,
progress_bar=progress_bar)

# -----------------------------------------------------------------
# F I L T E R I N G
Expand Down
21 changes: 13 additions & 8 deletions moviepy/video/io/gif_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@use_clip_fps_by_default
def write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',
opt="OptimizeTransparency", fuzz=1, verbose=True,
loop=0, dispose=True, colors=None):
loop=0, dispose=True, colors=None, progress_bar=True):
""" Write the VideoClip to a GIF file.
Expand All @@ -40,8 +40,13 @@ def write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',

verbose_print(verbose, "[MoviePy] Generating GIF frames...\n")

total = int(clip.duration*fps)+1
for i, t in tqdm(enumerate(tt), total=total):
if progress_bar:
total = int(clip.duration*fps)+1
iterator = tqdm(enumerate(tt), total=total)
else:
iterator = enumerate(tt)

for i, t in iterator:

name = "%s_GIFTEMP%04d.png"%(fileName, i+1)
tempfiles.append(name)
Expand Down Expand Up @@ -96,7 +101,7 @@ def write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',
@use_clip_fps_by_default
def write_gif(clip, filename, fps=None, program= 'ImageMagick',
opt="OptimizeTransparency", fuzz=1, verbose=True, withmask=True,
loop=0, dispose=True, colors=None):
loop=0, dispose=True, colors=None, progress_bar=True):
""" Write the VideoClip to a GIF file, without temporary files.
Converts a VideoClip into an animated GIF using ImageMagick
Expand Down Expand Up @@ -220,7 +225,7 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick',

try:

for t,frame in clip.iter_frames(fps=fps, progress_bar=True,
for t,frame in clip.iter_frames(fps=fps, progress_bar=progress_bar,
with_times=True, dtype="uint8"):
if withmask:
mask = 255 * clip.mask.get_frame(t)
Expand Down Expand Up @@ -251,7 +256,7 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick',


def write_gif_with_image_io(clip, filename, fps=None, opt=0, loop=0,
colors=None, verbose=True):
colors=None, verbose=True, progress_bar=True):
"""
Writes the gif with the Python library ImageIO (calls FreeImage).
Expand Down Expand Up @@ -282,7 +287,7 @@ def write_gif_with_image_io(clip, filename, fps=None, opt=0, loop=0,
)

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'):

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

writer.append_data(frame)

0 comments on commit 4473cfc

Please sign in to comment.