Skip to content

Commit

Permalink
Fix issue #464, repeated/skipped frames in ImageSequenceClip (#494)
Browse files Browse the repository at this point in the history
* Fix issue 464, repeated/skipped frames in ImageSequenceClip

* Add test for issue #464, repeated/skipped frames of ImageSequenceClip
  • Loading branch information
neitzal authored and bearney74 committed Apr 19, 2017
1 parent c6e3a22 commit 167db9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion moviepy/video/io/ImageSequenceClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def __init__(self, sequence, fps=None, durations=None, with_mask=True,
self.fps = fps
if fps is not None:
durations = [1.0/fps for image in sequence]
self.images_starts = [1.0*i/fps-np.finfo(np.float32).eps for i in range(len(sequence))]
else:
self.images_starts = [0]+list(np.cumsum(durations))
self.durations = durations
self.images_starts = [0]+list(np.cumsum(durations))
self.duration = sum(durations)
self.end = self.duration
self.sequence = sequence
Expand Down
9 changes: 9 additions & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ def test_issue_417():
final = CompositeVideoClip([myclip], size=(1280, 720))
#final.set_duration(7).write_videofile("test.mp4", fps=30)

def test_issue_464():
import numpy as np
original_frames = [i*np.ones((32, 32, 3), dtype=np.uint8) for i in range(50)]
clip = ImageSequenceClip(original_frames, fps=30)
for original_frame, clip_frame in zip(original_frames, clip.iter_frames()):
# The retrieved frames should be equal to the original ones
# Since the frames are constant color, it suffices to compare one pixel
assert original_frame[0,0,0] == clip_frame[0,0,0]

def test_issue_467():
cad = 'media/python_logo.png'
clip = ImageClip(cad)
Expand Down

0 comments on commit 167db9f

Please sign in to comment.