Skip to content

Video editing with Python

.

osaajaniacbfd3dac752
diff --cc moviepy/decorators.py
index 1177f214,9c7b9a21..812803b7
--- a/moviepy/decorators.py
+++ b/moviepy/decorators.py
@@@ -71,40 -71,29 +71,39 @@@ def audio_video_effect(func, effect, cl
videoclip with unmodified video and modified audio.
"""
if hasattr(clip, "audio"):
- new_clip = clip.copy()
if clip.audio is not None:
- new_clip.audio = func(clip.audio, *args, **kwargs)
- return new_clip
+ clip.audio = func(effect, clip.audio, *args, **kwargs)
+ return clip
else:
- return func(clip, *args, **kwargs)
+ return func(effect, clip, *args, **kwargs)
-def preprocess_args(fun, varnames):
- """Applies fun to variables in varnames before launching the function."""
+def preprocess_args(preprocess_func, varnames):
+ """Applies preprocess_func to variables in varnames before launching
+ the function.
+ """
- def wrapper(func, *args, **kwargs):
- names = inspect.getfullargspec(func).args
- new_args = [
- fun(arg) if (name in varnames) and (arg is not None) else arg
- for (arg, name) in zip(args, names)
- ]
- new_kwargs = {
- kwarg: fun(value) if kwarg in varnames else value
- for (kwarg, value) in kwargs.items()
- }
- return func(*new_args, **new_kwargs)
+ def decor(func):
+ argnames = inspect.getfullargspec(func).args
+
+ def wrapper(func, *args, **kwargs):
+ new_args = [
+ (
+ preprocess_func(arg)
+ if (name in varnames) and (arg is not None)
+ else arg
+ )
+ for (arg, name) in zip(args, argnames)
+ ]
+ new_kwargs = {
+ kwarg: preprocess_func(value) if kwarg in varnames else value
+ for (kwarg, value) in kwargs.items()
+ }
+ return func(*new_args, **new_kwargs)
+
+ return decorator.decorate(func, wrapper)
- return decorator.decorator(wrapper)
+ return decor
def convert_parameter_to_seconds(varnames):