Video editing with Python
Move most imports from editor.py to __init__.py (#1340)
Tom Burrows4d9f6370468c
diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.mdindex 6df545e5..77175950 100644--- a/.github/ISSUE_TEMPLATE/bug-report.md+++ b/.github/ISSUE_TEMPLATE/bug-report.md@@ -11,7 +11,7 @@ assignees: ''You can format code by putting ``` (that's 3 backticks) on a line by itself at the beginning and end of each code block. For example:```-from moviepy.editor import *+from moviepy import *clip = ColorClip((600, 400), color=(255, 100, 0), duration=2)```-->diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.mdindex 309d7f77..19eb1e4b 100644--- a/.github/ISSUE_TEMPLATE/question.md+++ b/.github/ISSUE_TEMPLATE/question.md@@ -15,7 +15,7 @@ Hello! If you think that it is a simple problem, then consider asking instead onYou can format code by putting ``` (that's 3 backticks) on a line by itself at the beginning and end of each code block. For example:```-from moviepy.editor import *+from moviepy import *clip = ColorClip((600, 400), color=(255, 100, 0), duration=2)```-->diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.ymlindex 3a8c4915..f4b2a104 100644--- a/.github/workflows/format_check.yml+++ b/.github/workflows/format_check.yml@@ -39,6 +39,6 @@ jobs:# W503: line break before binary operatorflake8 moviepy --ignore=E203,E302,E402,W291,W293,W503 --max-complexity=10 --max-line-length=127 --statistics --count --exit-zero# Check examples and tests with slightly relaxed rules to allow 'star' imports- # F403 'from moviepy.editor import *' used; unable to detect undefined names- # F405 'name' may be undefined, or defined from star imports: moviepy.editor+ # F403 'from moviepy import *' used; unable to detect undefined names+ # F405 'name' may be undefined, or defined from star imports: moviepyflake8 . --ignore=E203,E302,E402,W291,W293,W503,F403,F405 --exclude moviepy/ --max-complexity=10 --max-line-length=127 --statistics --count --exit-zerodiff --git a/CHANGELOG.md b/CHANGELOG.mdindex b99628c6..0961960a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `VideoFileClip.coreader()` that creates a new clip created from the same source file as the original (to complement the existing `AudioFileClip.coreader()`) [\#1332](https://github.com/Zulko/moviepy/pull/1332)### Changed <!-- for changes in existing functionality -->-Lots of method and parameter names have been changed. This will be explained better in the documentation soon. See https://github.com/Zulko/moviepy/pull/1170 for more information. [\#1170](https://github.com/Zulko/moviepy/pull/1170)+- Lots of method and parameter names have been changed. This will be explained better in the documentation soon. See https://github.com/Zulko/moviepy/pull/1170 for more information. [\#1170](https://github.com/Zulko/moviepy/pull/1170)+- Changed recommended import from `import moviepy.editor` to `import moviepy`. This change is fully backwards compatible [\#1340](https://github.com/Zulko/moviepy/pull/1340)### Deprecated <!-- for soon-to-be removed features -->- `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](https://github.com/Zulko/moviepy/pull/1105)diff --git a/README.rst b/README.rstindex 7866e43a..73cf9551 100644--- a/README.rst+++ b/README.rst@@ -32,7 +32,7 @@ In this example we open a video file, select the subclip between t=50s and t=60s.. code:: python- from moviepy.editor import *+ from moviepy import *video = VideoFileClip("myHolidays.mp4").subclip(50,60)diff --git a/docs/examples/quick_recipes.rst b/docs/examples/quick_recipes.rstindex 364d38d8..b7eabbb6 100644--- a/docs/examples/quick_recipes.rst+++ b/docs/examples/quick_recipes.rst@@ -12,7 +12,7 @@ Blurring all frames of a video::from skimage.filters import gaussian- from moviepy.editor import VideoFileClip+ from moviepy import VideoFileClipdef blur(image):""" Returns a blurred (radius=2 pixels) version of the image """@@ -56,7 +56,7 @@ Getting the average frame of a video"""""""""""""""""""""""""""""""""""""::- from moviepy.editor import VideoFileClip, ImageClip+ from moviepy import VideoFileClip, ImageClipclip = VideoFileClip("video.mp4")fps= 1.0 # take one frame per secondnframes = clip.duration*fps # total number of frames useddiff --git a/docs/getting_started/audioclips.rst b/docs/getting_started/audioclips.rstindex f8089159..4727149e 100644--- a/docs/getting_started/audioclips.rst+++ b/docs/getting_started/audioclips.rst@@ -18,7 +18,7 @@ Creating a new audio clipAudio clips can be created from an audio file or from the soundtrack of a video file ::- from moviepy.editor import *+ from moviepy import *audioclip = AudioFileClip("some_audiofile.mp3")audioclip = AudioFileClip("some_video.avi")diff --git a/docs/getting_started/compositing.rst b/docs/getting_started/compositing.rstindex fa6466c9..0612a4a5 100644--- a/docs/getting_started/compositing.rst+++ b/docs/getting_started/compositing.rst@@ -22,7 +22,7 @@ Two simple ways of putting clips together is to concatenate them (to play them oConcatenation is done with the function ``concatenate_videoclips``: ::- from moviepy.editor import VideoFileClip, concatenate_videoclips+ from moviepy import VideoFileClip, concatenate_videoclipsclip1 = VideoFileClip("myvideo.mp4")clip2 = VideoFileClip("myvideo2.mp4").subclip(50,60)clip3 = VideoFileClip("myvideo3.mp4")@@ -34,7 +34,7 @@ The ``final_clip`` is a clip that plays the clips 1, 2, and 3 one after the otheStacking is done with ``clip_array``: ::- from moviepy.editor import VideoFileClip, clips_array, vfx+ from moviepy import VideoFileClip, clips_array, vfxclip1 = VideoFileClip("myvideo.mp4").margin(10) # add 10px contourclip2 = clip1.fx( vfx.mirror_x)clip3 = clip1.fx( vfx.mirror_y)@@ -125,7 +125,7 @@ When you mix video clips together, MoviePy will automatically compose their respIf you want to make a custom audiotrack from several audio sources: audioc clips can be mixed together with ``CompositeAudioClip`` and ``concatenate_audioclips``: ::- from moviepy.editor import *+ from moviepy import *# ... make some audio clips aclip1, aclip2, aclip3concat = concatenate_audioclips([aclip1, aclip2, aclip3])compo = CompositeAudioClip([aclip1.volumex(1.2),diff --git a/docs/getting_started/effects.rst b/docs/getting_started/effects.rstindex 37c47340..2d4b2298 100644--- a/docs/getting_started/effects.rst+++ b/docs/getting_started/effects.rst@@ -47,15 +47,15 @@ but this is not easy to read. To have a clearer syntax you can use ``clip.fx``:.fx( effect_2, args2).fx( effect_3, args3))-Much better! There are already many effects implemented in the modules ``moviepy.video.fx`` and ``moviepy.audio.fx``. The fx methods in these modules are automatically applied to the sound and the mask of the clip if it is relevant, so that you don't have to worry about modifying these. For practicality, when you use ``from moviepy.editor import *``, these two modules are loaded as ``vfx`` and ``afx``, so you may write something like ::+Much better! There are already many effects implemented in the modules ``moviepy.video.fx`` and ``moviepy.audio.fx``. The fx methods in these modules are automatically applied to the sound and the mask of the clip if it is relevant, so that you don't have to worry about modifying these. For practicality, these two modules are loaded as ``vfx`` and ``afx``, so you may write something like ::- from moviepy.editor import *+ from moviepy import *clip = (VideoFileClip("myvideo.avi").fx( vfx.resize, width=460) # resize (keep aspect ratio).fx( vfx.speedx, 2) # double the speed.fx( vfx.colorx, 0.5)) # darken the picture-For convenience, when you use ``moviepy.editor``, frequently used methods such as ``resize`` can be called in a simpler way: ``clip.resize(...)`` instead of ``clip.fx( vfx.resize, ...)``+For convenience, fx methods such as ``resize`` can be called in a simpler way: ``clip.resize(...)`` instead of ``clip.fx( vfx.resize, ...)``Methods to create custom effectsdiff --git a/docs/getting_started/efficient_moviepy.rst b/docs/getting_started/efficient_moviepy.rstindex af7a7007..5642ee01 100644--- a/docs/getting_started/efficient_moviepy.rst+++ b/docs/getting_started/efficient_moviepy.rst@@ -12,20 +12,11 @@ The best way to start with MoviePy is to use it with the IPython Notebook: it maShould I use ``moviepy.editor``?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-Most examples in this documentation use the submodule ``moviepy.editor``, but this submodule is not adapted to all needs so should *you* use it? Short answer: if you use MoviePy to edit videos *by hand*, use it, but if you use MoviePy inside a larger library or program or webserver, it is better to avoid it and just load the functions that you need.--The module ``moviepy.editor`` can be loaded using one of the three following methods: ::--- from moviepy.editor import * # imports everything, quick and dirty- import moviepy.editor as mpy # Clean. Then use mpy.VideoClip, etc.- from moviepy.editor import VideoFileClip # just import what you need--With any of these lines, the ``moviepy.editor`` module will actually do a lot of work behind the curtain: it will fetch all the most common classes, functions and subpackages of MoviePy, initialize a PyGame session (if PyGame is installed) to be able to preview video clips, and implement some shortcuts, like adding the ``resize`` transformation to the clips. This way you can use ``clip.resize(width=240)`` instead of the longer ``clip.fx( resize, width=240)``. In short, ``moviepy.editor``-provides all you need to play around and edit your videos, but it will take time to load (circa one second). So if all you need is one or two features inside another library, it is better to import directly what you need, as follows: ::-- from moviepy.video.io.VideoFileClip import VideoFileClip- from moviepy.video.fx.resize import resize+Older versions of MoviePy always recommended importing from ``moviepy.editor``. In v2.0 and above this is no longer recommended and you should generally import directly from ``moviepy`` (for example, ``from moviepy import VideoFileClip``).+The module ``moviepy.editor`` should now only be loaded if you are using MoviePy to edit videos *by hand*. Importing it will:+- Start a pygame session to enable ``clip.show()`` and ``clip.preview()`` if pygame is installed+- Enable ``clip.ipython_display()`` if in an IPython Notebook+- Enable ``sliders()`` if Matplotlib is installed.. _previewing:diff --git a/docs/getting_started/quick_presentation.rst b/docs/getting_started/quick_presentation.rstindex 290032c5..efe79371 100644--- a/docs/getting_started/quick_presentation.rst+++ b/docs/getting_started/quick_presentation.rst@@ -39,7 +39,7 @@ Example codeIn a typical MoviePy script, you load video or audio files, modify them, put them together, and write the final result to a new video file. As an example, let us load a video of my last holidays, lower the volume, add a title in the center of the video for the first ten seconds, and write the result in a file: ::# Import everything needed to edit video clips- from moviepy.editor import *+ from moviepy import *# Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60clip = VideoFileClip("myHolidays.mp4").subclip(50,60)diff --git a/docs/getting_started/videoclips.rst b/docs/getting_started/videoclips.rstindex e66f3d8e..8b7938a9 100644--- a/docs/getting_started/videoclips.rst+++ b/docs/getting_started/videoclips.rst@@ -38,7 +38,7 @@ VideoClip``VideoClip`` is the base class for all the other video clips in MoviePy. If all you want is to edit video files, you will never need it. This class is practical when you want to make animations from frames that are generated by another library. All you need is to define a function ``make_frame(t)`` which returns a HxWx3 numpy array (of 8-bits integers) representing the frame at time t. Here is an example with the graphics library Gizeh: ::import gizeh- import moviepy.editor as mpy+ import moviepy as mpyWIDTH, HEIGHT = (128, 128)diff --git a/docs/getting_started/working_with_matplotlib.rst b/docs/getting_started/working_with_matplotlib.rstindex fbd17897..c9dc684d 100644--- a/docs/getting_started/working_with_matplotlib.rst+++ b/docs/getting_started/working_with_matplotlib.rst@@ -9,7 +9,7 @@ MoviePy allows you to produce custom animations by defining a function that retuAn example of this workflow is below: ::- from moviepy.editor import VideoClip+ from moviepy import VideoClipdef make_frame(t):"""Returns an image of the frame for time t."""@@ -32,7 +32,7 @@ An example of an animation using `matplotlib` can then be as follows: ::import matplotlib.pyplot as pltimport numpy as np- from moviepy.editor import VideoClip+ from moviepy import VideoClipfrom moviepy.video.io.bindings import mplfig_to_npimagex = np.linspace(-2, 2, 200)diff --git a/docs/ref/audiofx.rst b/docs/ref/audiofx.rstindex a9a21449..9282cc5c 100644--- a/docs/ref/audiofx.rst+++ b/docs/ref/audiofx.rst@@ -28,7 +28,7 @@ Or import everything: ::When you type ::- from moviepy.editor import *+ from moviepy import *the module ``audio.fx`` is loaded as ``afx`` and you can use ``afx.volumex``, etc.diff --git a/docs/ref/videofx.rst b/docs/ref/videofx.rstindex 2bdf10c9..fd3b802f 100644--- a/docs/ref/videofx.rst+++ b/docs/ref/videofx.rst@@ -22,7 +22,7 @@ Or import everything: ::When you type: ::- from moviepy.editor import *+ from moviepy import *the module ``video.fx`` is loaded as ``vfx`` and you can use ``vfx.colorx``, ``vfx.resize`` etc.diff --git a/examples/compo_from_image.py b/examples/compo_from_image.pyindex 122f5038..5acb4544 100644--- a/examples/compo_from_image.py+++ b/examples/compo_from_image.py@@ -1,4 +1,4 @@-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.segmenting import find_objects# Load the image specifying the regions.diff --git a/examples/dancing_knights.py b/examples/dancing_knights.pyindex 037249d7..0bf9e68d 100644--- a/examples/dancing_knights.py+++ b/examples/dancing_knights.py@@ -24,7 +24,7 @@ easy to preview and fine-tune each part of the editing.import osimport sys-from moviepy.editor import *+from moviepy import *from moviepy.audio.tools.cuts import find_audio_periodfrom moviepy.video.tools.cuts import find_video_perioddiff --git a/examples/example_with_sound.py b/examples/example_with_sound.pyindex e0ee3341..907a6b6c 100644--- a/examples/example_with_sound.py+++ b/examples/example_with_sound.py@@ -5,7 +5,7 @@ talking at the same time, because it is actually two scenes of a samemovie put together."""-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.drawing import color_splitduration = 6 # duration of the final clipdiff --git a/examples/headblur.py b/examples/headblur.pyindex 142ccb9d..16ea17b6 100644--- a/examples/headblur.py+++ b/examples/headblur.py@@ -1,4 +1,4 @@-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.tracking import manual_trackingfrom moviepy.video.tools.interpolators import Trajectorydiff --git a/examples/logo.py b/examples/logo.pyindex 829744e7..93b46cf9 100644--- a/examples/logo.py+++ b/examples/logo.py@@ -1,6 +1,6 @@import numpy as np-from moviepy.editor import *+from moviepy import *w, h = moviesize = (720, 380)diff --git a/examples/masked_credits.py b/examples/masked_credits.pyindex 8d2989bf..96357203 100644--- a/examples/masked_credits.py+++ b/examples/masked_credits.py@@ -1,4 +1,4 @@-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.credits import credits1# Load the mountains clip, cut it, slow it down, make it look darkerdiff --git a/examples/moving_letters.py b/examples/moving_letters.pyindex f9ce5327..fc7b0d7d 100644--- a/examples/moving_letters.py+++ b/examples/moving_letters.py@@ -1,6 +1,6 @@import numpy as np-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.segmenting import find_objects# WE CREATE THE TEXT THAT IS GOING TO MOVE, WE CENTER IT.diff --git a/examples/painting_effect.py b/examples/painting_effect.pyindex b61d52e7..90d260cc 100644--- a/examples/painting_effect.py+++ b/examples/painting_effect.py@@ -1,6 +1,6 @@""" requires scikit-image installed (for vfx.painting) """-from moviepy.editor import *+from moviepy import *# WE TAKE THE SUBCLIPS WHICH ARE 2 SECONDS BEFORE & AFTER THE FREEZEdiff --git a/examples/soundtrack.py b/examples/soundtrack.pyindex 057b996c..9a1a6f63 100644--- a/examples/soundtrack.py+++ b/examples/soundtrack.py@@ -1,5 +1,5 @@""" A simple test script on how to put a soundtrack to a movie """-from moviepy.editor import *+from moviepy import *# We load a movie and replace the sound with some music:diff --git a/examples/star_worms.py b/examples/star_worms.pyindex ae18db18..8094adcc 100644--- a/examples/star_worms.py+++ b/examples/star_worms.py@@ -8,7 +8,7 @@ background made of stars. Slight fading effect on the text.import numpy as np-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.drawing import color_gradientfrom skimage import transform as tfdiff --git a/examples/the_end.py b/examples/the_end.pyindex 8c38ee72..237bafda 100644--- a/examples/the_end.py+++ b/examples/the_end.py@@ -1,4 +1,4 @@-from moviepy.editor import *+from moviepy import *from moviepy.video.tools.drawing import circleclip = (diff --git a/examples/ukulele_concerto.py b/examples/ukulele_concerto.pyindex e4c6da89..ddae9cd3 100644--- a/examples/ukulele_concerto.py+++ b/examples/ukulele_concerto.py@@ -1,4 +1,4 @@-from moviepy.editor import *+from moviepy import *# UKULELE CLIP, OBTAINED BY CUTTING AND CROPPING# RAW FOOTAGEdiff --git a/moviepy/Clip.py b/moviepy/Clip.pyindex 5e4bbc6c..fc5efba3 100644--- a/moviepy/Clip.py+++ b/moviepy/Clip.py@@ -475,7 +475,7 @@ class Clip:>>> # prints the maximum of red that is contained>>> # on the first line of each frame of the clip.- >>> from moviepy.editor import VideoFileClip+ >>> from moviepy import VideoFileClip>>> myclip = VideoFileClip('myvideo.mp4')>>> print ( [frame[0,:,0].max()for frame in myclip.iter_frames()])diff --git a/moviepy/__init__.py b/moviepy/__init__.pyindex 58f3ace6..dfbde644 100644--- a/moviepy/__init__.py+++ b/moviepy/__init__.py@@ -1 +1,108 @@-from .version import __version__+"""+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, so that instead of+``clip.fx(vfx.resize, 2)`` or ``vfx.resize(clip, 2)``+you can write ``clip.resize(2)``.++"""++import inspect++from moviepy.version import __version__++# Clips+from moviepy.video.VideoClip import (+ VideoClip,+ ImageClip,+ ColorClip,+ TextClip,+ BitmapClip,+)+from moviepy.video.io.VideoFileClip import VideoFileClip+from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array+from moviepy.video.io.ImageSequenceClip import ImageSequenceClip++from moviepy.video.compositing.concatenate import concatenate_videoclips++from moviepy.video.io.downloader import download_webfile++from moviepy.audio.AudioClip import (+ AudioClip,+ CompositeAudioClip,+ concatenate_audioclips,+)+from moviepy.audio.io.AudioFileClip import AudioFileClip++# FX+from moviepy.video import fx as vfx+from moviepy.audio import fx as afx+from moviepy.video.compositing import transitions as transfx++# Tools+from moviepy.video import tools as videotools+from moviepy.video.io import ffmpeg_tools+from moviepy.tools import convert_to_seconds++# 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 = (+ 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)+++def preview(self, *args, **kwargs):+ """NOT AVAILABLE: clip.preview requires importing from moviepy.editor"""+ raise ImportError("clip.preview requires importing from moviepy.editor")+++def show(self, *args, **kwargs):+ """NOT AVAILABLE: clip.show requires importing from moviepy.editor"""+ raise ImportError("clip.show requires importing from moviepy.editor")+++VideoClip.preview = preview+VideoClip.show = show+AudioClip.preview = preview++# Cleanup namespace+del audio_fxs, video_fxs, name, function, preview, show+del inspect++# Importing with `from moviepy import *` will only import these names+__all__ = [+ "__version__",+ "VideoClip",+ "ImageClip",+ "ColorClip",+ "TextClip",+ "BitmapClip",+ "VideoFileClip",+ "CompositeVideoClip",+ "clips_array",+ "ImageSequenceClip",+ "concatenate_videoclips",+ "download_webfile",+ "AudioClip",+ "CompositeAudioClip",+ "concatenate_audioclips",+ "AudioFileClip",+ "vfx",+ "afx",+ "transfx",+ "videotools",+ "ffmpeg_tools",+ "convert_to_seconds",+]diff --git a/moviepy/audio/fx/audio_loop.py b/moviepy/audio/fx/audio_loop.pyindex e8a3785f..375c95a1 100644--- a/moviepy/audio/fx/audio_loop.py+++ b/moviepy/audio/fx/audio_loop.py@@ -12,7 +12,7 @@ def audio_loop(clip, n_loops=None, duration=None):Examples========- >>> from moviepy.editor import *+ >>> from moviepy import *>>> videoclip = VideoFileClip('myvideo.mp4')>>> music = AudioFileClip('music.ogg')>>> audio = afx.audio_loop( music, duration=videoclip.duration)diff --git a/moviepy/audio/fx/audio_normalize.py b/moviepy/audio/fx/audio_normalize.pyindex 8d088134..4076346c 100644--- a/moviepy/audio/fx/audio_normalize.py+++ b/moviepy/audio/fx/audio_normalize.py@@ -13,7 +13,7 @@ def audio_normalize(clip):Examples========- >>> from moviepy.editor import *+ >>> from moviepy import *>>> videoclip = VideoFileClip('myvideo.mp4').fx(afx.audio_normalize)"""diff --git a/moviepy/audio/fx/volumex.py b/moviepy/audio/fx/volumex.pyindex f00c1c46..84643355 100644--- a/moviepy/audio/fx/volumex.py+++ b/moviepy/audio/fx/volumex.py@@ -6,15 +6,14 @@ def volumex(clip, factor):"""Returns a clip with audio volume multiplied by thevalue `factor`. Can be applied to both audio and video clips.- This effect is loaded as a clip method when you use moviepy.editor,- so you can just write ``clip.volumex(2)``+ This effect is loaded as a clip method so you can just write ``clip.volumex(2)``Examples--------->>> new_clip = volumex(clip, 2.0) # doubles audio volume>>> new_clip = clip.fx( volumex, 0.5) # half audio, use with fx- >>> new_clip = clip.volumex(2) # only if you used "moviepy.editor"+ >>> new_clip = clip.volumex(2)"""return clip.transform(lambda get_frame, t: factor * get_frame(t), keep_duration=Truediff --git a/moviepy/editor.py b/moviepy/editor.pyindex c7ec4a9e..041b7bf6 100644--- a/moviepy/editor.py+++ b/moviepy/editor.py@@ -1,121 +1,51 @@"""-This file is meant to make it easy to load the main features of-MoviePy by simply typing:+This file is meant to make it easy to load the features of+MoviePy that you will use for live editing by simply typing:>>> from moviepy.editor import *-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)-we can write->>> clip.resize(2)--It also starts a PyGame session (if PyGame is installed) and enables-clip.preview().+- Starts a pygame session to enable ``clip.show()`` and ``clip.preview()`` if pygame is installed+- Enables ``clip.ipython_display()`` if in an IPython Notebook+- Allows the use of ``sliders`` if Matplotlib is installed"""-__all__ = [- "afx",- "AudioClip",- "AudioFileClip",- "BitmapClip",- "clips_array",- "ColorClip",- "CompositeAudioClip",- "CompositeVideoClip",- "concatenate_audioclips",- "concatenate_videoclips",- "convert_to_seconds",- "download_webfile",- "ffmpeg_tools",- "ImageClip",- "ImageSequenceClip",- "ipython_display",- "TextClip",- "transfx",- "vfx",- "VideoClip",- "VideoFileClip",- "videotools",-]--# Note that these imports could have been performed in the __init__.py-# file, but this would make the loading of moviepy slower.-import os-import inspect---# Hide the welcome message from pygame: https://github.com/pygame/pygame/issues/542-os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"--# Clips-from .video.io.VideoFileClip import VideoFileClip-from .video.io.ImageSequenceClip import ImageSequenceClip-from .video.io.downloader import download_webfile-from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip, BitmapClip-from .video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array-from .video.compositing.concatenate import concatenate_videoclips--from .audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips-from .audio.io.AudioFileClip import AudioFileClip--# FX--import moviepy.video.fx as vfx-import moviepy.audio.fx as afx-import moviepy.video.compositing.transitions as transfx-# Tools--import moviepy.video.tools as videotools-import moviepy.video.io.ffmpeg_tools as ffmpeg_tools+from . import *from .video.io.html_tools import ipython_display-from .tools import convert_to_secondstry:from .video.io.sliders import sliders-- __all__.append("sliders")except ImportError:- pass--# 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 = (- 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)+ def sliders(*args, **kwargs):+ """NOT AVAILABLE : sliders requires matplotlib installed."""+ raise ImportError("sliders requires matplotlib installed")# adds easy ipython integrationVideoClip.ipython_display = ipython_displayAudioClip.ipython_display = ipython_display++# -----------------------------------------------------------------# Previews: try to import pygame, else make methods which raise# exceptions saying to install PyGame+# Hide the welcome message from pygame: https://github.com/pygame/pygame/issues/542+os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"# Add methods preview and show (only if pygame installed)try:- from moviepy.video.io.preview import show, preview+ from .video.io.preview import show, previewexcept ImportError:def preview(self, *args, **kwargs):- """NOT AVAILABLE : clip.preview requires Pygame installed."""+ """NOT AVAILABLE: clip.preview requires Pygame installed"""raise ImportError("clip.preview requires Pygame installed")def show(self, *args, **kwargs):- """NOT AVAILABLE : clip.show requires Pygame installed."""+ """NOT AVAILABLE: clip.show requires Pygame installed"""raise ImportError("clip.show requires Pygame installed")@@ -123,12 +53,14 @@ VideoClip.preview = previewVideoClip.show = showtry:- from moviepy.audio.io.preview import preview+ from .audio.io.preview import previewexcept ImportError:def preview(self, *args, **kwargs):- """ NOT AVAILABLE : clip.preview requires Pygame installed."""+ """ NOT AVAILABLE: clip.preview requires Pygame installed"""raise ImportError("clip.preview requires Pygame installed")AudioClip.preview = preview++__all__ = ["ipython_display", "sliders"]diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex 5ca43cd8..10f44270 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -277,7 +277,7 @@ class VideoClip(Clip):Examples========- >>> from moviepy.editor import VideoFileClip+ >>> from moviepy import VideoFileClip>>> clip = VideoFileClip("myvideo.mp4").subclip(100,120)>>> clip.write_videofile("my_new_video.mp4")>>> clip.close()diff --git a/moviepy/video/compositing/transitions.py b/moviepy/video/compositing/transitions.pyindex 4d1ff6d3..0f5083a2 100644--- a/moviepy/video/compositing/transitions.py+++ b/moviepy/video/compositing/transitions.py@@ -1,7 +1,6 @@"""Here is the current catalogue. These are meantto be used with clip.fx. There are available as transfx.crossfadein etc.-if you load them with ``from moviepy.editor import *``"""from moviepy.decorators import add_mask_if_none, requires_duration@@ -60,7 +59,7 @@ def slide_in(clip, duration, side):Examples=========- >>> from moviepy.editor import *+ >>> from moviepy import *>>> clips = [... make a list of clips]>>> slided_clips = [CompositeVideoClip([clip.fx(transfx.slide_in, duration=1, side='left')])@@ -102,7 +101,7 @@ def slide_out(clip, duration, side):Examples=========- >>> from moviepy.editor import *+ >>> from moviepy import *>>> clips = [... make a list of clips]>>> slided_clips = [CompositeVideoClip([clip.fx(transfx.slide_out, duration=1, side='left')])diff --git a/moviepy/video/io/html_tools.py b/moviepy/video/io/html_tools.pyindex dff90f59..bc6e2bbe 100644--- a/moviepy/video/io/html_tools.py+++ b/moviepy/video/io/html_tools.py@@ -73,21 +73,7 @@ def html_embed(Examples=========-- >>> import moviepy.editor as mpy- >>> # later ...- >>> clip.write_videofile("test.mp4")- >>> mpy.ipython_display("test.mp4", width=360)-- >>> clip.audio.write_audiofile('test.ogg') # Sound !- >>> mpy.ipython_display('test.ogg')-- >>> clip.write_gif("test.gif")- >>> mpy.ipython_display('test.gif')-- >>> clip.save_frame("first_frame.jpeg")- >>> mpy.ipython_display("first_frame.jpeg")-+ TODO Create example based on ipython_display examples"""if rd_kwargs is None:@@ -218,19 +204,16 @@ def ipython_display(Examples=========- >>> import moviepy.editor as mpy+ >>> from moviepy.editor import *>>> # later ...- >>> clip.write_videofile("test.mp4")- >>> mpy.ipython_display("test.mp4", width=360)-- >>> clip.audio.write_audiofile('test.ogg') # Sound !- >>> mpy.ipython_display('test.ogg')+ >>> clip.ipython_display(width=360)+ >>> clip.audio.ipython_display()>>> clip.write_gif("test.gif")- >>> mpy.ipython_display('test.gif')+ >>> ipython_display('test.gif')>>> clip.save_frame("first_frame.jpeg")- >>> mpy.ipython_display("first_frame.jpeg")+ >>> ipython_display("first_frame.jpeg")"""if not ipython_available:diff --git a/moviepy/video/tools/cuts.py b/moviepy/video/tools/cuts.pyindex d9796bd8..33683797 100644--- a/moviepy/video/tools/cuts.py+++ b/moviepy/video/tools/cuts.py@@ -126,7 +126,7 @@ class FramesMatches(list):We find all matching frames in a given video and turn the best match witha duration of 1.5s or more into a GIF:- >>> from moviepy.editor import VideoFileClip+ >>> from moviepy import VideoFileClip>>> from moviepy.video.tools.cuts import FramesMatches>>> clip = VideoFileClip("foo.mp4").resize(width=200)>>> matches = FramesMatches.from_clip(clip, distance_threshold=10, max_duration=3) # will take timediff --git a/moviepy/video/tools/tracking.py b/moviepy/video/tools/tracking.pyindex da3a8285..313f2874 100644--- a/moviepy/video/tools/tracking.py+++ b/moviepy/video/tools/tracking.py@@ -63,7 +63,7 @@ def manual_tracking(clip, t1=None, t2=None, fps=None, n_objects=1, savefile=NoneExamples---------- >>> from moviepy.editor import VideoFileClip+ >>> from moviepy import VideoFileClip>>> from moviepy.video.tools.tracking import manual_tracking>>> clip = VideoFileClip("myvideo.mp4")>>> # manually indicate 3 trajectories, save them to a filediff --git a/tests/test_compositing.py b/tests/test_compositing.pyindex 0d0b21e0..f46c361d 100644--- a/tests/test_compositing.py+++ b/tests/test_compositing.py@@ -4,7 +4,7 @@ from os.path import joinimport pytest-from moviepy.editor import *+from moviepy import *from moviepy.utils import close_all_clipsfrom tests.test_helper import TMP_DIRdiff --git a/tests/test_fx.py b/tests/test_fx.pyindex 96ee6e67..40f6fd53 100644--- a/tests/test_fx.py+++ b/tests/test_fx.py@@ -3,35 +3,32 @@ import osimport numpy as npimport pytest-from moviepy.audio.AudioClip import AudioClip-from moviepy.audio.fx.audio_normalize import audio_normalize-from moviepy.audio.io.AudioFileClip import AudioFileClip+from moviepy import AudioClip, AudioFileClip, BitmapClip, ColorClip, VideoFileClip+from moviepy.audio.fx import audio_normalizefrom moviepy.utils import close_all_clips-from moviepy.video.VideoClip import BitmapClip, ColorClip-from moviepy.video.fx.blackwhite import blackwhite-from moviepy.video.fx.blink import blink-from moviepy.video.fx.colorx import colorx-from moviepy.video.fx.crop import crop-from moviepy.video.fx.even_size import even_size-from moviepy.video.fx.fadein import fadein-from moviepy.video.fx.fadeout import fadeout-from moviepy.video.fx.freeze import freeze-from moviepy.video.fx.freeze_region import freeze_region-from moviepy.video.fx.invert_colors import invert_colors-from moviepy.video.fx.loop import loop-from moviepy.video.fx.lum_contrast import lum_contrast-from moviepy.video.fx.make_loopable import make_loopable-from moviepy.video.fx.margin import margin-from moviepy.video.fx.mirror_x import mirror_x-from moviepy.video.fx.mirror_y import mirror_y-from moviepy.video.fx.resize import resize-from moviepy.video.fx.rotate import rotate-from moviepy.video.fx.speedx import speedx-from moviepy.video.fx.time_mirror import time_mirror-from moviepy.video.fx.time_symmetrize import time_symmetrize-from moviepy.video.io.VideoFileClip import VideoFileClip-from moviepy.video.VideoClip import ColorClip-from moviepy.video.fx.supersample import supersample+from moviepy.video.fx import (+ blackwhite,+ blink,+ colorx,+ crop,+ even_size,+ fadein,+ fadeout,+ freeze,+ freeze_region,+ invert_colors,+ loop,+ lum_contrast,+ make_loopable,+ margin,+ mirror_x,+ mirror_y,+ resize,+ rotate,+ speedx,+ time_mirror,+ time_symmetrize,+)from tests.test_helper import TMP_DIRdiff --git a/tests/test_issues.py b/tests/test_issues.pyindex 81380ffa..44b21a86 100644--- a/tests/test_issues.py+++ b/tests/test_issues.py@@ -3,7 +3,7 @@import pytestimport os-from moviepy.editor import *+from moviepy import *from moviepy.utils import close_all_clipsfrom moviepy.video.fx.blink import blinkfrom moviepy.video.fx.resize import resize