Skip to content

Commit

Permalink
Merge pull request #528 from Gloin1313/scroll_fix
Browse files Browse the repository at this point in the history
Fixed `scroll` compatability with numpy 1.12
  • Loading branch information
Gloin1313 committed Apr 14, 2017
2 parents d41a40e + 9e9a9c8 commit a25768a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 2 additions & 4 deletions moviepy/video/fx/scroll.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
4 changes: 3 additions & 1 deletion tests/download_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
10 changes: 10 additions & 0 deletions tests/test_PR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit a25768a

Please sign in to comment.