Skip to content

Video editing with Python

Remove auto adding of effects as clip methods at runtime

osaajani4f3bfbf2a542
diff --git a/moviepy/Effect.py b/moviepy/Effect.py
index 125681cd..5ea4a77a 100644
--- a/moviepy/Effect.py
+++ b/moviepy/Effect.py
@@ -3,12 +3,15 @@ from moviepy.Clip import Clip
import copy as _copy
class Effect(metaclass=ABCMeta):
+ """
+ Base abastract class for all effects.
+ """
def copy(self):
"""Return a shallow copy of an Effect.
- You must *always* copy an ``Effect`` before calling ``Effect.apply``,
- because some of them will modify their own attributes when calling apply.
+ You must *always* copy an ``Effect`` before applying,
+ because some of them will modify their own attributes when applied.
For example, setting a previously unset property by using target clip property.
If we was to use the original effect, calling the same effect multiple times
diff --git a/moviepy/__init__.py b/moviepy/__init__.py
index ac3f96ba..7464f781 100644
--- a/moviepy/__init__.py
+++ b/moviepy/__init__.py
@@ -1,13 +1,7 @@
"""Imports everything that you need from the MoviePy submodules so that every thing
-can be directly imported like `from moviepy import VideoFileClip`.
-
-In particular it loads all effects from the video.fx and audio.fx folders
-and turns them into VideoClip and AudioClip methods, where method name is effect
-name in snake_case preceeded by ``with_``
+can be directly imported with `from moviepy import *`.
"""
-import inspect
-
from moviepy.audio import fx as afx
from moviepy.audio.AudioClip import (
AudioClip,
@@ -35,36 +29,10 @@ from moviepy.video.VideoClip import (
UpdatedVideoClip,
)
-import re
-
-
-# Black magic to transforms the effects into Clip methods so that
-# they can be called with clip.resize(width=500) instead of
-# clip.with_effects([vfx.Resize(width=500)])
-# We use a lot of inspect + closure + setattr + python scope magic
-audio_fxs = inspect.getmembers(afx, inspect.isclass)
-video_fxs = inspect.getmembers(vfx, inspect.isclass) + audio_fxs
-
-def add_effect_as_method(to_klass, method_name, eklass) :
- def effect_call(clip, *args, **kwargs):
- return clip.with_effects([eklass(*args, **kwargs).copy()])
-
- setattr(to_klass, method_name, effect_call)
-
-for name, effect_class in video_fxs :
- camel_name = 'with_' + re.sub('(?!^)([A-Z]+)', r'_\1', name).lower()
- add_effect_as_method(VideoClip, camel_name, effect_class)
-
-for name, effect_class in audio_fxs :
- camel_name = 'with_' + re.sub('(?!^)([A-Z]+)', r'_\1', name).lower()
- add_effect_as_method(AudioClip, camel_name, effect_class)
-
# Add display in notebook to video and audioclip
VideoClip.display_in_notebook = display_in_notebook
AudioClip.display_in_notebook = display_in_notebook
-# Cleanup namespace
-del audio_fxs, video_fxs, inspect, add_effect_as_method
# Importing with `from moviepy import *` will only import these names
__all__ = [
diff --git a/moviepy/audio/fx/all/__init__.py b/moviepy/audio/fx/all/__init__.py
deleted file mode 100644
index c6cadf1c..00000000
--- a/moviepy/audio/fx/all/__init__.py
+++ /dev/null
@@ -1,12 +0,0 @@
-"""
-moviepy.audio.fx.all is deprecated.
-
-Use the fx method directly from the clip instance (e.g. ``clip.audio_normalize(...)``)
-or import the function from moviepy.audio.fx instead.
-"""
-import warnings
-
-from .. import * # noqa 401,F403
-
-
-warnings.warn(f"\nMoviePy: {__doc__}", UserWarning)