Skip to content

Video editing with Python

Fixes use of to_ImageClip in on_color

Zulko76e1a280ff1d
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 5930ccae..a85362fd 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -759,14 +759,14 @@ class VideoClip(Clip):
result = CompositeVideoClip([colorclip, self.set_pos(pos)],
transparent=(col_opacity is not None))
- if isinstance(self, ImageClip):
+ if (isinstance(self, ImageClip) and (not hasattr(pos, "__call__"))
+ and ((self.mask is None) or isinstance(self.mask, ImageClip))):
new_result = result.to_ImageClip()
if result.mask is not None:
- new_result.mask = result.mask.to_ImageClip()
- return new_result
+ new_result.mask = result.mask.to_ImageClip()
+ return new_result.set_duration(result.duration)
- else:
- return result
+ return result
diff --git a/moviepy/video/tools/interpolators.py b/moviepy/video/tools/interpolators.py
index 4aca21a4..482fb628 100644
--- a/moviepy/video/tools/interpolators.py
+++ b/moviepy/video/tools/interpolators.py
@@ -8,7 +8,10 @@ import numpy as np
class Interpolator:
""" Poorman's linear interpolator, doesn't require Scipy. """
- def __init__(self, tt, ss, left=None, right=None):
+ def __init__(self, tt=None, ss=None, ttss = None, left=None, right=None):
+
+ if ttss is not None:
+ tt, ss = zip(*ttss)
self.tt = 1.0*np.array(tt)
self.ss = 1.0*np.array(ss)
@@ -26,8 +29,6 @@ class Interpolator:
s1, s2 = self.ss[ind], self.ss[ind+1]
return s1 + (s2-s1)*(t-t1)/(t2-t1)
-
-
class Trajectory:
def __init__(self, tt, xx, yy):