From ee434648639aac22370785cab6f8477fc7921d89 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 20 Mar 2020 18:29:00 +0000 Subject: [PATCH 1/3] Rework editor.py fx imports to include all fx --- moviepy/editor.py | 51 +++++++++--------------- moviepy/video/compositing/transitions.py | 2 +- moviepy/video/fx/time_mirror.py | 4 +- 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index 3b5babcf6..da0cbe756 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -56,38 +56,24 @@ # The next loop transforms many effects into VideoClip methods so that # they can be called with myclip.resize(width=500) instead of # myclip.fx( vfx.resize, width= 500) -for method in [ - "afx.audio_fadein", - "afx.audio_fadeout", - "afx.audio_normalize", - "afx.volumex", - "transfx.crossfadein", - "transfx.crossfadeout", - "vfx.crop", - "vfx.fadein", - "vfx.fadeout", - "vfx.invert_colors", - "vfx.loop", - "vfx.margin", - "vfx.mask_and", - "vfx.mask_or", - "vfx.resize", - "vfx.rotate", - "vfx.speedx" - ]: - - exec("VideoClip.%s = %s" % (method.split('.')[1], method)) - - -for method in ["afx.audio_fadein", - "afx.audio_fadeout", - "afx.audio_loop", - "afx.audio_normalize", - "afx.volumex" - ]: - - exec("AudioClip.%s = %s" % (method.split('.')[1], method)) - +for method_name in vfx.__all__: + exec("VideoClip.%s = vfx.%s" % (method_name, method_name)) + +for method_name in afx.__all__: + exec("AudioClip.%s = afx.%s" % (method_name, method_name)) + if method_name != "audio_loop": + exec("VideoClip.%s = afx.%s" % (method_name, method_name)) + +print(vfx.__all__) +print(afx.__all__) +# These transitions effects are all contained in one file so there is no way to automatically +# generate a list of them +for method_name in ["crossfadein", + "crossfadeout", + "slide_in", + "slide_out", + "make_loopable"]: + exec("VideoClip.%s = transfx.%s" % (method_name, method_name)) # adds easy ipython integration VideoClip.ipython_display = ipython_display @@ -109,7 +95,6 @@ def show(self, *args, **kwargs): """NOT AVAILABLE : clip.show requires Pygame installed.""" raise ImportError("clip.show requires Pygame installed") - VideoClip.preview = preview VideoClip.show = show diff --git a/moviepy/video/compositing/transitions.py b/moviepy/video/compositing/transitions.py index ab2920b23..b15a707eb 100644 --- a/moviepy/video/compositing/transitions.py +++ b/moviepy/video/compositing/transitions.py @@ -117,7 +117,7 @@ def slide_out(clip, duration, side): @requires_duration def make_loopable(clip, cross_duration): """ Makes the clip fade in progressively at its own end, this way - it can be looped indefinitely. ``cross`` is the duration in seconds + it can be looped indefinitely. ``cross_duration`` is the duration in seconds of the fade-in. """ d = clip.duration clip2 = clip.fx(crossfadein, cross_duration).set_start(d - cross_duration) diff --git a/moviepy/video/fx/time_mirror.py b/moviepy/video/fx/time_mirror.py index 1c044e3e3..b8d92f370 100644 --- a/moviepy/video/fx/time_mirror.py +++ b/moviepy/video/fx/time_mirror.py @@ -4,10 +4,10 @@ @requires_duration @apply_to_mask @apply_to_audio -def time_mirror(self): +def time_mirror(clip): """ 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) + return clip.fl_time(lambda t: clip.duration - t, keep_duration=True) From 2fb768e40887fcaa35cd22fe84355438f767351a Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 20 Mar 2020 18:40:50 +0000 Subject: [PATCH 2/3] Remove debug print statements --- moviepy/editor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index da0cbe756..ea5cb777f 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -64,8 +64,6 @@ if method_name != "audio_loop": exec("VideoClip.%s = afx.%s" % (method_name, method_name)) -print(vfx.__all__) -print(afx.__all__) # These transitions effects are all contained in one file so there is no way to automatically # generate a list of them for method_name in ["crossfadein", @@ -75,6 +73,7 @@ "make_loopable"]: exec("VideoClip.%s = transfx.%s" % (method_name, method_name)) + # adds easy ipython integration VideoClip.ipython_display = ipython_display AudioClip.ipython_display = ipython_display From f544085aae3f64e883e60cb22efc4da5463dd1cf Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Mon, 30 Mar 2020 12:45:39 +0100 Subject: [PATCH 3/3] Apply black --- moviepy/editor.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index 8eebe9bb0..4cb818665 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -69,11 +69,13 @@ # These transitions effects are all contained in one file so there is no way to automatically # generate a list of them -for method_name in ["crossfadein", - "crossfadeout", - "slide_in", - "slide_out", - "make_loopable"]: +for method_name in [ + "crossfadein", + "crossfadeout", + "slide_in", + "slide_out", + "make_loopable", +]: exec("VideoClip.%s = transfx.%s" % (method_name, method_name)) @@ -98,6 +100,7 @@ def show(self, *args, **kwargs): """NOT AVAILABLE : clip.show requires Pygame installed.""" raise ImportError("clip.show requires Pygame installed") + VideoClip.preview = preview VideoClip.show = show