Skip to content

Video editing with Python

add testing to verify the width,height (size) are correct. (#459)

Billy Earney6530f5b72ddb
diff --git a/moviepy/Clip.py b/moviepy/Clip.py
index fade174a..efc1ecc8 100644
--- a/moviepy/Clip.py
+++ b/moviepy/Clip.py
@@ -471,25 +471,16 @@ class Clip:
"""
def generator():
-
for t in np.arange(0, self.duration, 1.0/fps):
-
frame = self.get_frame(t)
-
if (dtype is not None) and (frame.dtype != dtype):
-
frame = frame.astype(dtype)
-
if with_times:
-
yield t, frame
-
else:
-
yield frame
if progress_bar:
-
nframes = int(self.duration*fps)+1
return tqdm(generator(), total=nframes)
diff --git a/tests/download_media.py b/tests/download_media.py
index 7a81445f..512cc8f2 100644
--- a/tests/download_media.py
+++ b/tests/download_media.py
@@ -22,3 +22,6 @@ def download():
download_url("http://matplotlib.org/_images/barh_demo.png",
"media/matplotlib_demo1.png")
+
+ download_url("https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Afterimagenpov.svg/1200px-Afterimagenpov.svg.png",
+ "media/afterimage.png")
diff --git a/tests/test_issues.py b/tests/test_issues.py
index 1e767988..bb76efe6 100644
--- a/tests/test_issues.py
+++ b/tests/test_issues.py
@@ -24,12 +24,25 @@ def test_issue_145():
def test_issue_407():
red = ColorClip((800, 600), color=(255,0,0)).set_duration(5)
red.fps=30
- assert round(red.fps) == 30
+ assert red.fps == 30
+ assert red.w == 800
+ assert red.h == 600
+ assert red.size == (800, 600)
#ColorClip has no fps attribute
green=ColorClip((640, 480), color=(0,255,0)).set_duration(2)
blue=ColorClip((640, 480), color=(0,0,255)).set_duration(2)
+ assert green.w == blue.w == 640
+ assert green.h == blue.h == 480
+ assert green.size == blue.size == (640, 480)
+
+ with pytest.raises(AttributeError, message="Expecting ValueError Exception"):
+ green.fps
+
+ with pytest.raises(AttributeError, message="Expecting ValueError Exception"):
+ blue.fps
+
video=concatenate_videoclips([red, green, blue])
assert video.fps == red.fps