Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Zulko/moviepy
Browse files Browse the repository at this point in the history
  • Loading branch information
bearney74 committed Mar 10, 2017
2 parents ae93f71 + f9c65f0 commit 5b29868
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
12 changes: 9 additions & 3 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def write_images_sequence(self, nameformat, fps=None, verbose=True,
@requires_duration
@convert_masks_to_RGB
def write_gif(self, filename, fps=None, program='imageio',
opt='wu', fuzz=1, verbose=True,
opt=0, fuzz=1, verbose=True,
loop=0, dispose=False, colors=None, tempfiles=False):
""" Write the VideoClip to a GIF file.
Expand Down Expand Up @@ -460,10 +460,16 @@ 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)

elif tempfiles:
#convert imageio opt variable to something that can be used with
#ImageMagick
opt1=opt
if opt1 == 0:
opt1='optimizeplus'
else:
opt1='OptimizeTransparency'
write_gif_with_tempfiles(self, filename, fps=fps,
program=program, opt=opt, fuzz=fuzz,
program=program, opt=opt1, fuzz=fuzz,
verbose=verbose,
loop=loop, dispose=dispose, colors=colors)
else:
Expand Down
10 changes: 2 additions & 8 deletions moviepy/video/compositing/transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
from moviepy.video.fx.fadein import fadein
from moviepy.video.fx.fadeout import fadeout

@requires_duration
@add_mask_if_none
def crossfadein(clip, duration):
""" Makes the clip appear progressively, over ``duration`` seconds.
Only works when the clip is included in a CompositeVideoClip.
"""
clip.mask.duration = clip.duration
newclip = clip.copy()
newclip.mask = clip.mask.fx(fadein, duration)
return newclip
Expand Down Expand Up @@ -113,14 +115,6 @@ def slide_out(clip, duration, side):
return clip.set_pos( pos_dict[side] )










@requires_duration
def make_loopable(clip, cross_duration):
""" Makes the clip fade in progressively at its own end, this way
Expand Down
4 changes: 2 additions & 2 deletions moviepy/video/io/gif_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick',
verbose_print(verbose, "[MoviePy] >>>> File %s is ready !"%filename)


def write_gif_with_image_io(clip, filename, fps=None, opt='wu', loop=0,
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).
Expand All @@ -277,7 +277,7 @@ def write_gif_with_image_io(clip, filename, fps=None, opt='wu', loop=0,
if fps is None:
fps = clip.fps

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

Expand Down
17 changes: 17 additions & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ def test_issue_285():
merged_clip = concatenate_videoclips([clip_1, clip_2, clip_3])
assert merged_clip.duration == 30


def test_issue_354():
clip = ImageClip("media/python_logo.png")

clip.duration = 10
crosstime = 1

#caption = editor.TextClip("test text", font="Liberation-Sans-Bold", color='white', stroke_color='gray', stroke_width=2, method='caption', size=(1280, 720), fontsize=60, align='South-East')
#caption.duration = clip.duration
fadecaption = clip.crossfadein(crosstime).crossfadeout(crosstime)
ret = CompositeVideoClip([clip, fadecaption])

def test_issue_359():
video = ColorClip((800, 600), color=(255,0,0)).set_duration(5)
video.fps=30
video.write_gif(filename="/tmp/issue_359.gif", tempfiles=True)

def test_issue_407():
red = ColorClip((800, 600), color=(255,0,0)).set_duration(5)
red.fps=30
Expand Down

0 comments on commit 5b29868

Please sign in to comment.