Skip to content

Commit

Permalink
Issue #574, fix duration of masks when using concatenate(.., method="…
Browse files Browse the repository at this point in the history
…compose") (#585)

* add scipy for py2.7 on travis-ci

* add tests for ffmeg_parse_infos

* put communicate back in

* fix syntax error

* Update test_misc.py

* add scroll test

* remove issue 527/528, this is in another PR

* add tests for colorx, fadein, fadeout

* fix: cv2.CV_AA does not exist error in cv2 version 3

* add headblur example, add opencv dependency

* openvcv only supports 2.7 and 3.4+

* add Exception to ImageSequenceClip when sizes do not match

* add test for ImageSequenceClip

* fix test mains

* fix copy error

* add ImageSequenceClip exception test

* add second image to ImageSequenceClip test

* fix incorrect duration calculation when concatenate method=compose

* fix duration issue of masks when using concatenate method=compose

* `concatenate` -> `concatenate_videoclips

`concatenate` is deprecated. Use `concatenate_videoclips instead. https://github.com/Zulko/moviepy/blob/master/moviepy/video/compositing/concatenate.py#L123
  • Loading branch information
bearney74 authored Jul 14, 2017
1 parent d6bc0c6 commit 4d9972e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def set_end(self, t):
of the returned clip.
"""
self.end = t
if self.end is None: return
if self.start is None:
if self.duration is not None:
self.start = max(0, t - newclip.duration)
Expand Down Expand Up @@ -387,7 +388,6 @@ def subclip(self, t_start=0, t_end=None):
t_start = self.duration + t_start #remeber t_start is negative

if (self.duration is not None) and (t_start>self.duration):

raise ValueError("t_start (%.02f) "%t_start +
"should be smaller than the clip's "+
"duration (%.02f)."%self.duration)
Expand Down
2 changes: 1 addition & 1 deletion moviepy/video/compositing/CompositeVideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, clips, size=None, bg_color=None, use_bgclip=False,
# compute mask if necessary
if transparent:
maskclips = [(c.mask if (c.mask is not None) else
c.add_mask().mask).set_pos(c.pos)
c.add_mask().mask).set_pos(c.pos).set_end(c.end).set_start(c.start, change_end=False)
for c in self.clips]

self.mask = CompositeVideoClip(maskclips,self.size, ismask=True,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_TextClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_duration():
return

clip = TextClip('hello world', size=(1280,720), color='white')
clip.set_duration(5)
clip=clip.set_duration(5)
assert clip.duration == 5

clip2 = clip.fx(blink, d_on=1, d_off=1)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ def test_audio_reader():
subclip.write_audiofile(os.path.join(TMP_DIR, 'issue_246.wav'),
write_logfile=True)

def test_issue_547():
red = ColorClip((640, 480), color=(255,0,0)).set_duration(1)
green = ColorClip((640, 480), color=(0,255,0)).set_duration(2)
blue = ColorClip((640, 480), color=(0,0,255)).set_duration(3)

video=concatenate_videoclips([red, green, blue], method="compose")
assert video.duration == 6
assert video.mask.duration == 6

video=concatenate_videoclips([red, green, blue])
assert video.duration == 6


if __name__ == '__main__':
pytest.main()

0 comments on commit 4d9972e

Please sign in to comment.