Skip to content

Commit

Permalink
fix duration issue of masks when using concatenate method=compose
Browse files Browse the repository at this point in the history
  • Loading branch information
bearney74 committed Jun 14, 2017
1 parent 2464e40 commit 416279c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 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 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([red, green, blue], method="compose")
assert video.duration == 6
assert video.mask.duration == 6

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


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

0 comments on commit 416279c

Please sign in to comment.