Skip to content

Video editing with Python

Replaced tabs by spaces

Zulkofa4e2735a3bf
diff --git a/moviepy/version.py b/moviepy/version.py
index b2c5d0b2..a7f8fc50 100644
--- a/moviepy/version.py
+++ b/moviepy/version.py
@@ -1 +1 @@
-__version__ = "0.2.1.7.19"
+__version__ = "0.2.1.7.20"
diff --git a/moviepy/video/compositing/transitions.py b/moviepy/video/compositing/transitions.py
index d81a572f..fd2dcd45 100644
--- a/moviepy/video/compositing/transitions.py
+++ b/moviepy/video/compositing/transitions.py
@@ -11,25 +11,25 @@ from moviepy.video.fx.fadeout import fadeout
@add_mask_if_none
def crossfadein(clip, duration):
- """
- Makes the clip appear progressively, over ``duration`` seconds.
- Only works when the clip is included in a CompositeVideoClip.
- """
- newclip = clip.copy()
- newclip.mask = clip.mask.fx(fadein, duration)
- return newclip
+ """
+ Makes the clip appear progressively, over ``duration`` seconds.
+ Only works when the clip is included in a CompositeVideoClip.
+ """
+ newclip = clip.copy()
+ newclip.mask = clip.mask.fx(fadein, duration)
+ return newclip
@requires_duration
@add_mask_if_none
def crossfadeout(clip, duration):
- """
- Makes the clip disappear progressively, over ``duration`` seconds.
- Only works when the clip is included in a CompositeVideoClip.
- """
- newclip = clip.copy()
- newclip.mask = clip.mask.fx(fadeout, duration)
- return newclip
+ """
+ Makes the clip disappear progressively, over ``duration`` seconds.
+ Only works when the clip is included in a CompositeVideoClip.
+ """
+ newclip = clip.copy()
+ newclip.mask = clip.mask.fx(fadeout, duration)
+ return newclip
diff --git a/moviepy/video/fx/even_size.py b/moviepy/video/fx/even_size.py
index 610d8a7e..adeb636e 100644
--- a/moviepy/video/fx/even_size.py
+++ b/moviepy/video/fx/even_size.py
@@ -16,7 +16,7 @@ def even_size(clip):
if (w%2 != 0) and (h%2!=0):
fl_image = lambda a : a[:-1,:-1,:]
elif (w%2 != 0):
- fl_image = lambda a : a[:,:-1,:]
+ fl_image = lambda a : a[:,:-1,:]
else:
fl_image = lambda a : a[:-1,:,:]
diff --git a/moviepy/video/fx/fadeout.py b/moviepy/video/fx/fadeout.py
index b34bc5c3..4027f62f 100644
--- a/moviepy/video/fx/fadeout.py
+++ b/moviepy/video/fx/fadeout.py
@@ -2,14 +2,14 @@ from moviepy.decorators import requires_duration
@requires_duration
def fadeout(clip, duration):
- """
- Makes the clip fade to black progressively, over ``duration`` seconds.
- For more advanced fading, see ``composition.crossfade``
- """
- fading = lambda t: min(1.0 * (clip.duration - t) / duration, 1)
- return clip.fl(lambda gf, t: fading(t) * gf(t))
+ """
+ Makes the clip fade to black progressively, over ``duration`` seconds.
+ For more advanced fading, see ``composition.crossfade``
+ """
+ fading = lambda t: min(1.0 * (clip.duration - t) / duration, 1)
+ return clip.fl(lambda gf, t: fading(t) * gf(t))
-
+
-
+
diff --git a/moviepy/video/fx/headblur.py b/moviepy/video/fx/headblur.py
index 45a42303..e3377339 100644
--- a/moviepy/video/fx/headblur.py
+++ b/moviepy/video/fx/headblur.py
@@ -24,7 +24,7 @@ def headblur(clip,fx,fy,r_zone,r_blur=None):
if r_blur==None: r_blur = 2*r_zone/3
def fl(gf,t):
-
+
im = gf(t)
h,w,d = im.shape
x,y = int(fx(t)),int(fy(t))
diff --git a/moviepy/video/fx/margin.py b/moviepy/video/fx/margin.py
index 4a45165d..4a10a8f7 100644
--- a/moviepy/video/fx/margin.py
+++ b/moviepy/video/fx/margin.py
@@ -32,7 +32,9 @@ def margin(clip, mar=None, left=0, right=0, top=0,
new_w, new_h = w + left + right, h + top + bottom
if clip.ismask:
shape = (new_h, new_w)
- bg = np.tile(opacity, (new_h, new_w)).reshape(shape)
+ bg = ( np.tile(opacity, (new_h, new_w))
+ .astype(float)
+ .reshape(shape))
else:
shape = (new_h, new_w, 3)
bg = np.tile(color, (new_h, new_w)).reshape(shape)
diff --git a/moviepy/video/fx/mirror_x.py b/moviepy/video/fx/mirror_x.py
index 5dab6966..2a1daebc 100644
--- a/moviepy/video/fx/mirror_x.py
+++ b/moviepy/video/fx/mirror_x.py
@@ -1,5 +1,5 @@
def mirror_x(clip, apply_to= "mask"):
- """ flips the clip horizontally (and its mask too, by default) """
- return clip.fl_image(lambda gf, t: gf(t)[:,::-1],
+ """ flips the clip horizontally (and its mask too, by default) """
+ return clip.fl_image(lambda gf, t: gf(t)[:,::-1],
apply_to = apply_to)
diff --git a/moviepy/video/fx/mirror_y.py b/moviepy/video/fx/mirror_y.py
index fe714bfb..db205423 100644
--- a/moviepy/video/fx/mirror_y.py
+++ b/moviepy/video/fx/mirror_y.py
@@ -1,4 +1,4 @@
def mirror_y(clip, apply_to= "mask"):
- """ flips the clip vertically (and its mask too, by default) """
- return clip.fl_image(lambda gf, t : gf(t)[::-1],
+ """ flips the clip vertically (and its mask too, by default) """
+ return clip.fl_image(lambda gf, t : gf(t)[::-1],
apply_to = apply_to)
diff --git a/moviepy/video/fx/scroll.py b/moviepy/video/fx/scroll.py
index 66ef5935..51e20abd 100644
--- a/moviepy/video/fx/scroll.py
+++ b/moviepy/video/fx/scroll.py
@@ -1,12 +1,12 @@
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
- credits """
- if h is None: h = clip.h
- if w is None: w = clip.w
- def f(gf,t):
- x = x_start+int(x_speed*t)
- y = y_start+ int(y_speed*t)
- return gf(t)[y:y+h, x:x+w]
- return clip.fl(f, apply_to = apply_to)
+ """ Scrolls horizontally or vertically a clip, e.g. to make end
+ credits """
+ if h is None: h = clip.h
+ if w is None: w = clip.w
+ def f(gf,t):
+ x = x_start+int(x_speed*t)
+ y = y_start+ int(y_speed*t)
+ return gf(t)[y:y+h, x:x+w]
+ return clip.fl(f, apply_to = apply_to)
diff --git a/moviepy/video/fx/time_mirror.py b/moviepy/video/fx/time_mirror.py
index ed53dad4..0e3da230 100644
--- a/moviepy/video/fx/time_mirror.py
+++ b/moviepy/video/fx/time_mirror.py
@@ -6,9 +6,9 @@ from moviepy.decorators import (apply_to_mask, apply_to_audio,
@apply_to_mask
@apply_to_audio
def time_mirror(self):
- """
- Returns a clip that plays the current clip backwards.
- The clip must have its ``duration`` attribute set.
- The same effect is applied to the clip's audio and mask if any.
- """
- return self.fl_time(lambda t: self.duration - t, keep_duration=True)
+ """
+ Returns a clip that plays the current clip backwards.
+ The clip must have its ``duration`` attribute set.
+ The same effect is applied to the clip's audio and mask if any.
+ """
+ return self.fl_time(lambda t: self.duration - t, keep_duration=True)
diff --git a/moviepy/video/io/sliders.py b/moviepy/video/io/sliders.py
index 0c35b7a1..39121031 100644
--- a/moviepy/video/io/sliders.py
+++ b/moviepy/video/io/sliders.py
@@ -7,9 +7,9 @@ def sliders(f, sliders_properties, wait_for_validation = False):
slider_properties is a list of dicts (arguments for Slider )
def volume(x,y,z):
- return x*y*z
+ return x*y*z
- intervals = [ { 'label' : 'width', 'valmin': 1 , 'valmax': 5 },
+ intervals = [ { 'label' : 'width', 'valmin': 1 , 'valmax': 5 },
{ 'label' : 'height', 'valmin': 1 , 'valmax': 5 },
{ 'label' : 'depth', 'valmin': 1 , 'valmax': 5 } ]
inputExplorer(volume,intervals)
diff --git a/moviepy/video/tools/tracking.py b/moviepy/video/tools/tracking.py
index e287fff3..edc90c9b 100644
--- a/moviepy/video/tools/tracking.py
+++ b/moviepy/video/tools/tracking.py
@@ -13,11 +13,11 @@ from scipy.interpolate import interp1d
from moviepy.video.io.preview import imdisplay
try:
- import cv2
+ import cv2
except:
- # Note: this will be later fixed with scipy/skimage replacements
- # but for the moment OpenCV is mandatory, so...
- print "WARNING: OpenCV not found: automated tracking not possible"
+ # Note: this will be later fixed with scipy/skimage replacements
+ # but for the moment OpenCV is mandatory, so...
+ print "WARNING: OpenCV not found: automated tracking not possible"
@@ -168,8 +168,8 @@ def autoTrack(clip, pattern, tt=None, fps=None, radius=20, xy0=None):
xy0 = findAround(clip.get_frame(tt[0]),pattern)
if tt is None:
- tt = np.arange(0, clip.duration, 1.0/fps)
-
+ tt = np.arange(0, clip.duration, 1.0/fps)
+
xys = [xy0]
for t in tt[1:]:
xys.append( findAround(clip.get_frame(t),pattern,