Skip to content

Video editing with Python

fixed bug in subclip with negative t. Added 'even_size' effect. Now version 0.2.1.7.15

Zulko4eb6adfbe13a
diff --git a/moviepy/Clip.py b/moviepy/Clip.py
index 78cc33c7..ca09a25d 100644
--- a/moviepy/Clip.py
+++ b/moviepy/Clip.py
@@ -326,7 +326,8 @@ class Clip:
subclips of ``mask`` and ``audio`` the original clip, if
they exist.
"""
-
+
+
newclip = self.fl_time(lambda t: t + ta, apply_to=[])
if (tb is None) and (self.duration != None):
tb = self.duration
@@ -335,7 +336,7 @@ class Clip:
print ("Error: subclip with negative times can only be"+
"be taken from clips with a ``duration``")
else:
- tb = self.duration - tb
+ tb = self.duration + tb
if (tb is not None):
newclip.duration = tb - ta
newclip.end = newclip.start + newclip.duration
diff --git a/moviepy/version.py b/moviepy/version.py
index f5bb1800..36467e14 100644
--- a/moviepy/version.py
+++ b/moviepy/version.py
@@ -1 +1 @@
-__version__ = '0.2.1.7.14'
+__version__ = '0.2.1.7.15'
diff --git a/moviepy/video/fx/even_size.py b/moviepy/video/fx/even_size.py
new file mode 100644
index 00000000..610d8a7e
--- /dev/null
+++ b/moviepy/video/fx/even_size.py
@@ -0,0 +1,25 @@
+import numpy as np
+
+from moviepy.decorators import apply_to_mask
+
+@apply_to_mask
+def even_size(clip):
+ """ Crops the clip to make dimensions even.
+
+ """
+
+ w,h = clip.size
+
+ if (w%2 == 0) and (h%2==0):
+ return 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,:]
+ else:
+ fl_image = lambda a : a[:-1,:,:]
+
+ return clip.fl_image(fl_image)
+
+