Skip to content

Commit

Permalink
fix issue Zulko#334
Browse files Browse the repository at this point in the history
fix resize video when time changed trigger a error
  • Loading branch information
bluedazzle committed Oct 15, 2016
1 parent d4c9c37 commit f860f07
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,24 @@ def fl_image(self, image_func, apply_to=[]):
# C O M P O S I T I N G


def fill_array(self, pre_array, shape=(0, 0)):
pre_shape = pre_array.shape
dx = shape[0] - pre_shape[0]
dy = shape[1] - pre_shape[1]
post_array = pre_array
if dx < 0:
post_array = pre_array[:shape[0]]
elif dx > 0:
x_1 = [[[1, 1, 1]] * pre_shape[1]] * dx
post_array = np.vstack((pre_array, x_1))
if dy < 0:
post_array = post_array[:, :shape[1]]
elif dy > 0:
x_1 = [[[1, 1, 1]] * dy] * post_array.shape[0]
post_array = np.hstack((post_array, x_1))
return post_array


def blit_on(self, picture, t):
"""
Returns the result of the blit of the clip's frame at time `t`
Expand All @@ -535,6 +553,9 @@ def blit_on(self, picture, t):
img = self.get_frame(ct)
mask = (None if (self.mask is None) else
self.mask.get_frame(ct))
if mask is not None:
if (img.shape[0] != mask.shape[0]) or (img.shape[1] != mask.shape[1]):
img = self.fill_array(img, mask.shape)
hi, wi = img.shape[:2]

# SET POSITION
Expand Down

0 comments on commit f860f07

Please sign in to comment.