Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ImageSequenceClip image size exception #550

Merged
29 commits merged into from Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b035660
add scipy for py2.7 on travis-ci
bearney74 Mar 14, 2017
1426eb2
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Mar 14, 2017
26ab7dc
add tests for ffmeg_parse_infos
bearney74 Mar 15, 2017
24f3f47
put communicate back in
bearney74 Mar 15, 2017
4f9709d
fix syntax error
bearney74 Mar 15, 2017
2e9f460
Update test_misc.py
bearney74 Mar 15, 2017
2c70ab2
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Mar 15, 2017
29089b2
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Mar 30, 2017
f54556c
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Mar 31, 2017
8eb6d9b
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 4, 2017
b2ff5fd
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 5, 2017
6e93d02
add scroll test
bearney74 Apr 7, 2017
478f44d
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 10, 2017
745030b
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 12, 2017
852466d
remove issue 527/528, this is in another PR
bearney74 Apr 12, 2017
a787a3d
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 12, 2017
bd49aa9
add tests for colorx, fadein, fadeout
bearney74 Apr 12, 2017
fce552c
fix: cv2.CV_AA does not exist error in cv2 version 3
bearney74 Apr 12, 2017
51ea1f4
add headblur example, add opencv dependency
bearney74 Apr 12, 2017
f8c488f
openvcv only supports 2.7 and 3.4+
bearney74 Apr 12, 2017
878101f
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 13, 2017
57b50dd
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 17, 2017
de83bb6
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 19, 2017
f210c1e
add Exception to ImageSequenceClip when sizes do not match
bearney74 Apr 19, 2017
90fe625
add test for ImageSequenceClip
bearney74 Apr 19, 2017
a712102
Merge branch 'master' of github.com:Zulko/moviepy
bearney74 Apr 19, 2017
26ac231
fix test mains
bearney74 Apr 19, 2017
9838451
fix copy error
bearney74 Apr 19, 2017
47cf9ec
add ImageSequenceClip exception test
bearney74 Apr 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions moviepy/video/io/ImageSequenceClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ def __init__(self, sequence, fps=None, durations=None, with_mask=True,
sequence = sorted([os.path.join(sequence, f)
for f in os.listdir(sequence)])


#check that all the images are of the same size
if isinstance(sequence[0], str):
size = imread(sequence[0]).shape
else:
size = sequence[0].shape

for image in sequence:
image1=image
if isinstance(image, str):
image1=imread(image)
if size != image1.shape:
raise Exception("Moviepy: ImageSequenceClip requires all images to be the same size")


self.fps = fps
if fps is not None:
durations = [1.0/fps for image in sequence]
Expand Down
18 changes: 17 additions & 1 deletion tests/test_ImageSequenceClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,31 @@ def test_download_media(capsys):
def test_1():
images=[]
durations=[]

for i in range(5):
durations.append(i)
images.append("media/python_logo.png")
durations.append(i)
images.append("media/matplotlib_demo1.png")
images.append("media/python_logo.png")
#images.append("media/matplotlib_demo1.png")

clip = ImageSequenceClip(images, durations=durations)
assert clip.duration == sum(durations)
clip.write_videofile("/tmp/ImageSequenceClip1.mp4", fps=30)

def test_2():
images=[]
durations=[]

durations.append(1)
images.append("media/python_logo.png")
durations.append(2)
images.append("media/matplotlib_demo1.png")

#images are not the same size..
with pytest.raises(Exception, message='Expecting Exception'):
ImageSequenceClip(images, durations=durations)


if __name__ == '__main__':
pytest.main()
21 changes: 12 additions & 9 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def test_issue_145():
with pytest.raises(Exception, message='Expecting Exception'):
concatenate_videoclips([video], method='composite')

def test_issue_190():
#from PIL import Image
#Image.new('L', (800,600), 'white').save(os.path.join(TMP_DIR, "issue_190.png"))

#from imageio import imread
#image = imread(os.path.join(TMP_DIR, "issue_190.png"))

#clip = ImageSequenceClip([image, image], fps=1)
#clip.write_videofile(os.path.join(TMP_DIR, "issue_190.mp4"))
pass

def test_issue_285():

clip_1, clip_2, clip_3 = ImageClip('media/python_logo.png', duration=10), \
Expand Down Expand Up @@ -227,15 +238,6 @@ def test_issue_417():
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 Expand Up @@ -263,5 +265,6 @@ def test_audio_reader():
subclip.write_audiofile(os.path.join(TMP_DIR, 'issue_246.wav'),
write_logfile=True)


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