From ee434648639aac22370785cab6f8477fc7921d89 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 20 Mar 2020 18:29:00 +0000 Subject: [PATCH 01/19] 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 02/19] 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 91b8aefb6973db69dc7066d5c4628576d978475a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Mon, 23 Mar 2020 23:45:47 -0300 Subject: [PATCH 03/19] use super --- moviepy/audio/AudioClip.py | 2 +- moviepy/video/VideoClip.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/moviepy/audio/AudioClip.py b/moviepy/audio/AudioClip.py index 122d9b2ec..c5776c665 100644 --- a/moviepy/audio/AudioClip.py +++ b/moviepy/audio/AudioClip.py @@ -45,7 +45,7 @@ class AudioClip(Clip): """ def __init__(self, make_frame=None, duration=None, fps=None): - Clip.__init__(self) + super().__init__() if fps is not None: self.fps = fps diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index 92a2a7452..e8ed31b10 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -72,10 +72,9 @@ class VideoClip(Clip): See variable ``pos``. """ - def __init__(self, make_frame=None, ismask=False, duration=None, has_constant_size=True): - Clip.__init__(self) + super().__init__() self.mask = None self.audio = None self.pos = lambda t: (0, 0) From 43023034527f6a0a6625a55273afcd9c29bd007b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Mon, 23 Mar 2020 23:46:18 -0300 Subject: [PATCH 04/19] audio loop support videoclip instance --- moviepy/audio/fx/audio_loop.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/moviepy/audio/fx/audio_loop.py b/moviepy/audio/fx/audio_loop.py index 7e309b7ff..fc64576e1 100644 --- a/moviepy/audio/fx/audio_loop.py +++ b/moviepy/audio/fx/audio_loop.py @@ -1,7 +1,7 @@ from ..AudioClip import concatenate_audioclips -def audio_loop(audioclip, nloops=None, duration=None): +def audio_loop(clip, nloops=None, duration=None): """ Loops over an audio clip. Returns an audio clip that plays the given clip either @@ -17,12 +17,17 @@ def audio_loop(audioclip, nloops=None, duration=None): >>> videoclip.set_audio(audio) """ + try: + clip = clip.audio + except AttributeError: + # assume it's a an audioclip + pass if duration is not None: - nloops = int( duration/ audioclip.duration)+1 - return concatenate_audioclips(nloops*[audioclip]).set_duration(duration) + nloops = int( duration/ clip.duration)+1 + return concatenate_audioclips(nloops*[clip]).set_duration(duration) else: - return concatenate_audioclips(nloops*[audioclip]) + return concatenate_audioclips(nloops*[clip]) From 3c2f9c4b4a728bfec4ccdf5d9a4a21ee3beff536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Mon, 23 Mar 2020 23:46:52 -0300 Subject: [PATCH 05/19] patch classes avoiding exec --- moviepy/editor.py | 36 +++++++++++++++------------------- moviepy/video/io/html_tools.py | 1 + 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index ea5cb777f..62beda15b 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -6,7 +6,7 @@ In particular it will load many effects from the video.fx and audio.fx folders and turn them into VideoClip methods, so that instead of ->>> clip.fx( vfx.resize, 2 ) # or equivalently vfx.resize(clip, 2) +>>> clip.fx( vfx.resize, 2 ) or equivalently vfx.resize(clip, 2) we can write >>> clip.resize(2) @@ -18,7 +18,8 @@ # file, but this would make the loading of moviepy slower. import os -import sys +import inspect +import itertools # Hide the welcome message from pygame: https://github.com/pygame/pygame/issues/542 @@ -56,24 +57,19 @@ # 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_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 = transfx.%s" % (method_name, method_name)) - - +audio_fxs = inspect.getmembers(afx, inspect.isfunction) +video_fxs = itertools.chain( + inspect.getmembers(vfx, inspect.isfunction), + inspect.getmembers(transfx, inspect.isfunction), + audio_fxs +) +for name, function in video_fxs: + setattr(VideoClip, name, function) + +for name, function in audio_fxs: + setattr(AudioClip, name, function) + + # adds easy ipython integration VideoClip.ipython_display = ipython_display AudioClip.ipython_display = ipython_display diff --git a/moviepy/video/io/html_tools.py b/moviepy/video/io/html_tools.py index f24af513f..24fc2ea78 100644 --- a/moviepy/video/io/html_tools.py +++ b/moviepy/video/io/html_tools.py @@ -156,6 +156,7 @@ def html_embed(clip, filetype=None, maxduration=60, rd_kwargs=None, return result + def ipython_display(clip, filetype=None, maxduration=60, t=None, fps=None, rd_kwargs=None, center=True, **html_kwargs): """ From 5629a94f48834bcf4760514a7bade4847b579925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Mon, 23 Mar 2020 23:51:43 -0300 Subject: [PATCH 06/19] explicitly set fx all --- moviepy/audio/fx/__init__.py | 12 +++++--- moviepy/audio/fx/all/__init__.py | 19 +++++-------- moviepy/video/compositing/transitions.py | 23 +++++++++------ moviepy/video/fx/__init__.py | 36 +++++++++++++++++++++--- moviepy/video/fx/all/__init__.py | 20 +++++-------- 5 files changed, 69 insertions(+), 41 deletions(-) diff --git a/moviepy/audio/fx/__init__.py b/moviepy/audio/fx/__init__.py index 67fe3b194..538ccd0f7 100644 --- a/moviepy/audio/fx/__init__.py +++ b/moviepy/audio/fx/__init__.py @@ -1,4 +1,8 @@ -""" -This module contains transformation functions (clip->clip) -One file for one fx. The file's name is the fx's name -""" +# import every video fx function + +from .audio_fadein import audio_fadein +from .audio_fadeout import audio_fadeout +from .audio_left_right import audio_left_right +from .audio_loop import audio_loop +from .audio_normalize import audio_normalize +from .volumex import volumex \ No newline at end of file diff --git a/moviepy/audio/fx/all/__init__.py b/moviepy/audio/fx/all/__init__.py index 11258d7f0..73a8c83d8 100644 --- a/moviepy/audio/fx/all/__init__.py +++ b/moviepy/audio/fx/all/__init__.py @@ -1,16 +1,11 @@ """ -Loads all the fx ! -Usage: -import moviepy.audio.fx.all as afx -audio_clip = afx.volume_x(some_clip, .5) -""" - -import pkgutil +moviepy.audio.fx.all is deprecated. -import moviepy.audio.fx as fx +Use the right fx method directly from the clip instance +or import the function from moviepy.audio.fx instead. +""" +import warnings -__all__ = [name for _, name, _ in pkgutil.iter_modules( - fx.__path__) if name != "all"] +from .. import * -for name in __all__: - exec("from ..%s import %s" % (name, name)) +warnings.warn(f"MoviePy: {__doc__}", PendingDeprecationWarning) \ No newline at end of file diff --git a/moviepy/video/compositing/transitions.py b/moviepy/video/compositing/transitions.py index b15a707eb..818d75a61 100644 --- a/moviepy/video/compositing/transitions.py +++ b/moviepy/video/compositing/transitions.py @@ -11,6 +11,9 @@ from .CompositeVideoClip import CompositeVideoClip +__all__ = ["crossfadein", "crossfadeout", "slide_in", "slide_out", "make_loopable"] + + @requires_duration @add_mask_if_none def crossfadein(clip, duration): @@ -65,10 +68,12 @@ def slide_in(clip, duration, side): """ w, h = clip.size - pos_dict = {'left': lambda t: (min(0, w*(t/duration-1)), 'center'), - 'right': lambda t: (max(0, w*(1-t/duration)), 'center'), - 'top': lambda t: ('center', min(0, h*(t/duration-1))), - 'bottom': lambda t: ('center', max(0, h*(1-t/duration)))} + pos_dict = { + "left": lambda t: (min(0, w * (t / duration - 1)), "center"), + "right": lambda t: (max(0, w * (1 - t / duration)), "center"), + "top": lambda t: ("center", min(0, h * (t / duration - 1))), + "bottom": lambda t: ("center", max(0, h * (1 - t / duration))), + } return clip.set_position(pos_dict[side]) @@ -106,10 +111,12 @@ def slide_out(clip, duration, side): w, h = clip.size ts = clip.duration - duration # start time of the effect. - pos_dict = {'left': lambda t: (min(0, w*(1-(t-ts)/duration)), 'center'), - 'right': lambda t: (max(0, w*((t-ts)/duration-1)), 'center'), - 'top': lambda t: ('center', min(0, h*(1-(t-ts)/duration))), - 'bottom': lambda t: ('center', max(0, h*((t-ts)/duration-1)))} + pos_dict = { + "left": lambda t: (min(0, w * (1 - (t - ts) / duration)), "center"), + "right": lambda t: (max(0, w * ((t - ts) / duration - 1)), "center"), + "top": lambda t: ("center", min(0, h * (1 - (t - ts) / duration))), + "bottom": lambda t: ("center", max(0, h * ((t - ts) / duration - 1))), + } return clip.set_position(pos_dict[side]) diff --git a/moviepy/video/fx/__init__.py b/moviepy/video/fx/__init__.py index 67fe3b194..f444def5e 100644 --- a/moviepy/video/fx/__init__.py +++ b/moviepy/video/fx/__init__.py @@ -1,4 +1,32 @@ -""" -This module contains transformation functions (clip->clip) -One file for one fx. The file's name is the fx's name -""" +# import every video fx function + +from .accel_decel import accel_decel +from .blackwhite import blackwhite +from .blink import blink +from .colorx import colorx +from .crop import crop +from .even_size import even_size +from .fadein import fadein +from .fadeout import fadeout +from .freeze import freeze +from .freeze_region import freeze_region +from .gamma_corr import gamma_corr +from .headblur import headblur +from .invert_colors import invert_colors +from .loop import loop +from .lum_contrast import lum_contrast +from .make_loopable import make_loopable +from .margin import margin +from .mask_and import mask_and +from .mask_color import mask_color +from .mask_or import mask_or +from .mirror_x import mirror_x +from .mirror_y import mirror_y +from .painting import painting +from .resize import resize +from .rotate import rotate +from .scroll import scroll +from .speedx import speedx +from .supersample import supersample +from .time_mirror import time_mirror +from .time_symmetrize import time_symmetrize \ No newline at end of file diff --git a/moviepy/video/fx/all/__init__.py b/moviepy/video/fx/all/__init__.py index a9a4c4e4e..14873f666 100644 --- a/moviepy/video/fx/all/__init__.py +++ b/moviepy/video/fx/all/__init__.py @@ -1,17 +1,11 @@ """ -Loads all the fx ! -Usage: -import moviepy.video.fx.all as vfx -clip = vfx.resize(some_clip, width=400) -clip = vfx.mirror_x(some_clip) -""" - -import pkgutil +moviepy.video.fx.all is deprecated. -import moviepy.video.fx as fx +Use the right fx method directly from the clip instance +or import the function from moviepy.video.fx instead. +""" +import warnings -__all__ = [name for _, name, _ in pkgutil.iter_modules( - fx.__path__) if name != "all"] +from .. import * -for name in __all__: - exec("from ..%s import %s" % (name, name)) +warnings.warn(f"MoviePy: {__doc__}", PendingDeprecationWarning) \ No newline at end of file From f0f90f0d589901927e5b2d656e19cdcf50f62a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Tue, 24 Mar 2020 00:15:15 -0300 Subject: [PATCH 07/19] explicitly define __all__ on editor.py ``` In [2]: from moviepy.editor import * In [3]: len(dir()) 47 # was 58 ``` --- moviepy/editor.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index 62beda15b..109537a01 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -14,6 +14,17 @@ clip.preview(). """ +__all__ = [ + "VideoFileClip", + "ImageSequenceClip", + "download_webfile", + "VideoClip", "ImageClip", "ColorClip", "TextClip", + "CompositeVideoClip", "concatenate_videoclips", + "AudioClip", "CompositeAudioClip", "concatenate_audioclips", + "AudioFileClip", "vfx", "afx", "transfx", "videotools", + "ffmpeg_tools", "ipython_display", "cvsecs" +] + # Note that these imports could have been performed in the __init__.py # file, but this would make the loading of moviepy slower. @@ -31,7 +42,7 @@ from .video.io.downloader import download_webfile from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip from .video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array -from .video.compositing.concatenate import concatenate_videoclips, concatenate # concatenate=deprecated +from .video.compositing.concatenate import concatenate_videoclips from .audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips from .audio.io.AudioFileClip import AudioFileClip @@ -51,6 +62,7 @@ try: from .video.io.sliders import sliders + __all__.append("sliders") except ImportError: pass @@ -100,4 +112,4 @@ def preview(self, *args, **kwargs): """ NOT AVAILABLE : clip.preview requires Pygame installed.""" raise ImportError("clip.preview requires Pygame installed") -AudioClip.preview = preview +AudioClip.preview = preview \ No newline at end of file From 448029fc8493851a3fc47b4e15b875d3184d67a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Tue, 24 Mar 2020 00:21:58 -0300 Subject: [PATCH 08/19] user warning to be explicit --- moviepy/audio/fx/all/__init__.py | 2 +- moviepy/video/fx/all/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/moviepy/audio/fx/all/__init__.py b/moviepy/audio/fx/all/__init__.py index 73a8c83d8..0e3fe9d50 100644 --- a/moviepy/audio/fx/all/__init__.py +++ b/moviepy/audio/fx/all/__init__.py @@ -8,4 +8,4 @@ from .. import * -warnings.warn(f"MoviePy: {__doc__}", PendingDeprecationWarning) \ No newline at end of file +warnings.warn(f"MoviePy: {__doc__}", UserWarning) \ No newline at end of file diff --git a/moviepy/video/fx/all/__init__.py b/moviepy/video/fx/all/__init__.py index 14873f666..f4297fbd9 100644 --- a/moviepy/video/fx/all/__init__.py +++ b/moviepy/video/fx/all/__init__.py @@ -8,4 +8,4 @@ from .. import * -warnings.warn(f"MoviePy: {__doc__}", PendingDeprecationWarning) \ No newline at end of file +warnings.warn(f"MoviePy: {__doc__}", UserWarning) \ No newline at end of file From aa8136849ac50a78224bfc4b420d61e3363c23e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Tue, 24 Mar 2020 00:37:41 -0300 Subject: [PATCH 09/19] Update moviepy/audio/fx/audio_loop.py --- moviepy/audio/fx/audio_loop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moviepy/audio/fx/audio_loop.py b/moviepy/audio/fx/audio_loop.py index fc64576e1..7e64a1f6e 100644 --- a/moviepy/audio/fx/audio_loop.py +++ b/moviepy/audio/fx/audio_loop.py @@ -20,7 +20,7 @@ def audio_loop(clip, nloops=None, duration=None): try: clip = clip.audio except AttributeError: - # assume it's a an audioclip + # assume it's already an audioclip pass if duration is not None: From 8eb54d60060d6ba2710b8919c856ba0b1964f06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Wed, 25 Mar 2020 00:06:09 -0300 Subject: [PATCH 10/19] black files --- moviepy/audio/fx/__init__.py | 2 +- moviepy/audio/fx/all/__init__.py | 2 +- moviepy/editor.py | 36 +++++++++++++++++++++++--------- moviepy/video/VideoClip.py | 8 +------ moviepy/video/fx/__init__.py | 2 +- moviepy/video/fx/all/__init__.py | 2 +- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/moviepy/audio/fx/__init__.py b/moviepy/audio/fx/__init__.py index 538ccd0f7..8f2def3d5 100644 --- a/moviepy/audio/fx/__init__.py +++ b/moviepy/audio/fx/__init__.py @@ -5,4 +5,4 @@ from .audio_left_right import audio_left_right from .audio_loop import audio_loop from .audio_normalize import audio_normalize -from .volumex import volumex \ No newline at end of file +from .volumex import volumex diff --git a/moviepy/audio/fx/all/__init__.py b/moviepy/audio/fx/all/__init__.py index 0e3fe9d50..0a1e2843e 100644 --- a/moviepy/audio/fx/all/__init__.py +++ b/moviepy/audio/fx/all/__init__.py @@ -8,4 +8,4 @@ from .. import * -warnings.warn(f"MoviePy: {__doc__}", UserWarning) \ No newline at end of file +warnings.warn(f"MoviePy: {__doc__}", UserWarning) diff --git a/moviepy/editor.py b/moviepy/editor.py index 9553478a9..f047f15ee 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -18,11 +18,23 @@ "VideoFileClip", "ImageSequenceClip", "download_webfile", - "VideoClip", "ImageClip", "ColorClip", "TextClip", - "CompositeVideoClip", "concatenate_videoclips", - "AudioClip", "CompositeAudioClip", "concatenate_audioclips", - "AudioFileClip", "vfx", "afx", "transfx", "videotools", - "ffmpeg_tools", "ipython_display", "cvsecs" + "VideoClip", + "ImageClip", + "ColorClip", + "TextClip", + "CompositeVideoClip", + "concatenate_videoclips", + "AudioClip", + "CompositeAudioClip", + "concatenate_audioclips", + "AudioFileClip", + "vfx", + "afx", + "transfx", + "videotools", + "ffmpeg_tools", + "ipython_display", + "cvsecs", ] # Note that these imports could have been performed in the __init__.py @@ -45,7 +57,7 @@ from .video.compositing.concatenate import ( concatenate_videoclips, concatenate, -) +) from .audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips from .audio.io.AudioFileClip import AudioFileClip @@ -64,6 +76,7 @@ try: from .video.io.sliders import sliders + __all__.append("sliders") except ImportError: pass @@ -73,17 +86,17 @@ # myclip.fx( vfx.resize, width= 500) audio_fxs = inspect.getmembers(afx, inspect.isfunction) video_fxs = itertools.chain( - inspect.getmembers(vfx, inspect.isfunction), + inspect.getmembers(vfx, inspect.isfunction), inspect.getmembers(transfx, inspect.isfunction), - audio_fxs + audio_fxs, ) for name, function in video_fxs: setattr(VideoClip, name, function) for name, function in audio_fxs: setattr(AudioClip, name, function) - - + + # adds easy ipython integration VideoClip.ipython_display = ipython_display AudioClip.ipython_display = ipython_display @@ -105,14 +118,17 @@ 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 try: from moviepy.audio.io.preview import preview except ImportError: + def preview(self, *args, **kwargs): """ NOT AVAILABLE : clip.preview requires Pygame installed.""" raise ImportError("clip.preview requires Pygame installed") + AudioClip.preview = preview diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index ced000855..aa556c643 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -81,17 +81,11 @@ class VideoClip(Clip): See variable ``pos``. """ -<<<<<<< HEAD - def __init__(self, make_frame=None, ismask=False, duration=None, - has_constant_size=True): - super().__init__() -======= def __init__( self, make_frame=None, ismask=False, duration=None, has_constant_size=True ): - Clip.__init__(self) ->>>>>>> zulko/v2 + super().__init__() self.mask = None self.audio = None self.pos = lambda t: (0, 0) diff --git a/moviepy/video/fx/__init__.py b/moviepy/video/fx/__init__.py index f444def5e..4dc78e689 100644 --- a/moviepy/video/fx/__init__.py +++ b/moviepy/video/fx/__init__.py @@ -29,4 +29,4 @@ from .speedx import speedx from .supersample import supersample from .time_mirror import time_mirror -from .time_symmetrize import time_symmetrize \ No newline at end of file +from .time_symmetrize import time_symmetrize diff --git a/moviepy/video/fx/all/__init__.py b/moviepy/video/fx/all/__init__.py index f4297fbd9..e484fe7bd 100644 --- a/moviepy/video/fx/all/__init__.py +++ b/moviepy/video/fx/all/__init__.py @@ -8,4 +8,4 @@ from .. import * -warnings.warn(f"MoviePy: {__doc__}", UserWarning) \ No newline at end of file +warnings.warn(f"MoviePy: {__doc__}", UserWarning) From 19f15b20371b3aae2eca9d3362f791f63eb5858b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Wed, 25 Mar 2020 00:17:57 -0300 Subject: [PATCH 11/19] fix regressions --- moviepy/editor.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index f047f15ee..6080e666e 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -15,26 +15,27 @@ """ __all__ = [ - "VideoFileClip", - "ImageSequenceClip", - "download_webfile", - "VideoClip", - "ImageClip", - "ColorClip", - "TextClip", - "CompositeVideoClip", - "concatenate_videoclips", + "afx", "AudioClip", + "AudioFileClip", + "clips_array", + "ColorClip", "CompositeAudioClip", + "CompositeVideoClip", "concatenate_audioclips", - "AudioFileClip", - "vfx", - "afx", - "transfx", - "videotools", + "concatenate_videoclips", + "cvsecs", + "download_webfile", "ffmpeg_tools", + "ImageClip", + "ImageSequenceClip", "ipython_display", - "cvsecs", + "TextClip", + "transfx", + "vfx", + "VideoClip", + "VideoFileClip", + "videotools", ] # Note that these imports could have been performed in the __init__.py From f72522cbc1ac779b947a372b6dc2f0fb67cfa546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Sat, 4 Apr 2020 14:23:40 -0300 Subject: [PATCH 12/19] import package directly instead all modules --- moviepy/editor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index 6080e666e..36e2ffa71 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -64,8 +64,8 @@ # FX -import moviepy.video.fx.all as vfx -import moviepy.audio.fx.all as afx +import moviepy.video.fx as vfx +import moviepy.audio.fx as afx import moviepy.video.compositing.transitions as transfx # Tools From 92d8a911617eae68700580fd5ecb4b7d3fc194b0 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Wed, 29 Apr 2020 16:26:56 +0100 Subject: [PATCH 13/19] Add missing import --- tests/test_issues.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_issues.py b/tests/test_issues.py index aa4ec31f8..5d5b17bd0 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Issue tests meant to be run with pytest.""" import pytest +import os from moviepy.editor import * from moviepy.utils import close_all_clips From 3d8dd864baa00f907c66a7beb3401e781333df9b Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 8 Oct 2020 22:40:35 +0100 Subject: [PATCH 14/19] Fix undefined name from incorrect merging --- moviepy/audio/fx/audio_loop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moviepy/audio/fx/audio_loop.py b/moviepy/audio/fx/audio_loop.py index cc4718a09..41ea79e9f 100644 --- a/moviepy/audio/fx/audio_loop.py +++ b/moviepy/audio/fx/audio_loop.py @@ -27,4 +27,4 @@ def audio_loop(clip, n_loops=None, duration=None): n_loops = int(duration / clip.duration) + 1 return concatenate_audioclips(n_loops * [clip]).with_duration(duration) - return concatenate_audioclips(nloops * [clip]) + return concatenate_audioclips(n_loops * [clip]) From 7dc7b5ff471c704ba914fed1e43004d1a3ef7d52 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 8 Oct 2020 22:47:12 +0100 Subject: [PATCH 15/19] cvsecs -> convert_to_seconds in editor.py --- moviepy/editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moviepy/editor.py b/moviepy/editor.py index 1fa1c6775..0b29f3c04 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -24,7 +24,7 @@ "CompositeVideoClip", "concatenate_audioclips", "concatenate_videoclips", - "cvsecs", + "convert_to_seconds", "download_webfile", "ffmpeg_tools", "ImageClip", From 9cfd5fa7f134ecabc5944f77298d137cc7da1993 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 8 Oct 2020 22:55:44 +0100 Subject: [PATCH 16/19] Minor docs cleanup --- moviepy/audio/fx/all/__init__.py | 2 +- moviepy/editor.py | 17 +++++++++-------- moviepy/video/fx/all/__init__.py | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/moviepy/audio/fx/all/__init__.py b/moviepy/audio/fx/all/__init__.py index 0a1e2843e..0b5e75e60 100644 --- a/moviepy/audio/fx/all/__init__.py +++ b/moviepy/audio/fx/all/__init__.py @@ -1,7 +1,7 @@ """ moviepy.audio.fx.all is deprecated. -Use the right fx method directly from the clip instance +Use the fx method directly from the clip instance (e.g. ``clip.audio_loop(...)``) or import the function from moviepy.audio.fx instead. """ import warnings diff --git a/moviepy/editor.py b/moviepy/editor.py index 0b29f3c04..c7ec4a9e8 100644 --- a/moviepy/editor.py +++ b/moviepy/editor.py @@ -18,6 +18,7 @@ "afx", "AudioClip", "AudioFileClip", + "BitmapClip", "clips_array", "ColorClip", "CompositeAudioClip", @@ -43,7 +44,6 @@ import os import inspect -import itertools # Hide the welcome message from pygame: https://github.com/pygame/pygame/issues/542 @@ -80,15 +80,16 @@ except ImportError: pass -# 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) +# Transforms the effects into Clip methods so that +# they can be called with clip.resize(width=500) instead of +# clip.fx(vfx.resize, width=500) audio_fxs = inspect.getmembers(afx, inspect.isfunction) -video_fxs = itertools.chain( - inspect.getmembers(vfx, inspect.isfunction), - inspect.getmembers(transfx, inspect.isfunction), - audio_fxs, +video_fxs = ( + inspect.getmembers(vfx, inspect.isfunction) + + inspect.getmembers(transfx, inspect.isfunction) + + audio_fxs ) + for name, function in video_fxs: setattr(VideoClip, name, function) diff --git a/moviepy/video/fx/all/__init__.py b/moviepy/video/fx/all/__init__.py index e484fe7bd..46aa14a56 100644 --- a/moviepy/video/fx/all/__init__.py +++ b/moviepy/video/fx/all/__init__.py @@ -1,7 +1,7 @@ """ moviepy.video.fx.all is deprecated. -Use the right fx method directly from the clip instance +Use the fx method directly from the clip instance (e.g. ``clip.resize(...)``) or import the function from moviepy.video.fx instead. """ import warnings From d8a0bd8dd855e2baa1da92d79c26dd6704fcf652 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 8 Oct 2020 23:12:05 +0100 Subject: [PATCH 17/19] Add @audio_video_fx to audio_loop (should probably delete audio_loop in future --- moviepy/audio/fx/audio_loop.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/moviepy/audio/fx/audio_loop.py b/moviepy/audio/fx/audio_loop.py index 41ea79e9f..e8a3785ff 100644 --- a/moviepy/audio/fx/audio_loop.py +++ b/moviepy/audio/fx/audio_loop.py @@ -1,6 +1,8 @@ from ..AudioClip import concatenate_audioclips +from moviepy.decorators import audio_video_fx +@audio_video_fx def audio_loop(clip, n_loops=None, duration=None): """Loops over an audio clip. @@ -17,12 +19,6 @@ def audio_loop(clip, n_loops=None, duration=None): >>> videoclip.with_audio(audio) """ - try: - clip = clip.audio - except AttributeError: - # assume it's already an audioclip - pass - if duration is not None: n_loops = int(duration / clip.duration) + 1 return concatenate_audioclips(n_loops * [clip]).with_duration(duration) From 9f174c2029913b8c18d8811ccb548d5b060cc087 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 8 Oct 2020 23:20:41 +0100 Subject: [PATCH 18/19] Updated CHANGELOG.md --- CHANGELOG.md | 3 ++- moviepy/audio/fx/all/__init__.py | 2 +- moviepy/video/fx/all/__init__.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6fd9dc25..b47217d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -### Deprecated +### Deprecated +- `moviepy.video.fx.all` and `moviepy.audio.fx.all`. Use the fx method directly from the clip instance or import the fx function from `moviepy.video.fx` and `moviepy.audio.fx`. ### Removed diff --git a/moviepy/audio/fx/all/__init__.py b/moviepy/audio/fx/all/__init__.py index 0b5e75e60..c36d6e87f 100644 --- a/moviepy/audio/fx/all/__init__.py +++ b/moviepy/audio/fx/all/__init__.py @@ -8,4 +8,4 @@ from .. import * -warnings.warn(f"MoviePy: {__doc__}", UserWarning) +warnings.warn(f"\nMoviePy: {__doc__}", UserWarning) diff --git a/moviepy/video/fx/all/__init__.py b/moviepy/video/fx/all/__init__.py index 46aa14a56..47364b51e 100644 --- a/moviepy/video/fx/all/__init__.py +++ b/moviepy/video/fx/all/__init__.py @@ -8,4 +8,4 @@ from .. import * -warnings.warn(f"MoviePy: {__doc__}", UserWarning) +warnings.warn(f"\nMoviePy: {__doc__}", UserWarning) From eee1e1f06d24538ce06b4d6037cfbdee8b19b6f6 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 8 Oct 2020 23:21:03 +0100 Subject: [PATCH 19/19] Updated CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b47217d17..d4c5165e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Deprecated -- `moviepy.video.fx.all` and `moviepy.audio.fx.all`. Use the fx method directly from the clip instance or import the fx function from `moviepy.video.fx` and `moviepy.audio.fx`. +- `moviepy.video.fx.all` and `moviepy.audio.fx.all`. Use the fx method directly from the clip instance or import the fx function from `moviepy.video.fx` and `moviepy.audio.fx`. [#1105] ### Removed