diff --git a/moviepy/video/fx/scroll.py b/moviepy/video/fx/scroll.py index 59a285c91..34f4f4012 100644 --- a/moviepy/video/fx/scroll.py +++ b/moviepy/video/fx/scroll.py @@ -1,5 +1,3 @@ -import numpy as np - def scroll(clip, h=None, w=None, x_speed=0, y_speed=0, x_start=0, y_start=0, apply_to="mask"): """ Scrolls horizontally or vertically a clip, e.g. to make end @@ -11,8 +9,8 @@ def scroll(clip, h=None, w=None, x_speed=0, y_speed=0, ymax = clip.h-h-1 def f(gf,t): - x = max(0, min(xmax, x_start+ np.round(x_speed*t))) - y = max(0, min(ymax, y_start+ np.round(y_speed*t))) + x = int(max(0, min(xmax, x_start+ round(x_speed*t)))) + y = int(max(0, min(ymax, y_start+ round(y_speed*t)))) return gf(t)[y:y+h, x:x+w] return clip.fl(f, apply_to = apply_to) diff --git a/tests/download_media.py b/tests/download_media.py index 5d735ba2c..0cc75d291 100644 --- a/tests/download_media.py +++ b/tests/download_media.py @@ -48,4 +48,6 @@ def download(): download_url("https://raw.githubusercontent.com/earney/moviepy_media/master/tests/misc/traj.txt", "media/traj.txt") - + + download_url("https://github.com/earney/moviepy_media/raw/master/tests/images/vacation_2017.jpg", + "media/vacation_2017.jpg") \ No newline at end of file diff --git a/tests/test_PR.py b/tests/test_PR.py index 790c65c42..aba1c3e5b 100644 --- a/tests/test_PR.py +++ b/tests/test_PR.py @@ -89,9 +89,19 @@ def test_PR_515(): clip = VideoFileClip("media/fire2.mp4", fps_source='fps') assert clip.fps == 10.51 + +def test_PR_528(): + clip = ImageClip("media/vacation_2017.jpg") + new_clip = vfx.scroll(clip, w=1000, x_speed=50) + new_clip = new_clip.set_duration(20) + new_clip.fps = 24 + new_clip.write_videofile(os.path.join(TMP_DIR, "pano.mp4")) + + def test_PR_529(): video_clip = VideoFileClip("media/fire2.mp4") assert video_clip.rotation ==180 + if __name__ == '__main__': pytest.main()