Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support improved syntax for all effects in editor.py #1104

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 17 additions & 31 deletions moviepy/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,38 +59,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",
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))

# 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 = %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))
exec("VideoClip.%s = transfx.%s" % (method_name, method_name))


# adds easy ipython integration
Expand Down
2 changes: 1 addition & 1 deletion moviepy/video/compositing/transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,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)
Expand Down
4 changes: 2 additions & 2 deletions moviepy/video/fx/time_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)