Video editing with Python
Misc. changes. Added use_clip_fps_by_default. Changed ImageSequenceClip
Zulkoa92de2861dfb
diff --git a/README.rst b/README.rstindex 596d8689..dbd7650c 100644--- a/README.rst+++ b/README.rst@@ -37,7 +37,7 @@ Installation(sudo) pip install moviepy-This method may fail if ``ez_setup`` is not installed on your computer. In this case install ``ez_setup`` first, with ::+This method will fail if ``ez_setup`` is not installed on your computer. In this case install ``ez_setup`` first, with ::(sudo) pip install ez_setupdiff --git a/docs/examples/quick_recipes.rst b/docs/examples/quick_recipes.rstnew file mode 100644index 00000000..7d612e0c--- /dev/null+++ b/docs/examples/quick_recipes.rst@@ -0,0 +1,22 @@+Quick recipes+===============++++Add a title before a video+---------------------------++++Videos++++Make gifs that loop well+--------------------------++ clip.fx( vfx.time_symmetrize)+++ # find a subclip+ T = clipdiff --git a/docs/getting_started/quick_presentation.rst b/docs/getting_started/quick_presentation.rstindex f315c5a9..871a1219 100644--- a/docs/getting_started/quick_presentation.rst+++ b/docs/getting_started/quick_presentation.rst@@ -16,6 +16,11 @@ Here are a few reasons why you may want to edit videos in Python:- You want to code your own video effects to do something no existing video editor can.- You want to create animations from images generated by another python library (Matplotlib, Mayavi, Gizeh, scikit-images...)+And here are a few uses for which MoviePy is NOT the best solution:+- You only need to do frame-by-frame video analysis (with face detection or other fancy stuff). This could be done with MoviePy in association with other libraries, but really, just use OpenCV or SimpleCV, these are libraries that specialize in these tasks.+- You only want to convert a video, or convert a series of images to a movie. In this case it is better to directly call ``ffmpeg`` (or ``avconv`` or ``mencoder``...) it will be faster more memory-efficient than going through MoviePy.++Advantages and limitations~~~~~~~~~~~~~~~~~~~~~~~~~~~@@ -25,8 +30,7 @@ MoviePy has been developed with the following goals in mind:- **Flexible**. You have total control over the frames of the video and audio, and creating your own effects is easy as Py.- **Portable**. The code uses very common software (Numpy and FFMPEG) and can run on (almost) any machine with (almost) any version of Python.-Now for the limitations: MoviePy cannot (yet) stream videos (read from a webcam, or render a video live on a distant machine), it cannot do 3D effects (by lack of a nice 3D library for Python) and is not really designed for video processing involving many successive frames of a movie (like video stabilization, you'll need another software for that). Also, if you only need to do frame-by-frame video analysis (with face detection or other fancy stuff) you may want to use the libraries OpenCV and SimpleCV instead.-+Now for the main limitations: MoviePy cannot (yet) stream videos (read from a webcam, or render a video live on a distant machine), it cannot do 3D effects (by lack of a nice 3D library for Python) and is not really designed for video processing involving many successive frames of a movie (like video stabilization, you'll need another software for that).Example code~~~~~~~~~~~~~~diff --git a/moviepy/Clip.py b/moviepy/Clip.pyindex 4d9393cb..13e06950 100644--- a/moviepy/Clip.py+++ b/moviepy/Clip.py@@ -11,7 +11,8 @@ from moviepy.decorators import ( apply_to_mask,apply_to_audio,requires_duration,outplace,- convert_to_seconds)+ convert_to_seconds,+ use_clip_fps_by_default)from tqdm import tqdmclass Clip:@@ -68,17 +69,19 @@ class Clip:newclip.mask = copy(self.mask)return newclip-++ @convert_to_seconds(['t'])def get_frame(self, t):"""- Gets a numpy array representing the RGB picture of the clip at time t.+ Gets a numpy array representing the RGB picture of the clip at time t+ or (mono or stereo) value for a sound clip"""# Coming soon: smart error handling for debugging at this pointreturn self.make_frame(t)def fl(self, fun, apply_to=[] , keep_duration=True):""" General processing of a clip.-+Returns a new Clip whose frames are a transformation(through function ``fun``) of the frames of the current clip.@@ -276,12 +279,18 @@ class Clip:@outplace- def set_make_frame(self, gf):+ def set_make_frame(self, make_frame):"""Sets a ``make_frame`` attribute for the clip. Useful for settingarbitrary/complicated videoclips."""- self.make_frame = gf+ self.make_frame = make_frame++ @outplace+ def set_fps(self, fps):+ """ Returns a copy of the clip with a new default fps for functions like+ write_videofile, iterframe, etc. """+ self.fps = fps@@ -318,6 +327,8 @@ class Clip:return( (t >= self.start) and((self.end is None) or (t < self.end) ) )++@convert_to_seconds(['t_start', 't_end'])@apply_to_mask@apply_to_audio@@ -362,8 +373,7 @@ class Clip:newclip.end = newclip.start + newclip.durationreturn newclip--+@apply_to_mask@apply_to_audio@@ -390,6 +400,7 @@ class Clip:return newclip@requires_duration+ @use_clip_fps_by_defaultdef iter_frames(self, fps=None, with_times = False, progress_bar=False,dtype=None):""" Iterates over all the frames of the clip.@@ -416,9 +427,6 @@ class Clip:>>> print ( [frame[0,:,0].max()for frame in myclip.iter_frames()])"""-- if fps is None:- fps = self.fpsdef generator():for t in np.arange(0, self.duration, 1.0/fps):diff --git a/moviepy/config.py b/moviepy/config.pyindex edea934d..81bd5424 100644--- a/moviepy/config.py+++ b/moviepy/config.py@@ -9,9 +9,11 @@ from .config_defaults import (FFMPEG_BINARY, IMAGEMAGICK_BINARY)def try_cmd(cmd):try:- popen_params = {"stdout": sp.PIPE,- "stderr": sp.PIPE,- "stdin": DEVNULL}+ popen_params = { "stdout": sp.PIPE,+ "stderr": sp.PIPE,+ "stdin": DEVNULL+ }+# This was added so that no extra unwanted window opens on windows# when the child process is created@@ -35,9 +37,10 @@ if FFMPEG_BINARY=='auto-detect':else:FFMPEG_BINARY = 'unset'else:- success, err = try_cmd(cmd)+ success, err = try_cmd([FFMPEG_BINARY])if not success:- raise err+ raise IOError(err.message ++ "The path specified for the ffmpeg binary might be wrong")if IMAGEMAGICK_BINARY=='auto-detect':diff --git a/moviepy/decorators.py b/moviepy/decorators.pyindex 0224b8bf..c78b83e8 100644--- a/moviepy/decorators.py+++ b/moviepy/decorators.py@@ -80,7 +80,7 @@ def preprocess_args(fun,varnames):func_code = f.__code__ # Python 3names = func_code.co_varnames- new_a = [cvsecs(arg) if (name in varnames) else arg+ new_a = [fun(arg) if (name in varnames) else argfor (arg, name) in zip(a, names)]new_kw = {k: fun(v) if k in varnames else vfor (k,v) in kw.items()}@@ -99,4 +99,36 @@ def add_mask_if_none(f, clip, *a, **k):""" Add a mask to the clip if there is none. """if clip.mask is None:clip = clip.add_mask()- return f(clip, *a, **k)\ No newline at end of file+ return f(clip, *a, **k)++++def use_clip_fps_by_default(f, clip, *a, **k):++ def fun(fps):+ if fps is not None:+ return fps+ else:+ if hasattr(clip, 'fps') and clip.fps is not None:+ return clip.fps+ else:+ raise AttributeError("No 'fps' (frames per second) attribute specified"+ " for function %s and the clip has no 'fps' attribute. Either"+ " provide e.g. fps=24 in the arguments of the function, or define"+ " the clip's fps with `clip.fps=24`"%f.__name__)+++ if hasattr(f, "func_code"):+ func_code = f.func_code # Python 2+ else:+ func_code = f.__code__ # Python 3++ names = func_code.co_varnames[1:]++ new_a = [fun(arg) if (name=='fps') else arg+ for (arg, name) in zip(a, names)]+ new_kw = {k: fun(v) if k=='fps' else v+ for (k,v) in k.items()}++ return f(clip, *new_a, **new_kw)diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex b5e5c040..08a7e037 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -34,7 +34,8 @@ from ..decorators import (apply_to_mask,outplace,add_mask_if_none,convert_to_seconds,- convert_masks_to_RGB)+ convert_masks_to_RGB,+ use_clip_fps_by_default)import ostry:@@ -144,8 +145,9 @@ class VideoClip(Clip):@requires_duration+ @use_clip_fps_by_default@convert_masks_to_RGB- def write_videofile(self, filename, fps=24, codec=None,+ def write_videofile(self, filename, fps=None, codec=None,bitrate=None, audio=True, audio_fps=44100,preset="medium",audio_nbytes=4, audio_codec=None,@@ -166,7 +168,8 @@ class VideoClip(Clip):or simply be '.avi' (which will work with any codec).fps- Number of frames per second in the resulting video file.+ Number of frames per second in the resulting video file. If None is+ provided, and the clip has an fps attribute, this fps will be used.codecCodec to use for image encoding. Can be any codec supported@@ -338,6 +341,7 @@ class VideoClip(Clip):@requires_duration+ @use_clip_fps_by_default@convert_masks_to_RGBdef write_images_sequence(self, nameformat, fps=None, verbose=True,withmask=True):@@ -381,9 +385,6 @@ class VideoClip(Clip):verbose_print(verbose, "MoviePy: Writing frames %s." % (nameformat))- if fps is None:- fps = self.fps-tt = np.arange(0, self.duration, 1.0 / fps)filenames = []@@ -894,7 +895,7 @@ class ImageClip(VideoClip):(see Clip.fl_time).This method does nothing for ImageClips (but it may affect their- masks of their audios). The result is still an ImageClip.+ masks or their audios). The result is still an ImageClip."""for attr in apply_to:diff --git a/moviepy/video/fx/accel_decel.py b/moviepy/video/fx/accel_decel.pynew file mode 100644index 00000000..a7c413ca--- /dev/null+++ b/moviepy/video/fx/accel_decel.py@@ -0,0 +1,44 @@+def f_accel_decel(t, old_d, new_d, abruptness=1, soonness=1.0):+ """+ abruptness+ negative abruptness (>-1): speed up down up+ zero abruptness : no effect+ positive abruptness: speed down up down++ soonness+ for positive abruptness, determines how soon the+ speedup occurs (0<soonness < inf)+ """++ a = 1.0+abruptness+ def _f(t):+ f1 = lambda t: (0.5)**(1-a)*(t**a)+ f2 = lambda t: (1-f1(1-t))+ return (t<.5)*f1(t) + (t>=.5)*f2(t)++ return old_d*_f((t/new_d)**soonness)+++def accel_decel(clip, new_duration=None, abruptness=1.0, soonness=1.0):+ """++ new_duration+ If None, will be that of the current clip.++ abruptness+ negative abruptness (>-1): speed up down up+ zero abruptness : no effect+ positive abruptness: speed down up down++ soonness+ for positive abruptness, determines how soon the+ speedup occurs (0<soonness < inf)+ """++ if new_duration is None:+ new_duration = clip.duration++ fl = lambda t : f_accel_decel(t, clip.duration, new_duration,+ abruptness, soonness)++ return clip.fl_time(fl).set_duration(new_duration)\ No newline at end of filediff --git a/moviepy/video/fx/fadein.py b/moviepy/video/fx/fadein.pyindex 09139f84..bfd270a8 100644--- a/moviepy/video/fx/fadein.py+++ b/moviepy/video/fx/fadein.py@@ -1,7 +1,24 @@--def fadein(clip, duration):- """ Makes the clip fade to black progressively, over ``duration``- seconds. For more advanced fading, see- ``moviepy.video.composition.crossfadein`` """+import numpy as np++def fadein(clip, duration, initial_color=None):+ """+ Makes the clip progressively appear from some color (black by default),+ over ``duration`` seconds at the beginning of the clip. Can be used for+ masks too, where the initial color must be a number between 0 and 1.+ For cross-fading (progressive appearance or disappearance of a clip+ over another clip, see ``composition.crossfade``+ """++ if initial_color is None:+ initial_color = 0 if clip.ismask else [0,0,0]- return clip.fl(lambda gf, t: min(1.0 * t / duration, 1) * gf(t))+ initial_color = np.array(initial_color)++ def fl(gf, t):+ if t>=duration:+ return gf(t)+ else:+ fading = (1.0*t/duration)+ return fading*gf(t) + (1-fading)*initial_color++ return clip.fl(fl)\ No newline at end of filediff --git a/moviepy/video/fx/fadeout.py b/moviepy/video/fx/fadeout.pyindex 4027f62f..68f31dda 100644--- a/moviepy/video/fx/fadeout.py+++ b/moviepy/video/fx/fadeout.py@@ -1,14 +1,29 @@from moviepy.decorators import requires_duration+import numpy as np@requires_duration-def fadeout(clip, duration):+def fadeout(clip, duration, final_color=None):"""- Makes the clip fade to black progressively, over ``duration`` seconds.- For more advanced fading, see ``composition.crossfade``+ Makes the clip progressively fade to some color (black by default),+ over ``duration`` seconds at the end of the clip. Can be used for+ masks too, where the final color must be a number between 0 and 1.+ For cross-fading (progressive appearance or disappearance of a clip+ over another clip, see ``composition.crossfade``"""- fading = lambda t: min(1.0 * (clip.duration - t) / duration, 1)- return clip.fl(lambda gf, t: fading(t) * gf(t))++ if final_color is None:+ final_color = 0 if clip.ismask else [0,0,0]++ final_color = np.array(final_color)++ def fl(gf, t):+ if (clip.duration-t)>=duration:+ return gf(t)+ else:+ fading = 1.0 * (clip.duration - t) / duration+ return fading*gf(t) + (1-fading)*final_color+ return clip.fl(fl)diff --git a/moviepy/video/fx/lum_contrast.py b/moviepy/video/fx/lum_contrast.pyindex 992b420e..a1ae55cf 100644--- a/moviepy/video/fx/lum_contrast.py+++ b/moviepy/video/fx/lum_contrast.py@@ -3,7 +3,7 @@ def lum_contrast(clip, lum = 0, contrast=0, contrast_thr=127):def fl_image(im):im = 1.0*im # float conversion- corrected = im + lum + factor*(im-thr)+ corrected = im + lum + contrast*(im-float(contrast_thr))corrected[corrected < 0] = 0corrected[corrected > 255] = 255return corrected.astype('uint8')diff --git a/moviepy/video/fx/supersample.py b/moviepy/video/fx/supersample.pynew file mode 100644index 00000000..5c7162b5--- /dev/null+++ b/moviepy/video/fx/supersample.py@@ -0,0 +1,12 @@+import numpy as np++def supersample(clip, d, nframes):+ """ Replaces each frame at time t by the mean of `nframes` equally spaced frames+ taken in the interval [t-d, t+d]. This results in motion blur."""++ def fl(gf, t):+ tt = np.linspace(t-d, t+d, nframes)+ avg = np.mean(1.0*np.array([gf(t_) for t_ in tt], dtype='uint16'), axis=0)+ return avg.astype("uint8")++ return clip.fl(fl)\ No newline at end of filediff --git a/moviepy/video/io/ImageSequenceClip.py b/moviepy/video/io/ImageSequenceClip.pyindex ee6101cd..86cb17a9 100644--- a/moviepy/video/io/ImageSequenceClip.py+++ b/moviepy/video/io/ImageSequenceClip.py@@ -1,6 +1,9 @@+import os+import numpy as np+from ..VideoClip import VideoClipfrom .ffmpeg_reader import ffmpeg_read_image-import os+class ImageSequenceClip(VideoClip):"""@@ -15,13 +18,17 @@ class ImageSequenceClip(VideoClip):Can be one of these:- The name of a folder (containing only pictures). The pictureswill be considered in alphanumerical order.- - A list of names of image files.+ - A list of names of image files. In this case you can choose to+ load the pictures in memory pictures- A list of Numpy arrays representing images. In this last case,masks are not supported currently.-fps- Number of picture frames to read per second.+ Number of picture frames to read per second. Instead, you can provide+ the duration of each image with durations (see below)++ durations+ List of the duration of each picture.with_maskShould the alpha layer of PNG images be considered as a mask ?@@ -29,11 +36,18 @@ class ImageSequenceClip(VideoClip):ismaskWill this sequence of pictures be used as an animated mask.+ Notes+ ------++ If your sequence is made of image files, the only image kept in++"""- def __init__(self, sequence, fps, with_mask=True, ismask=False):+ def __init__(self, sequence, fps=None, durations=None, with_mask=True,+ ismask=False, load_images=False):# CODE WRITTEN AS IT CAME, MAY BE IMPROVED IN THE FUTURE@@ -44,32 +58,48 @@ class ImageSequenceClip(VideoClip):fromfiles = Trueif isinstance(sequence, list):- if not isinstance(sequence[0], str):- # sequence is a list of numpy arrays+ if isinstance(sequence[0], str):+ if load_images:+ sequence = [ffmpeg_read_image( f, with_mask=True)+ for f in sequence]+ fromfiles = False+ else:+ fromfiles= True+ else:+ # sequence is already a list of numpy arraysfromfiles = Falseelse:- # sequence is a folder name+ # sequence is a folder name, make it a list of files:+ fromfiles = Truesequence = sorted([os.path.join(sequence, f)for f in os.listdir(sequence)])self.fps = fps- self.duration = 1.0* len(sequence) / self.fps+ if fps is not none:+ durations = [1.0/fps for image in sequence]+ self.durations = durations+ self.images_starts = [0]+list(np.cumsum(durations))+ self.duration = sum(durations)self.end = self.durationself.sequence = sequence++ def find_image_index(t):+ return max([i for i in range(len(self.sequence))+ if self.images_starts[i]<=t])if fromfiles:- self.lastpos = None+ self.lastindex = Noneself.lastimage = Nonedef get_frame(t):- pos = int(self.fps*t)- if pos != self.lastpos:- self.lastimage = ffmpeg_read_image(- self.sequence[pos],- with_mask=False)- self.lastpos = pos+ index = find_image_index(t)++ if index != self.lastindex:+ self.lastimage = ffmpeg_read_image( self.sequence[index],+ with_mask=False)+ self.lastindex = indexreturn self.lastimage@@ -79,12 +109,11 @@ class ImageSequenceClip(VideoClip):def mask_get_frame(t):- pos = int(self.fps*t)- if pos != self.lastpos:- self.mask.lastimage = ffmpeg_read_image(- self.sequence[pos],- with_mask=True)[:,:,3]- self.mask.lastpos = pos+ index = find_image_index(t)+ if index != self.lastindex:+ self.mask.lastimage = ffmpeg_read_image( self.sequence[index],+ with_mask=True)[:,:,3]+ self.mask.lastindex = indexreturn self.mask.lastimage@@ -96,8 +125,8 @@ class ImageSequenceClip(VideoClip):def get_frame(t):- pos = int(self.fps*t)- return self.sequence[pos]+ index = find_image_index(t)+ return self.sequence[index]self.get_frame = get_framediff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.pyindex 3f830f11..964bde2c 100644--- a/moviepy/video/io/ffmpeg_reader.py+++ b/moviepy/video/io/ffmpeg_reader.py@@ -265,12 +265,18 @@ def ffmpeg_parse_infos(filename, print_infos=False, check_duration=True):if result['video_found']:- line = lines_video[0]- # get the size, of the form 460x320 (w x h)- match = re.search(" [0-9]*x[0-9]*(,| )", line)- s = list(map(int, line[match.start():match.end()-1].split('x')))- result['video_size'] = s+ try:+ line = lines_video[0]++ # get the size, of the form 460x320 (w x h)+ match = re.search(" [0-9]*x[0-9]*(,| )", line)+ s = list(map(int, line[match.start():match.end()-1].split('x')))+ result['video_size'] = s+ except:+ raise (("MoviePy error: failed to read video dimensions in file %s.\n"+ "Here are the file infos returned by ffmpeg:\n\n%s")%(+ filename, infos))# get the frame rate. Sometimes it's 'tbr', sometimes 'fps', sometimesdiff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex a7a1c399..5156a346 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -127,7 +127,7 @@ class FFMPEG_VideoWriter:# when the child process is createdif os.name == "nt":popen_params["creationflags"] = 0x08000000-+self.proc = sp.Popen(cmd, **popen_params)diff --git a/moviepy/video/io/gif_writers.py b/moviepy/video/io/gif_writers.pyindex f2dc0120..4bc3d058 100644--- a/moviepy/video/io/gif_writers.py+++ b/moviepy/video/io/gif_writers.py@@ -2,7 +2,7 @@ import osimport subprocess as spfrom tqdm import tqdmfrom moviepy.config import get_setting-from moviepy.decorators import requires_duration+from moviepy.decorators import (requires_duration,use_clip_fps_by_default)from moviepy.tools import verbose_print, subprocess_callimport numpy as np@@ -13,6 +13,7 @@ except ImportError:@requires_duration+@use_clip_fps_by_defaultdef write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',opt="OptimizeTransparency", fuzz=1, verbose=True,loop=0, dispose=False, colors=None, tempfiles=False):@@ -26,9 +27,6 @@ def write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',"""- if fps is None:- fps = clip.fps-fileName, fileExtension = os.path.splitext(filename)tt = np.arange(0,clip.duration, 1.0/fps)@@ -93,6 +91,7 @@ def write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',@requires_duration+@use_clip_fps_by_defaultdef write_gif(clip, filename, fps=None, program= 'ImageMagick',opt="OptimizeTransparency", fuzz=1, verbose=True,loop=0, dispose=False, colors=None):@@ -153,8 +152,6 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick',# frames -ffmpeg-> bmp frames -ImagMag-> gif -ImagMag-> better gif#- if fps is None:- fps=clip.fpsdelay= 100.0/fpscmd1 = [get_setting("FFMPEG_BINARY"), '-y', '-loglevel', 'error',diff --git a/moviepy/video/tools/cuts.py b/moviepy/video/tools/cuts.pyindex 37cd92b1..97f3ff7f 100644--- a/moviepy/video/tools/cuts.py+++ b/moviepy/video/tools/cuts.py@@ -1,13 +1,15 @@""" This module contains everything that can help automatizethe cuts in MoviePy """-import numpy as np+from moviepy.decorators import use_clip_fps_by_default+import numpy as np+@use_clip_fps_by_defaultdef find_video_period(clip,fps=None,tmin=.3):""" Finds the period of a video based on frames correlation """- if fps is None:- fps=clip.fps++frame = lambda t: clip.get_frame(t).flatten()tt = np.arange(tmin,clip.duration,1.0/ fps)[1:]ref = frame(0)@@ -15,7 +17,7 @@ def find_video_period(clip,fps=None,tmin=.3):return tt[np.argmax(corrs)]-+@use_clip_fps_by_defaultdef detect_scenes(clip=None, luminosities=None, thr=10,progress_bar=False, fps=None):@@ -61,9 +63,6 @@ def detect_scenes(clip=None, luminosities=None, thr=10,"""-- if fps is None:- fps = clip.fpsif luminosities is None:luminosities = [f.sum() for f in clip.iter_frames(diff --git a/moviepy/video/tools/interpolators.py b/moviepy/video/tools/interpolators.pyindex 482fb628..f5cd030e 100644--- a/moviepy/video/tools/interpolators.py+++ b/moviepy/video/tools/interpolators.py@@ -15,19 +15,13 @@ class Interpolator:self.tt = 1.0*np.array(tt)self.ss = 1.0*np.array(ss)- self.left = ss[0] if (left is None) else left- self.right = ss[-1] if (right is None) else right+ self.left = left+ self.right = rightself.tmin, self.tmax = min(tt), max(tt)def __call__(self, t):- if (t <= self.tmin):- return self.left- if (t >= self.tmax):- return self.right- ind = np.argmax(np.diff(self.tt >= t)==1)- t1, t2 = self.tt[ind], self.tt[ind+1]- s1, s2 = self.ss[ind], self.ss[ind+1]- return s1 + (s2-s1)*(t-t1)/(t2-t1)++ return np.interp(t, self.tt, self.ss, self.left, self.right)class Trajectory:diff --git a/moviepy/video/tools/tracking.py b/moviepy/video/tools/tracking.pyindex ec9fdf1c..2d01a38f 100644--- a/moviepy/video/tools/tracking.py+++ b/moviepy/video/tools/tracking.py@@ -12,7 +12,7 @@ from scipy.interpolate import interp1dfrom ..io.preview import imdisplayfrom .interpolators import Trajectory-from moviepy.decorators import convert_to_seconds+from moviepy.decorators import (convert_to_seconds, use_clip_fps_by_default)try:@@ -29,6 +29,7 @@ except:# MANUAL TRACKING@convert_to_seconds(["t1","t2"])+@use_clip_fps_by_defaultdef manual_tracking(clip, t1=None, t2=None, fps=None, nobjects = 1,savefile = None):"""@@ -77,9 +78,6 @@ def manual_tracking(clip, t1=None, t2=None, fps=None, nobjects = 1,"""import pygame as pg-- if fps is None:- fps = clip.fpsscreen = pg.display.set_mode(clip.size)step = 1.0 / fps