# Table of Contents - [MoviePy documentation — MoviePy documentation](#moviepy-documentation-moviepy-documentation) - [Getting started with MoviePy — MoviePy documentation](#getting-started-with-moviepy-moviepy-documentation) - [The MoviePy User Guide — MoviePy documentation](#the-moviepy-user-guide-moviepy-documentation) - [Updating from v1.X to v2.X — MoviePy documentation](#updating-from-v1-x-to-v2-x-moviepy-documentation) - [The MoviePy Developers Guide — MoviePy documentation](#the-moviepy-developers-guide-moviepy-documentation) - [Api Reference — MoviePy documentation](#api-reference-moviepy-documentation) - [Unknown](#unknown) - [Installation — MoviePy documentation](#installation-moviepy-documentation) - [Loading resources as clips — MoviePy documentation](#loading-resources-as-clips-moviepy-documentation) - [Quick presentation — MoviePy documentation](#quick-presentation-moviepy-documentation) - [Installation for MoviePy developers — MoviePy documentation](#installation-for-moviepy-developers-moviepy-documentation) - [Modifying clips and apply effects — MoviePy documentation](#modifying-clips-and-apply-effects-moviepy-documentation) - [Creating your own effects — MoviePy documentation](#creating-your-own-effects-moviepy-documentation) - [MoviePy Docker — MoviePy documentation](#moviepy-docker-moviepy-documentation) - [MoviePy in 10 Minutes: Creating a Trailer from “Big Buck Bunny” — MoviePy documentation](#moviepy-in-10-minutes-creating-a-trailer-from-big-buck-bunny-moviepy-documentation) - [MoviePy’s Contribution Guidelines — MoviePy documentation](#moviepy-s-contribution-guidelines-moviepy-documentation) - [Publishing a New Version of MoviePy — MoviePy documentation](#publishing-a-new-version-of-moviepy-moviepy-documentation) - [Compositing multiple clips — MoviePy documentation](#compositing-multiple-clips-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Previewing and saving video clips — MoviePy documentation](#previewing-and-saving-video-clips-moviepy-documentation) - [FAQ and troubleshooting — MoviePy documentation](#faq-and-troubleshooting-moviepy-documentation) - [moviepy — MoviePy documentation](#moviepy-moviepy-documentation) - [moviepy.video.tools.subtitles.file_to_subtitles — MoviePy documentation](#moviepy-video-tools-subtitles-file-to-subtitles-moviepy-documentation) - [moviepy.Clip — MoviePy documentation](#moviepy-clip-moviepy-documentation) - [Unknown](#unknown) - [moviepy.Clip.Clip — MoviePy documentation](#moviepy-clip-clip-moviepy-documentation) - [moviepy.Effect — MoviePy documentation](#moviepy-effect-moviepy-documentation) - [moviepy.audio — MoviePy documentation](#moviepy-audio-moviepy-documentation) - [moviepy.audio.AudioClip — MoviePy documentation](#moviepy-audio-audioclip-moviepy-documentation) - [moviepy.audio.AudioClip.AudioArrayClip — MoviePy documentation](#moviepy-audio-audioclip-audioarrayclip-moviepy-documentation) - [Unknown](#unknown) - [moviepy.audio.AudioClip.AudioClip — MoviePy documentation](#moviepy-audio-audioclip-audioclip-moviepy-documentation) - [moviepy.audio.AudioClip.concatenate_audioclips — MoviePy documentation](#moviepy-audio-audioclip-concatenate-audioclips-moviepy-documentation) - [moviepy.audio.AudioClip.CompositeAudioClip — MoviePy documentation](#moviepy-audio-audioclip-compositeaudioclip-moviepy-documentation) - [moviepy.audio.fx.AudioDelay — MoviePy documentation](#moviepy-audio-fx-audiodelay-moviepy-documentation) - [moviepy.audio.fx — MoviePy documentation](#moviepy-audio-fx-moviepy-documentation) - [moviepy.audio.fx.AudioFadeOut — MoviePy documentation](#moviepy-audio-fx-audiofadeout-moviepy-documentation) - [moviepy.audio.fx.AudioFadeIn — MoviePy documentation](#moviepy-audio-fx-audiofadein-moviepy-documentation) - [moviepy.audio.fx.AudioLoop — MoviePy documentation](#moviepy-audio-fx-audioloop-moviepy-documentation) - [moviepy.audio.fx.AudioNormalize — MoviePy documentation](#moviepy-audio-fx-audionormalize-moviepy-documentation) - [moviepy.audio.fx.MultiplyStereoVolume — MoviePy documentation](#moviepy-audio-fx-multiplystereovolume-moviepy-documentation) - [moviepy.audio.fx.MultiplyVolume — MoviePy documentation](#moviepy-audio-fx-multiplyvolume-moviepy-documentation) - [moviepy.audio.io — MoviePy documentation](#moviepy-audio-io-moviepy-documentation) - [moviepy.audio.io.AudioFileClip — MoviePy documentation](#moviepy-audio-io-audiofileclip-moviepy-documentation) - [moviepy.audio.io.ffmpeg_audiowriter — MoviePy documentation](#moviepy-audio-io-ffmpeg-audiowriter-moviepy-documentation) - [moviepy.audio.io.ffplay_audiopreviewer — MoviePy documentation](#moviepy-audio-io-ffplay-audiopreviewer-moviepy-documentation) - [moviepy.audio.io.readers — MoviePy documentation](#moviepy-audio-io-readers-moviepy-documentation) - [moviepy.audio.tools.cuts — MoviePy documentation](#moviepy-audio-tools-cuts-moviepy-documentation) - [moviepy.audio.tools — MoviePy documentation](#moviepy-audio-tools-moviepy-documentation) - [moviepy.config — MoviePy documentation](#moviepy-config-moviepy-documentation) - [moviepy.config.check — MoviePy documentation](#moviepy-config-check-moviepy-documentation) - [moviepy.config.try_cmd — MoviePy documentation](#moviepy-config-try-cmd-moviepy-documentation) - [moviepy.decorators — MoviePy documentation](#moviepy-decorators-moviepy-documentation) - [moviepy.decorators.add_mask_if_none — MoviePy documentation](#moviepy-decorators-add-mask-if-none-moviepy-documentation) - [moviepy.decorators.apply_to_audio — MoviePy documentation](#moviepy-decorators-apply-to-audio-moviepy-documentation) - [moviepy.decorators.apply_to_mask — MoviePy documentation](#moviepy-decorators-apply-to-mask-moviepy-documentation) - [moviepy.decorators.audio_video_effect — MoviePy documentation](#moviepy-decorators-audio-video-effect-moviepy-documentation) - [moviepy.decorators.convert_parameter_to_seconds — MoviePy documentation](#moviepy-decorators-convert-parameter-to-seconds-moviepy-documentation) - [moviepy.decorators.convert_masks_to_RGB — MoviePy documentation](#moviepy-decorators-convert-masks-to-rgb-moviepy-documentation) - [moviepy.decorators.outplace — MoviePy documentation](#moviepy-decorators-outplace-moviepy-documentation) - [moviepy.decorators.convert_path_to_string — MoviePy documentation](#moviepy-decorators-convert-path-to-string-moviepy-documentation) - [moviepy.decorators.preprocess_args — MoviePy documentation](#moviepy-decorators-preprocess-args-moviepy-documentation) - [moviepy.decorators.requires_fps — MoviePy documentation](#moviepy-decorators-requires-fps-moviepy-documentation) - [moviepy.decorators.requires_duration — MoviePy documentation](#moviepy-decorators-requires-duration-moviepy-documentation) - [moviepy.decorators.use_clip_fps_by_default — MoviePy documentation](#moviepy-decorators-use-clip-fps-by-default-moviepy-documentation) - [moviepy.tools — MoviePy documentation](#moviepy-tools-moviepy-documentation) - [moviepy.tools.close_all_clips — MoviePy documentation](#moviepy-tools-close-all-clips-moviepy-documentation) - [moviepy.tools.convert_to_seconds — MoviePy documentation](#moviepy-tools-convert-to-seconds-moviepy-documentation) - [moviepy.tools.compute_position — MoviePy documentation](#moviepy-tools-compute-position-moviepy-documentation) - [moviepy.tools.deprecated_version_of — MoviePy documentation](#moviepy-tools-deprecated-version-of-moviepy-documentation) - [moviepy.tools.ffmpeg_escape_filename — MoviePy documentation](#moviepy-tools-ffmpeg-escape-filename-moviepy-documentation) - [moviepy.tools.cross_platform_popen_params — MoviePy documentation](#moviepy-tools-cross-platform-popen-params-moviepy-documentation) - [moviepy.tools.no_display_available — MoviePy documentation](#moviepy-tools-no-display-available-moviepy-documentation) - [moviepy.tools.find_extension — MoviePy documentation](#moviepy-tools-find-extension-moviepy-documentation) - [moviepy.tools.subprocess_call — MoviePy documentation](#moviepy-tools-subprocess-call-moviepy-documentation) - [moviepy.video — MoviePy documentation](#moviepy-video-moviepy-documentation) - [moviepy.video.VideoClip.BitmapClip — MoviePy documentation](#moviepy-video-videoclip-bitmapclip-moviepy-documentation) - [moviepy.video.VideoClip — MoviePy documentation](#moviepy-video-videoclip-moviepy-documentation) - [moviepy.video.VideoClip.ColorClip — MoviePy documentation](#moviepy-video-videoclip-colorclip-moviepy-documentation) - [moviepy.video.VideoClip.DataVideoClip — MoviePy documentation](#moviepy-video-videoclip-datavideoclip-moviepy-documentation) - [moviepy.video.VideoClip.ImageClip — MoviePy documentation](#moviepy-video-videoclip-imageclip-moviepy-documentation) - [moviepy.video.VideoClip.TextClip — MoviePy documentation](#moviepy-video-videoclip-textclip-moviepy-documentation) - [moviepy.video.VideoClip.UpdatedVideoClip — MoviePy documentation](#moviepy-video-videoclip-updatedvideoclip-moviepy-documentation) - [moviepy.video.compositing — MoviePy documentation](#moviepy-video-compositing-moviepy-documentation) - [moviepy.video.fx.AccelDecel — MoviePy documentation](#moviepy-video-fx-acceldecel-moviepy-documentation) - [moviepy.video.fx.BlackAndWhite — MoviePy documentation](#moviepy-video-fx-blackandwhite-moviepy-documentation) - [moviepy.video.VideoClip.VideoClip — MoviePy documentation](#moviepy-video-videoclip-videoclip-moviepy-documentation) - [moviepy.video.compositing.CompositeVideoClip — MoviePy documentation](#moviepy-video-compositing-compositevideoclip-moviepy-documentation) - [moviepy.video.fx.Blink — MoviePy documentation](#moviepy-video-fx-blink-moviepy-documentation) - [moviepy.video.fx.Crop — MoviePy documentation](#moviepy-video-fx-crop-moviepy-documentation) - [moviepy.video.fx — MoviePy documentation](#moviepy-video-fx-moviepy-documentation) - [moviepy.video.fx.CrossFadeIn — MoviePy documentation](#moviepy-video-fx-crossfadein-moviepy-documentation) - [moviepy.video.fx.CrossFadeOut — MoviePy documentation](#moviepy-video-fx-crossfadeout-moviepy-documentation) - [moviepy.video.fx.EvenSize — MoviePy documentation](#moviepy-video-fx-evensize-moviepy-documentation) - [moviepy.video.fx.FadeIn — MoviePy documentation](#moviepy-video-fx-fadein-moviepy-documentation) - [moviepy.video.fx.FadeOut — MoviePy documentation](#moviepy-video-fx-fadeout-moviepy-documentation) - [moviepy.video.fx.FreezeRegion — MoviePy documentation](#moviepy-video-fx-freezeregion-moviepy-documentation) - [moviepy.video.fx.Freeze — MoviePy documentation](#moviepy-video-fx-freeze-moviepy-documentation) - [moviepy.video.fx.HeadBlur — MoviePy documentation](#moviepy-video-fx-headblur-moviepy-documentation) - [moviepy.video.fx.GammaCorrection — MoviePy documentation](#moviepy-video-fx-gammacorrection-moviepy-documentation) - [moviepy.video.fx.InvertColors — MoviePy documentation](#moviepy-video-fx-invertcolors-moviepy-documentation) - [moviepy.video.fx.Loop — MoviePy documentation](#moviepy-video-fx-loop-moviepy-documentation) - [moviepy.video.fx.LumContrast — MoviePy documentation](#moviepy-video-fx-lumcontrast-moviepy-documentation) - [moviepy.video.fx.MaskColor — MoviePy documentation](#moviepy-video-fx-maskcolor-moviepy-documentation) - [moviepy.video.fx.MakeLoopable — MoviePy documentation](#moviepy-video-fx-makeloopable-moviepy-documentation) - [moviepy.video.fx.Margin — MoviePy documentation](#moviepy-video-fx-margin-moviepy-documentation) - [moviepy.video.fx.MasksAnd — MoviePy documentation](#moviepy-video-fx-masksand-moviepy-documentation) - [moviepy.video.fx.MasksOr — MoviePy documentation](#moviepy-video-fx-masksor-moviepy-documentation) - [moviepy.video.fx.MirrorY — MoviePy documentation](#moviepy-video-fx-mirrory-moviepy-documentation) - [moviepy.video.fx.MirrorX — MoviePy documentation](#moviepy-video-fx-mirrorx-moviepy-documentation) - [moviepy.video.fx.MultiplyColor — MoviePy documentation](#moviepy-video-fx-multiplycolor-moviepy-documentation) - [moviepy.video.fx.MultiplySpeed — MoviePy documentation](#moviepy-video-fx-multiplyspeed-moviepy-documentation) - [moviepy.video.fx.Resize — MoviePy documentation](#moviepy-video-fx-resize-moviepy-documentation) - [moviepy.video.fx.Scroll — MoviePy documentation](#moviepy-video-fx-scroll-moviepy-documentation) - [moviepy.video.fx.Rotate — MoviePy documentation](#moviepy-video-fx-rotate-moviepy-documentation) - [moviepy.video.fx.Painting — MoviePy documentation](#moviepy-video-fx-painting-moviepy-documentation) - [moviepy.video.fx.SlideIn — MoviePy documentation](#moviepy-video-fx-slidein-moviepy-documentation) - [moviepy.video.fx.SlideOut — MoviePy documentation](#moviepy-video-fx-slideout-moviepy-documentation) - [moviepy.video.io — MoviePy documentation](#moviepy-video-io-moviepy-documentation) - [moviepy.video.fx.SuperSample — MoviePy documentation](#moviepy-video-fx-supersample-moviepy-documentation) - [moviepy.video.fx.TimeSymmetrize — MoviePy documentation](#moviepy-video-fx-timesymmetrize-moviepy-documentation) - [moviepy.video.fx.TimeMirror — MoviePy documentation](#moviepy-video-fx-timemirror-moviepy-documentation) - [moviepy.video.io.ImageSequenceClip — MoviePy documentation](#moviepy-video-io-imagesequenceclip-moviepy-documentation) - [moviepy.video.io.VideoFileClip — MoviePy documentation](#moviepy-video-io-videofileclip-moviepy-documentation) - [moviepy.video.io.display_in_notebook — MoviePy documentation](#moviepy-video-io-display-in-notebook-moviepy-documentation) - [moviepy.video.io.ffmpeg_reader — MoviePy documentation](#moviepy-video-io-ffmpeg-reader-moviepy-documentation) - [moviepy.video.io.ffmpeg_tools — MoviePy documentation](#moviepy-video-io-ffmpeg-tools-moviepy-documentation) - [moviepy.video.io.ffmpeg_writer — MoviePy documentation](#moviepy-video-io-ffmpeg-writer-moviepy-documentation) - [moviepy.video.io.ffplay_previewer — MoviePy documentation](#moviepy-video-io-ffplay-previewer-moviepy-documentation) - [moviepy.video.io.gif_writers — MoviePy documentation](#moviepy-video-io-gif-writers-moviepy-documentation) - [moviepy.video.tools — MoviePy documentation](#moviepy-video-tools-moviepy-documentation) - [moviepy.video.tools.credits — MoviePy documentation](#moviepy-video-tools-credits-moviepy-documentation) - [moviepy.video.tools.cuts — MoviePy documentation](#moviepy-video-tools-cuts-moviepy-documentation) - [moviepy.video.tools.drawing — MoviePy documentation](#moviepy-video-tools-drawing-moviepy-documentation) - [moviepy.video.tools.interpolators — MoviePy documentation](#moviepy-video-tools-interpolators-moviepy-documentation) - [moviepy.video.tools.subtitles — MoviePy documentation](#moviepy-video-tools-subtitles-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.video.tools.subtitles.SubtitlesClip — MoviePy documentation](#moviepy-video-tools-subtitles-subtitlesclip-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.video.io.VideoFileClip.VideoFileClip — MoviePy documentation](#moviepy-video-io-videofileclip-videofileclip-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.video.io.ImageSequenceClip.ImageSequenceClip — MoviePy documentation](#moviepy-video-io-imagesequenceclip-imagesequenceclip-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips — MoviePy documentation](#moviepy-video-compositing-compositevideoclip-concatenate-videoclips-moviepy-documentation) - [moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip — MoviePy documentation](#moviepy-video-compositing-compositevideoclip-compositevideoclip-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.audio.io.readers.FFMPEG_AudioReader — MoviePy documentation](#moviepy-audio-io-readers-ffmpeg-audioreader-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview — MoviePy documentation](#moviepy-audio-io-ffplay-audiopreviewer-ffplay-audiopreview-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter — MoviePy documentation](#moviepy-audio-io-ffmpeg-audiowriter-ffmpeg-audiowriter-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [moviepy.audio.tools.cuts.find_audio_period — MoviePy documentation](#moviepy-audio-tools-cuts-find-audio-period-moviepy-documentation) - [Unknown](#unknown) - [moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite — MoviePy documentation](#moviepy-audio-io-ffmpeg-audiowriter-ffmpeg-audiowrite-moviepy-documentation) - [Unknown](#unknown) - [moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer — MoviePy documentation](#moviepy-audio-io-ffplay-audiopreviewer-ffplay-audiopreviewer-moviepy-documentation) - [Unknown](#unknown) - [moviepy.audio.io.AudioFileClip.AudioFileClip — MoviePy documentation](#moviepy-audio-io-audiofileclip-audiofileclip-moviepy-documentation) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) --- # MoviePy documentation — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") MoviePy documentation[#](#moviepy-documentation "Permalink to this heading") ============================================================================= [![_images/logo.png](_images/logo.png)](_images/logo.png) **Date**: Jan 26, 2025 **Version**: **Useful links**: [Binary Installers](https://pypi.org/project/moviepy/) | [Source Repository](https://github.com/Zulko/moviepy) | [Issues & Ideas](https://github.com/Zulko/moviepy) | [Q&A Support](https://www.reddit.com/r/moviepy/) | MoviePy is the [Python](https://www.python.org/) reference tool for video editing automation! It’s an open source, MIT-licensed library offering user-friendly video editing and manipulation tools for the [Python](https://www.python.org/) programming language. ![](_images/index_getting_started.svg) Getting started New to _MoviePy_? Check out the getting started guides. They contain instructions to install _MoviePy_ as well as introduction concepts and tutorials. [To the starting guide](getting_started/index.html#getting-started) ![](_images/index_user_guide.svg) User guide The user guide provides in-depth information on the key concepts of _MoviePy_ with useful background information and explanation. [To the user guide](user_guide/index.html#user-guide) ![](_images/index_api.svg) API reference The reference guide contains a detailed description of the _MoviePy_ API. The reference describes how the methods work and which parameters can be used. It assumes that you have an understanding of the key concepts. [To the reference guide](reference/index.html#reference-manual) ![](_images/index_contribute.svg) Developer guide Saw a typo in the documentation? Want to improve existing functionalities? The contributing guidelines will guide you through the process of improving _MoviePy_. [To the development guide](developer_guide/index.html#developer-guide) Contribute![#](#contribute "Permalink to this heading") -------------------------------------------------------- MoviePy is an open source software originally written by [Zulko](https://github.com/Zulko/) and released under the MIT licence. It works on Windows, Mac, and Linux. [Tweet](https://twitter.com/share) On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/index.rst) [Show Source](_sources/index.rst.txt) --- # Getting started with MoviePy — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Getting started with MoviePy[#](#getting-started-with-moviepy "Permalink to this heading") =========================================================================================== This section explain everything you need to start editing with MoviePy. To go further, have a look at the [The MoviePy User Guide](../user_guide/index.html#user-guide) and the [Api Reference](../reference/index.html#reference-manual) . * [Installation](install.html) * [Quick presentation](quick_presentation.html) * [MoviePy in 10 Minutes: Creating a Trailer from “Big Buck Bunny”](moviepy_10_minutes.html) * [MoviePy Docker](docker.html) * [Updating from v1.X to v2.X](updating_to_v2.html) * [FAQ and troubleshooting](FAQ.html) [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/index.rst) [Show Source](../_sources/getting_started/index.rst.txt) --- # The MoviePy User Guide — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") The MoviePy User Guide[#](#the-moviepy-user-guide "Permalink to this heading") =============================================================================== The User Guide covers all of MoviePy’s main concepts grouped by tasks (loading, editing, composing, rendering), with a presentation of the different concept/elements relative to the tasks along with short code example. It is a good place for users wishing to understand more precisely one of these aspects and to discover the different MoviePy elements relative to it. For users wanting to have a quick overview of how to use MoviePy, a better place to start is the [Getting started with MoviePy](../getting_started/index.html#getting-started) section, and more specifically the [MoviePy in 10 Minutes: Creating a Trailer from “Big Buck Bunny”](../getting_started/moviepy_10_minutes.html#moviepy-10-minutes) tutorial. For a full overview of MoviePy, see the [Api Reference](../reference/index.html#reference-manual) . * [Loading resources as clips](loading.html) * [Modifying clips and apply effects](modifying.html) * [Creating your own effects](create_effects.html) * [Compositing multiple clips](compositing.html) * [Previewing and saving video clips](rendering.html) [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/user_guide/index.rst) [Show Source](../_sources/user_guide/index.rst.txt) --- # Updating from v1.X to v2.X — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Updating from v1.X to v2.X[#](#updating-from-v1-x-to-v2-x "Permalink to this heading") ======================================================================================= MoviePy v2.0 has undergone some large changes with the aim of making the API more consistent and intuitive. In order to do so multiple breaking changes have been made. Therefore, there is a high likelihood that your pre-v2.0 programs will not run without some changes. Dropping support of Python 2[#](#dropping-support-of-python-2 "Permalink to this heading") ------------------------------------------------------------------------------------------- Starting with version 2.0, MoviePy **no longer supports Python 2**, since Python 2 reached its end of life in 2020. Focusing on Python 3.7+ allows MoviePy to take advantage of the latest language features and improvements while maintaining code quality and security. Users are encouraged to upgrade to a supported version of Python to continue using MoviePy. `moviepy.editor` suppression and simplified importation[#](#moviepy-editor-suppression-and-simplified-importation "Permalink to this heading") ----------------------------------------------------------------------------------------------------------------------------------------------- Before v2.0, it was advised to import from `moviepy.editor` whenever you needed to do some sort of manual operations, such as previewing or hand editing, because the `editor` package handled a lot of magic and initialization, making your life easier, at the cost of initializing some complex modules like `pygame`. With version 2.0, the `moviepy.editor` namespace simply no longer exists. You simply import everything from `moviepy` like this: from moviepy import \* \# Simple and nice, the \_\_all\_\_ is set in moviepy so only useful things will be loaded from moviepy import VideoFileClip \# You can also import only the things you really need Renaming and API unification[#](#renaming-and-api-unification "Permalink to this heading") ------------------------------------------------------------------------------------------- One of the most significant change has been renaming all `.set_` methods to `.with_`. More generally, almost all the method modifying a clip now starts by `with_`, indicating that they work ‘outplace’, meaning they do not directly modify the clip, but instead copy it, modify this copy, and return the updated copy, leaving the original clip untouched. We advise you to check in your code for any call of method from `Clip` objects and check for a matching `.with_` equivalent. Massive refactoring of effects[#](#massive-refactoring-of-effects "Permalink to this heading") ----------------------------------------------------------------------------------------------- With version 2.0, effects have undergone massive changes and refactoring. Though the logic of why and when applying effects remain globally the same, the implementation changed quite heavily. If you used any kind of effects, you will have to update your code! ### Moving effects from function to classes[#](#moving-effects-from-function-to-classes "Permalink to this heading") MoviePy version 2.0 introduces a more structured and object-oriented approach to handling effects. In previous versions, effects were simply Python functions that manipulated video clips or images. However, in version 2.0 and onwards, effects are now represented as classes. This shift allows for better organization, encapsulation, and reusability of code, as well as more comprehensible code. Each effect is now encapsulated within its own class, making it easier to manage and modify. All effects are now implementing the [`Effect`](../reference/reference/moviepy.Effect.html#moviepy.Effect.Effect "moviepy.Effect.Effect") abstract class, so if you ever used any custom effect. If you ever write your own effect, you will have to migrate to the new object implementation. For more info see [Creating your own effects](../user_guide/create_effects.html#create-effects) . ### Moving from `clip.fx` to [`with_effects()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_effects "moviepy.Clip.Clip.with_effects") [#](#moving-from-clip-fx-to-with-effects "Permalink to this heading") Moving from function to object also meant MoviePy had to drop the method `Clip.fx` previously used to apply effects in favor of the new [`with_effects()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_effects "moviepy.Clip.Clip.with_effects") . For more info about how to use effects with v2.0, see [Modify a clip using effects](../user_guide/modifying.html#modifying-effects) . ### Removing effects as clip methods[#](#removing-effects-as-clip-methods "Permalink to this heading") Before version 2.0, when importing from `moviepy.editor` the effects was added as clip class method at runtime. This is no longer the case. If you previously used effect by calling them as clips method, you must now use [`with_effects()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_effects "moviepy.Clip.Clip.with_effects") . Dropping many external dependencies and unifying environment[#](#dropping-many-external-dependencies-and-unifying-environment "Permalink to this heading") ----------------------------------------------------------------------------------------------------------------------------------------------------------- With v1.0, MoviePy relied on many optional external dependencies, trying to gracefully fallback from one library to another in the event one of them was missing, eventually dropping some features when no library was available. This resulted in complex and hard to maintain code for the MoviePy team, as well as fragmented and hard to understand environment for the users. With v2.0 the MoviePy team tried to offer a simpler, smaller and more unified dependency list, with focusing on `pillow` for all complex image manipulation, and dropping altogether the usage of `ImageMagick`, `PyGame`, `OpenCV`, `scipy`, `scikit`, and a few others. Removed features[#](#removed-features "Permalink to this heading") ------------------------------------------------------------------- Sadly, reducing the scope of MoviePy and limiting the external libraries mean that some features had to be removed, if you used any of the following features, you will have to create your own replacement: * `moviepy.video.tools.tracking` * `moviepy.video.tools.segmenting` * `moviepy.video.io.sliders` Miscellaneous signature changes[#](#miscellaneous-signature-changes "Permalink to this heading") ------------------------------------------------------------------------------------------------- When updating the API and moving from previous libraries to `pillow`, some miscellaneous changes also happen, meaning some methods signatures may have changed. You should check the new signatures if you used any of the following: * `TextClip` some arguments named have changed and a path to a font file is now needed at object instantiation * `clip.resize` is now `clip.resized` * `clip.crop` is now `clip.cropped` * `clip.rotate` is now `clip.rotated` * Any previous `Clip` method not starting by `with_` now probably start with it Why all these changes and updating from v1.0 to v2.0?[#](#why-all-these-changes-and-updating-from-v1-0-to-v2-0 "Permalink to this heading") -------------------------------------------------------------------------------------------------------------------------------------------- You may ask yourself why were all these changes introduced? The answer is: time. MoviePy have seen many evolution since his first release and have became kind of a complex project, with ambitions sometimes too important in regards to available manpower on the development team. Over time, as in any project, inconsistencies have been introduced in order to support new functionalities without breaking current API, and some initial choices no longer reflected the current state of things. Due to multiple factors, MoviePy have also undergone a long period of time during which the main version distributed through PiPy diverged from the GitHub distributed version, introducing confusion and chaos. In a global effort to simplify future development and limit confusion by providing a unified environment, it has been decided to release a new major version including the many evolutions than happened over the years, which meant breaking changes, and so a new major version released was required. For anyone interested in how and why all of these things have been decided, you can find a lot of the discussion that went into this in GitHub issues [#1874](https://github.com/Zulko/moviepy/issues/1874) , [#1089](https://github.com/Zulko/moviepy/issues/1089) and [#2012](https://github.com/Zulko/moviepy/issues/2012) . On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/updating_to_v2.rst) [Show Source](../_sources/getting_started/updating_to_v2.rst.txt) --- # The MoviePy Developers Guide — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") The MoviePy Developers Guide[#](#the-moviepy-developers-guide "Permalink to this heading") =========================================================================================== The Developers Guide covers most of the things people wanting to participate to MoviePy development need to know. * [Installation for MoviePy developers](developers_install.html) * [MoviePy’s Contribution Guidelines](contribution_guidelines.html) * [Publishing a New Version of MoviePy](maintainers_publish.html) [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/developer_guide/index.rst) [Show Source](../_sources/developer_guide/index.rst.txt) --- # Api Reference — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Api Reference[#](#api-reference "Permalink to this heading") ============================================================= This is the definitive place to find all the details on MoviePy API documentation. For a more beginner introduction, please see [Getting started with MoviePy](../getting_started/index.html#getting-started) , for a more detailed explanations of the different concepts in MoviePy, see [The MoviePy User Guide](../user_guide/index.html#user-guide) . | | | | --- | --- | | [`moviepy`](reference/moviepy.html#module-moviepy "moviepy") | Imports everything that you need from the MoviePy submodules so that every thing can be directly imported with `from moviepy import *`. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/index.rst) [Show Source](../_sources/reference/index.rst.txt) --- # Unknown :notoc: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* MoviePy documentation \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* .. image:: /\_static/medias/logo.png :width: 50% :align: center \*\*Date\*\*: |today| \*\*Version\*\*: |version| \*\*Useful links\*\*: \`Binary Installers \`\_\_ | \`Source Repository \`\_\_ | \`Issues & Ideas \`\_\_ | \`Q&A Support \`\_\_ | MoviePy is the \`Python \`\_\_ reference tool for video editing automation! It's an open source, MIT-licensed library offering user-friendly video editing and manipulation tools for the \`Python \`\_\_ programming language. .. grid:: 1 2 2 2 :gutter: 4 :padding: 2 2 0 0 :class-container: sd-text-center .. grid-item-card:: Getting started :img-top: \_static/medias/index\_getting\_started.svg :class-card: intro-card :shadow: md New to \*MoviePy\*? Check out the getting started guides. They contain instructions to install \*MoviePy\* as well as introduction concepts and tutorials. +++ .. button-ref:: getting\_started :ref-type: ref :click-parent: :color: secondary :expand: To the starting guide .. grid-item-card:: User guide :img-top: \_static/medias/index\_user\_guide.svg :class-card: intro-card :shadow: md The user guide provides in-depth information on the key concepts of \*MoviePy\* with useful background information and explanation. +++ .. button-ref:: user\_guide :ref-type: ref :click-parent: :color: secondary :expand: To the user guide .. grid-item-card:: API reference :img-top: \_static/medias/index\_api.svg :class-card: intro-card :shadow: md The reference guide contains a detailed description of the \*MoviePy\* API. The reference describes how the methods work and which parameters can be used. It assumes that you have an understanding of the key concepts. +++ .. button-ref:: reference\_manual :ref-type: ref :click-parent: :color: secondary :expand: To the reference guide .. grid-item-card:: Developer guide :img-top: \_static/medias/index\_contribute.svg :class-card: intro-card :shadow: md Saw a typo in the documentation? Want to improve existing functionalities? The contributing guidelines will guide you through the process of improving \*MoviePy\*. +++ .. button-ref:: developer\_guide :ref-type: ref :click-parent: :color: secondary :expand: To the development guide Contribute! -------------- MoviePy is an open source software originally written by Zulko\_ and released under the MIT licence. It works on Windows, Mac, and Linux. .. raw:: html [Tweet](https://twitter.com/share) .. toctree:: :maxdepth: 3 :hidden: :titlesonly: getting\_started/index user\_guide/index reference/index developer\_guide/index .. \_PyPI: https://pypi.python.org/pypi/moviepy .. \_Zulko: https://github.com/Zulko/ .. \_Stackoverflow: https://stackoverflow.com/ .. \_Github: https://github.com/Zulko/moviepy .. \_Reddit: https://www.reddit.com/r/moviepy/ --- # Installation — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Installation[#](#installation "Permalink to this heading") =========================================================== Installation is done with `pip`. If you don’t have `pip`, take a look at [how to install it](https://pip.pypa.io/en/stable/installation/) . With `pip` installed, just type this in a terminal: $ (sudo) pip install moviepy Installation of additional binaries[#](#installation-of-additional-binaries "Permalink to this heading") --------------------------------------------------------------------------------------------------------- MoviePy depends on the software [ffmpeg](https://www.ffmpeg.org/download.html) for video reading and writing and on `ffplay` for video previewing. You don’t need to worry about [ffmpeg](https://www.ffmpeg.org/download.html) , as it should be automatically downloaded/installed by ImageIO during your first use of MoviePy (it takes a few seconds). You do need to worry about `ffplay` if you plan on using video/audio previewing. For these cases, make sure to have `ffplay` installed (it can usually be found alongside `ffmpeg`) and make sure it is accessible to Python, or define a custom path (see below). ### Define custom paths to binaries[#](#define-custom-paths-to-binaries "Permalink to this heading") If you want to use a specific version of FFmpeg and FFplay, you can do so using environment variables. There are a couple of environment variables used by MoviePy that allow you to configure custom paths to the external tools. To setup any of these variables, the easiest way is to do it in Python before importing objects from MoviePy. For example: import os os.environ\["FFMPEG\_BINARY"\] \= "/path/to/custom/ffmpeg" os.environ\["FFPLAY\_BINARY"\] \= "/path/to/custom/ffplay" Alternatively, after installing the optional dependencies, you can create a `.env` file in your working directory that will be automatically read. For example FFMPEG\_BINARY\=/path/to/custom/ffmpeg FFPLAY\_BINARY\=/path/to/custom/ffplay #### Environment variables[#](#environment-variables "Permalink to this heading") There are 2 available environment variables for external binaries : `FFMPEG_BINARY` Normally you can leave it to its default (‘ffmpeg-imageio’) in which case imageio will download the right ffmpeg binary (on first use) and then always use that binary. The second option is `"auto-detect"`. In this case ffmpeg will be whatever binary is found on the computer: generally `ffmpeg` (on Linux/macOS) or `ffmpeg.exe` (on Windows). Lastly, you can set it to use a binary at a specific location on your disk by specifying the exact path. `FFPLAY_BINARY` The default is `"auto-detect"`. MoviePy will try to find and use the installed `ffplay` binary. You can set it to use a binary at a specific location on your disk. On Windows, this might look like: os.environ\["FFPLAY\_BINARY"\] \= r"C:\\Program Files\\ffmpeg\\ffplay.exe" #### Verify if MoviePy find binaries[#](#verify-if-moviepy-find-binaries "Permalink to this heading") To test if FFmpeg and FFplay are found by MoviePy, in a Python console, you can run : from moviepy.config import check check() On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/install.rst) [Show Source](../_sources/getting_started/install.rst.txt) --- # Loading resources as clips — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Loading resources as clips[#](#loading-resources-as-clips "Permalink to this heading") ======================================================================================= The first step for making a video with MoviePy is to load the resources you wish to include in the final video. In this section we present the different sorts of clips and how to load them. For information on modifying a clip, see [Modifying clips and apply effects](modifying.html#modifying) . For how to put clips together see [Compositing multiple clips](compositing.html#compositing) . And for how to see/save theme, see [Previewing and saving video clips](rendering.html#rendering) (we will usually save them in example, but we wont explain here). There’s a lot of different resources you can use with MoviePy, and you will load different resources with different subtypes of [`Clip`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") , and more precisely of [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") for any audio element, or [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") for any visual element. The following code summarizes the base clips that you can create with moviepy: from moviepy import ( VideoClip, VideoFileClip, ImageSequenceClip, ImageClip, TextClip, ColorClip, AudioFileClip, AudioClip, ) import numpy as np \# Define some constants for later use black \= (255, 255, 255) \# RGB for black def frame\_function(t): """Random noise image of 200x100""" return np.random.randint(low\=0, high\=255, size\=(100, 200, 3)) def frame\_function\_audio(t): """A note by producing a sinewave of 440 Hz""" return np.sin(440 \* 2 \* np.pi \* t) \# Now lets see how to load different type of resources ! \# VIDEO CLIPS \# for custom animations, where frame\_function is a function returning an image \# as numpy array for a given time clip \= VideoClip(frame\_function, duration\=5) clip \= VideoFileClip("example.mp4") \# for videos \# for a list or directory of images to be used as a video sequence clip \= ImageSequenceClip("example\_img\_dir", fps\=24) clip \= ImageClip("example.png") \# For a picture \# To create the image of a text clip \= TextClip(font\="./example.ttf", text\="Hello!", font\_size\=70, color\="black") \# a clip of a single unified color, where color is a RGB tuple/array/list clip \= ColorClip(size\=(460, 380), color\=black) \# AUDIO CLIPS \# for audio files, but also videos where you only want the keep the audio track clip \= AudioFileClip("example.wav") \# for custom audio, where frame\_function is a function returning a \# float (or tuple for stereo) for a given time clip \= AudioClip(frame\_function\_audio, duration\=3) The best to understand all these clips more thoroughly is to read the full documentation for each in the [Api Reference](../reference/index.html#reference-manual) . Releasing resources by closing a clip[#](#releasing-resources-by-closing-a-clip "Permalink to this heading") ------------------------------------------------------------------------------------------------------------- When you create some types of clip instances - e.g. `VideoFileClip` or `AudioFileClip` - MoviePy creates a subprocess and locks the file. In order to release these resources when you are finished you should call the `close()` method. This is more important for more complex applications and is particularly important when running on Windows. While Python’s garbage collector should eventually clean up the resources for you, closing them makes them available earlier. However, if you close a clip too early, methods on the clip (and any clips derived from it) become unsafe. So, the rules of thumb are: > * Call `close()` on any clip that you **construct** once you have finished using it and have also finished using any clip that was derived from it. > > * Even if you close a [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") > instance, you still need to close the clips it was created from. > > * Otherwise, if you have a clip that was created by deriving it from from another clip (e.g. by calling `with_mask()`), then generally you shouldn’t close it. Closing the original clip will also close the copy. > Clips act as [context managers](https://docs.python.org/3/reference/datamodel.html#context-managers) . This means you can use them with a `with` statement, and they will automatically be closed at the end of the block, even if there is an exception. from moviepy import \* \# clip.close() is implicitly called, so the lock on my\_audiofile.mp3 file \# is immediately released. try: with AudioFileClip("example.wav") as clip: raise Exception("Let's simulate an exception") except Exception as e: print("{}".format(e)) Categories of video clips[#](#categories-of-video-clips "Permalink to this heading") ------------------------------------------------------------------------------------- Video clips are the building blocks of longer videos. Technically, they are clips with a `clip.get_frame(t)` method which outputs a `HxWx3` numpy array representing the frame of the clip at time `t`. There are two main type of video clips: * animated clips (made with `VideoFileClip`, [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") and [`ImageSequenceClip`](../reference/reference/moviepy.video.io.ImageSequenceClip.ImageSequenceClip.html#moviepy.video.io.ImageSequenceClip.ImageSequenceClip "moviepy.video.io.ImageSequenceClip.ImageSequenceClip") ), which will always have duration. * unanimated clips (made with [`ImageClip`](../reference/reference/moviepy.video.VideoClip.ImageClip.html#moviepy.video.VideoClip.ImageClip "moviepy.video.VideoClip.ImageClip") , ``VideoClip`TextClip`` and [`ColorClip`](../reference/reference/moviepy.video.VideoClip.ColorClip.html#moviepy.video.VideoClip.ColorClip "moviepy.video.VideoClip.ColorClip") ), which show the same picture for an a-priori infinite duration. There are also special video clips called masks, which belong to the categories above but output greyscale frames indicating which parts of another clip are visible or not. A video clip can carry around an audio clip ([`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") ) in [`audio`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.audio "moviepy.video.VideoClip.VideoClip.audio") which is its _soundtrack_, and a mask clip in [`mask`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.mask "moviepy.video.VideoClip.VideoClip.mask") . ### Animated clips[#](#animated-clips "Permalink to this heading") These are clips whose image will change over time, and which have a duration and a number of Frames Per Second. #### VideoClip[#](#videoclip "Permalink to this heading") [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.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 `frame_function(t)` which returns a HxWx3 numpy array (of 8-bits integers) representing the frame at time `t`. Here is an example where we will create a pulsating red circle with graphical library [pillow](https://pypi.org/project/Pillow/) . from PIL import Image, ImageDraw import numpy as np from moviepy import VideoClip import math WIDTH, HEIGHT \= (128, 128) RED \= (255, 0, 0) def frame\_function(t): frequency \= 1 \# One pulse per second coef \= 0.5 \* (1 + math.sin(2 \* math.pi \* frequency \* t)) \# radius varies over time radius \= WIDTH \* coef x1 \= WIDTH / 2 \- radius / 2 y1 \= HEIGHT / 2 \- radius / 2 x2 \= WIDTH / 2 + radius / 2 y2 \= HEIGHT / 2 + radius / 2 img \= Image.new("RGB", (WIDTH, HEIGHT)) draw \= ImageDraw.Draw(img) draw.ellipse((x1, y1, x2, y2), fill\=RED) return np.array(img) \# returns a 8-bit RGB array \# we define a 2s duration for the clip to be able to render it later clip \= VideoClip(frame\_function, duration\=2) \# we must set a framerate because VideoClip have no framerate by default clip.write\_gif("circle.gif", fps\=15) Resulting in this. [![A pulsating red circle on black background.](../_images/circle.gif)](../_images/circle.gif) Note Clips that are made with a `frame_function` do not have an explicit frame rate nor duration by default, so you must provide duration at clip creation and a frame rate (`fps`, frames per second) for [`write_gif()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_gif "moviepy.video.VideoClip.VideoClip.write_gif") and [`write_videofile()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_videofile "moviepy.video.VideoClip.VideoClip.write_videofile") , and more generally for any methods that requires iterating through the frames. For more, see [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") . #### VideoFileClip[#](#videofileclip "Permalink to this heading") A [`VideoFileClip`](../reference/reference/moviepy.video.io.VideoFileClip.VideoFileClip.html#moviepy.video.io.VideoFileClip.VideoFileClip "moviepy.video.io.VideoFileClip.VideoFileClip") is a clip read from a video file (most formats are supported) or a GIF file. This is probably one of the most used object ! You load the video as follows: from moviepy import VideoFileClip myclip \= VideoFileClip("example.mp4") \# video file clips already have fps and duration print("Clip duration: {}".format(myclip.duration)) print("Clip fps: {}".format(myclip.fps)) myclip \= myclip.subclipped(0.5, 2) \# Cutting the clip between 0.5 and 2 secs. print("Clip duration: {}".format(myclip.duration)) \# Cuting will update duration print("Clip fps: {}".format(myclip.fps)) \# and keep fps \# the output video will be 1.5 sec long and use original fps myclip.write\_videofile("result.mp4") Note These clips will have an `fps` (frame per second) and `duration` attributes, which will be transmitted if you do small modifications of the clip, and will be used by default in [`write_gif()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_gif "moviepy.video.VideoClip.VideoClip.write_gif") , [`write_videofile()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_videofile "moviepy.video.VideoClip.VideoClip.write_videofile") , etc. For more, see [`VideoFileClip`](../reference/reference/moviepy.video.io.VideoFileClip.VideoFileClip.html#moviepy.video.io.VideoFileClip.VideoFileClip "moviepy.video.io.VideoFileClip.VideoFileClip") . #### ImageSequenceClip[#](#imagesequenceclip "Permalink to this heading") This [`ImageSequenceClip`](../reference/reference/moviepy.video.io.ImageSequenceClip.ImageSequenceClip.html#moviepy.video.io.ImageSequenceClip.ImageSequenceClip "moviepy.video.io.ImageSequenceClip.ImageSequenceClip") is a clip made from a series of images : from moviepy import ImageSequenceClip \# A clip with a list of images showed for 1 second each myclip \= ImageSequenceClip( \[\ "example\_img\_dir/image\_0001.jpg",\ "example\_img\_dir/image\_0002.jpg",\ "example\_img\_dir/image\_0003.jpg",\ \], durations\=\[1, 1, 1\], ) \# 3 images, 1 seconds each, duration = 3 print("Clip duration: {}".format(myclip.duration)) \# 3 seconds, 3 images, fps is 3/3 = 1 print("Clip fps: {}".format(myclip.fps)) \# This time we will load all images in the dir, and instead of showing theme \# for X seconds, we will define FPS myclip2 \= ImageSequenceClip("./example\_img\_dir", fps\=30) \# fps = 30, so duration = nb images in dir / 30 print("Clip duration: {}".format(myclip2.duration)) print("Clip fps: {}".format(myclip2.fps)) \# fps = 30 \# the gif will be 30 fps, its duration will depend on the number of \# images in dir myclip.write\_gif("result.gif") \# the gif will be 3 sec and 1 fps myclip2.write\_gif("result2.gif") When creating an image sequence, `sequence` can be either a list of image names (that will be _played_ in the provided order), a folder name (played in alphanumerical order), or a list of frames (Numpy arrays), obtained for instance from other clips. Warning All the images in list/folder/frames must be of the same size, or an exception will be raised For more, see [`ImageSequenceClip`](../reference/reference/moviepy.video.io.ImageSequenceClip.ImageSequenceClip.html#moviepy.video.io.ImageSequenceClip.ImageSequenceClip "moviepy.video.io.ImageSequenceClip.ImageSequenceClip") . #### DataVideoClip[#](#datavideoclip "Permalink to this heading") `DataVideoClip` is a video clip who take a list of datasets, a callback function, and make each frame by iterating over dataset and invoking the callback function with the current data as first argument. You will probably never use this. But if you do, think of it like a [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") , where you make frames not based on time, but based on each entry of a data list. """Let's make a clip where frames depend on values in a list""" from moviepy import DataVideoClip import numpy as np \# Dataset will just be a list of colors as RGB dataset \= \[\ (255, 0, 0),\ (0, 255, 0),\ (0, 0, 255),\ (0, 255, 255),\ (255, 0, 255),\ (255, 255, 0),\ \] \# The function make frame take data and create an image of 200x100 px \# filled with the color given in the dataset def frame\_function(data): frame \= np.full((100, 200, 3), data, dtype\=np.uint8) return frame \# We create the DataVideoClip, and we set FPS at 2, making a 3s clip \# (because len(dataset) = 6, so 6/2=3) myclip \= DataVideoClip(data\=dataset, data\_to\_frame\=frame\_function, fps\=2) \# Modifying fps here will change video FPS, not clip FPS myclip.write\_videofile("result.mp4", fps\=30) For more, see For more, see `DataVideoClip`. #### UpdatedVideoClip[#](#updatedvideoclip "Permalink to this heading") Warning This is really advanced usage, you will probably never need it, if you do, please go read the code. `UpdatedVideoClip` is a video whose frame\_function requires some objects to be updated before we can compute it. This is particularly practical in science where some algorithm needs to make some steps before a new frame can be generated, or maybe when trying to make a video based on a live exterior context. When you use this, you pass a world object to it. A world object is an object who respect these 3 rules: 1. It has a `clip_t` property, indicating the current world time. 2. It has an `update()` method, that will update the world state and is responsible for increasing `clip_t` when a new frame can be drown. 3. It has a `to_frame()` method, that will render a frame based on world current state. On `get_frame()` call, your `UpdatedVideoClip` will try to update the world until `world.clip_t` is superior or equal to frame time, then it will call `world.to_frame()`. from moviepy import UpdatedVideoClip import numpy as np import random class CoinFlipWorld: """A simulation of coin flipping. Imagine we want to make a video that become more and more red as we repeat same face on coinflip in a row because coinflip are done in real time, we need to wait until a winning row is done to be able to make the next frame. This is a world simulating that. Sorry, it's hard to come up with examples...""" def \_\_init\_\_(self, fps): """ FPS is usefull because we must increment clip\_t by 1/FPS to have UpdatedVideoClip run with a certain FPS """ self.clip\_t \= 0 self.win\_strike \= 0 self.reset \= False self.fps \= fps def update(self): if self.reset: self.win\_strike \= 0 self.reset \= False print("strike : {}, clip\_t : {}".format(self.win\_strike, self.clip\_t)) print(self.win\_strike) \# 0 tails, 1 heads, this is our simulation of coinflip choice \= random.randint(0, 1) face \= random.randint(0, 1) \# We win, we increment our serie and retry if choice \== face: self.win\_strike += 1 return \# Different face, we increment clip\_t and set reset so we will reset on next update. \# We don't reset immediately because we will need current state to make frame self.reset \= True self.clip\_t += 1 / self.fps def to\_frame(self): """Return a frame of a 200x100 image with red more or less intense based on number of victories in a row.""" red\_intensity \= 255 \* (self.win\_strike / 10) red\_intensity \= min(red\_intensity, 255) \# A 200x100 image with red more or less intense based on number of victories in a row return np.full((100, 200, 3), (red\_intensity, 0, 0), dtype\=np.uint8) world \= CoinFlipWorld(fps\=5) myclip \= UpdatedVideoClip(world\=world, duration\=10) \# We will set FPS to same as world, if we was to use a different FPS, \# the lowest from world.fps and our write\_videofile fps param \# will be the real visible fps myclip.write\_videofile("result.mp4", fps\=5) ### Unanimated clips[#](#unanimated-clips "Permalink to this heading") These are clips whose image will, at least before modifications, stay the same. By default they have no duration nor FPS, meaning you will need to define them before doing operations needing such information (for example, rendering). #### ImageClip[#](#imageclip "Permalink to this heading") [`ImageClip`](../reference/reference/moviepy.video.VideoClip.ImageClip.html#moviepy.video.VideoClip.ImageClip "moviepy.video.VideoClip.ImageClip") is the base class for all unanimated clips, it’s a video clip that always displays the same image. Along with [`VideoFileClip`](../reference/reference/moviepy.video.io.VideoFileClip.VideoFileClip.html#moviepy.video.io.VideoFileClip.VideoFileClip "moviepy.video.io.VideoFileClip.VideoFileClip") it’s one of the most used kind of clip. You can create one as follows: """Here's how you transform a VideoClip into an ImageClip from an image, from arbitrary data, or by extracting a frame at a given time""" from moviepy import ImageClip, VideoFileClip import numpy as np \# Random RGB noise image of 200x100 noise\_image \= np.random.randint(low\=0, high\=255, size\=(100, 200, 3)) myclip1 \= ImageClip("example.png") \# You can create it from a path myclip2 \= ImageClip(noise\_image) \# from a (height x width x 3) RGB numpy array \# Or load videoclip and extract frame at a given time myclip3 \= VideoFileClip("./example.mp4").to\_ImageClip(t\="00:00:01") For more, see [`ImageClip`](../reference/reference/moviepy.video.VideoClip.ImageClip.html#moviepy.video.VideoClip.ImageClip "moviepy.video.VideoClip.ImageClip") . #### TextClip[#](#textclip "Permalink to this heading") A [`TextClip`](../reference/reference/moviepy.video.VideoClip.TextClip.html#moviepy.video.VideoClip.TextClip "moviepy.video.VideoClip.TextClip") is a clip that will turn a text string into an image clip. [`TextClip`](../reference/reference/moviepy.video.VideoClip.TextClip.html#moviepy.video.VideoClip.TextClip "moviepy.video.VideoClip.TextClip") accept many parameters, letting you configure the appearance of the text, such as font and font size, color, interlining, text alignment, etc. The font you want to use must be an [OpenType font](https://fr.wikipedia.org/wiki/OpenType) , and you will set it by passing the path to the font file. Here are a few example of using [`TextClip`](../reference/reference/moviepy.video.VideoClip.TextClip.html#moviepy.video.VideoClip.TextClip "moviepy.video.VideoClip.TextClip") : from moviepy import TextClip font \= "./example.ttf" \# First we use as string and let system autocalculate clip dimensions to fit the text \# we set clip duration to 2 secs, if we do not, it got an infinite duration txt\_clip1 \= TextClip( font\=font, text\="Hello World !", font\_size\=30, color\="#FF0000", \# Red bg\_color\="#FFFFFF", duration\=2, ) \# This time we load text from a file, we set a fixed size for clip and let the system find best font size, \# allowing for line breaking txt\_clip2 \= TextClip( font\=font, filename\="./example.txt", size\=(500, 200), bg\_color\="#FFFFFF", method\="caption", color\=(0, 0, 255, 127), ) \# Blue with 50% transparency \# we set duration, because by default image clip are infinite, and we cannot render infinite txt\_clip2 \= txt\_clip2.with\_duration(2) \# ImageClip have no FPS either, so we must defined it txt\_clip1.write\_videofile("result1.mp4", fps\=24) txt\_clip2.write\_videofile("result2.mp4", fps\=24) Note The parameter `method` let you define if text should be written and overflow if too long (`label`) or be automatically broken over multiple lines (`caption`). For a more detailed explanation of all the parameters, see [`TextClip`](../reference/reference/moviepy.video.VideoClip.TextClip.html#moviepy.video.VideoClip.TextClip "moviepy.video.VideoClip.TextClip") . #### ColorClip[#](#colorclip "Permalink to this heading") A [`ColorClip`](../reference/reference/moviepy.video.VideoClip.ColorClip.html#moviepy.video.VideoClip.ColorClip "moviepy.video.VideoClip.ColorClip") is a clip that will return an image of only one color. It is sometimes useful when doing compositing (see [Compositing multiple clips](compositing.html#compositing) ). from moviepy import ColorClip \# Color is passed as a RGB tuple myclip \= ColorClip(size\=(200, 100), color\=(255, 0, 0), duration\=1) \# We really don't need more than 1 fps do we ? myclip.write\_videofile("result.mp4", fps\=1) For more, see [`ColorClip`](../reference/reference/moviepy.video.VideoClip.ColorClip.html#moviepy.video.VideoClip.ColorClip "moviepy.video.VideoClip.ColorClip") . ### Mask clips[#](#mask-clips "Permalink to this heading") Masks are a special kind of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") with the property `is_mask` set to `True`. They can be attached to any other kind of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") through method [`with_mask()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.with_mask "moviepy.video.VideoClip.VideoClip.with_mask") . When a clip as a mask attached to it, this mask will indicate which pixels will be visible when the clip is composed with other clips (see [Compositing multiple clips](compositing.html#compositing) ). Masks are also used to define transparency when you export the clip as GIF file or as a PNG. The fundamental difference between masks and standard clips is that standard clips output frames with 3 components (R-G-B) per pixel, comprised between 0 and 255, while a mask has just one component per pixel, between 0 and 1 (1 indicating a fully visible pixel and 0 a transparent pixel). Seen otherwise, a mask is always in greyscale. When you create or load a clip that you will use as a mask you need to declare it. You can then attach it to a clip with the same dimensions : from moviepy import VideoClip, ImageClip, VideoFileClip import numpy as np \# Random RGB noise image of 200x100 frame\_function \= lambda t: np.random.rand(100, 200) \# To define the VideoClip as a mask, just pass parameter is\_mask as True maskclip1 \= VideoClip(frame\_function, duration\=4, is\_mask\=True) \# A random noise mask maskclip2 \= ImageClip("example\_mask.jpg", is\_mask\=True) \# A fixed mask as jpeg maskclip3 \= VideoFileClip("example\_mask.mp4", is\_mask\=True) \# A video as a mask \# Load our basic clip, resize to 200x100 and apply each mask clip \= VideoFileClip("example.mp4") clip\_masked1 \= clip.with\_mask(maskclip1) clip\_masked2 \= clip.with\_mask(maskclip2) clip\_masked3 \= clip.with\_mask(maskclip3) Note In the case of video and image files, if these are not already black and white they will be converted automatically. Also, when you load an image with an _alpha layer_, like a PNG, MoviePy will use this layer as a mask unless you pass `transparent=False`. Any video clip can be turned into a mask with [`to_mask()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.to_mask "moviepy.video.VideoClip.VideoClip.to_mask") , and a mask can be turned to a standard RGB video clip with [`to_RGB()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.to_RGB "moviepy.video.VideoClip.VideoClip.to_RGB") . Masks are treated differently by many methods (because their frames are different) but at the core, they are [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") , so you can do with theme everything you can do with a video clip: modify, cut, apply effects, save, etc. Using audio elements with audio clips[#](#using-audio-elements-with-audio-clips "Permalink to this heading") ------------------------------------------------------------------------------------------------------------- In addition to [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") for visual, you can use audio elements, like an audio file, using the [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") class. Both are quite similar, except [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") method `get_frame()` return a numpy array of size `Nx1` for mono, and size `Nx2` for stereo. ### AudioClip[#](#audioclip "Permalink to this heading") [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") is the base class for all audio clips. If all you want is to edit audio files, you will never need it. All you need is to define a function `frame_function(t)` which returns a `Nx1` or `Nx2` numpy array representing the sound at time `t`. from moviepy import AudioClip import numpy as np def audio\_frame(t): """Producing a sinewave of 440 Hz -> note A""" return np.sin(440 \* 2 \* np.pi \* t) audio\_clip \= AudioClip(frame\_function\=audio\_frame, duration\=3) For more, see [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") . ### AudioFileClip[#](#audiofileclip "Permalink to this heading") [`AudioFileClip`](../reference/reference/moviepy.audio.io.AudioFileClip.AudioFileClip.html#moviepy.audio.io.AudioFileClip.AudioFileClip "moviepy.audio.io.AudioFileClip.AudioFileClip") is used to load an audio file. This is probably the only kind of audio clip you will use. You simply pass it the file you want to load : from moviepy import \* \# Works for audio files, but also videos file where you only want the keep the audio track clip \= AudioFileClip("example.wav") clip.write\_audiofile("./result.wav") For more, see [`AudioFileClip`](../reference/reference/moviepy.audio.io.AudioFileClip.AudioFileClip.html#moviepy.audio.io.AudioFileClip.AudioFileClip "moviepy.audio.io.AudioFileClip.AudioFileClip") . ### AudioArrayClip[#](#audioarrayclip "Permalink to this heading") [`AudioArrayClip`](../reference/reference/moviepy.audio.AudioClip.AudioArrayClip.html#moviepy.audio.AudioClip.AudioArrayClip "moviepy.audio.AudioClip.AudioArrayClip") is used to turn an array representing a sound into an audio clip. You will probably never use it, unless you need to use the result of some third library without using a temporary file. You need to provide a numpy array representing the sound (of size `Nx1` for mono, `Nx2` for stereo), and the number of fps, indicating the speed at which the sound is supposed to be played. """Let's create an audioclip from values in a numpy array.""" import numpy as np from moviepy import AudioArrayClip \# We want to play these notes notes \= {"A": 440, "B": 494, "C": 523, "D": 587, "E": 659, "F": 698} note\_duration \= 0.5 total\_duration \= len(notes) \* note\_duration sample\_rate \= 44100 \# Number of samples per second note\_size \= int(note\_duration \* sample\_rate) n\_frames \= note\_size \* len(notes) def frame\_function(t, note\_frequency): return np.sin(note\_frequency \* 2 \* np.pi \* t) \# At this point one could use this audioclip which generates the audio on the fly \# clip = AudioFileClip(frame\_function) \# We generate all frames timepoints audio\_frame\_values \= \[\ 2 \* \[frame\_function(t, freq)\]\ for freq in notes.values()\ for t in np.arange(0, note\_duration, 1.0 / sample\_rate)\ \] \# Create an AudioArrayClip from the audio samples audio\_clip \= AudioArrayClip(np.array(audio\_frame\_values), fps\=sample\_rate) \# Write the audio clip to a WAV file audio\_clip.write\_audiofile("result.wav", fps\=44100) For more, see [`AudioArrayClip`](../reference/reference/moviepy.audio.AudioClip.AudioArrayClip.html#moviepy.audio.AudioClip.AudioArrayClip "moviepy.audio.AudioClip.AudioArrayClip") . On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/user_guide/loading.rst) [Show Source](../_sources/user_guide/loading.rst.txt) --- # Quick presentation — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Quick presentation[#](#quick-presentation "Permalink to this heading") ======================================================================= This section explains when MoviePy can be used and how it works. Do I need MoviePy?[#](#do-i-need-moviepy "Permalink to this heading") ---------------------------------------------------------------------- Here are a few reasons why you may want to edit videos in Python: * You have many videos to process or to compose in a complicated way. * You want to automate the creation of videos or GIFs on a web server (Django, Flask, etc.) * You want to automate tedious tasks, like title insertions tracking objects, cutting scenes, making end credits, subtitles, etc… * You want to code your own video effects to do something no existing video editor can. * You want to create animations from images generated by another python library (Matplotlib, Mayavi, Gizeh, scikit-images…) And here are a few uses for which MoviePy is NOT the best solution: * You only need to do frame-by-frame video analysis (with face detection or other fancy stuff). This could be done with MoviePy in association with other libraries, but really, just use [imageio](https://imageio.github.io/) , [OpenCV](http://opencv.org/) or SimpleCV, these are libraries that specialize in these tasks. * You only want to convert a video file, or turn a series of image files into a movie. In this case it is better to directly call `ffmpeg` (or `avconv` or `mencoder`…) as it will be faster and more memory-efficient than going through MoviePy. Advantages and limitations[#](#advantages-and-limitations "Permalink to this heading") --------------------------------------------------------------------------------------- MoviePy has been developed with the following goals in mind: * **Simple and intuitive**. Basic operations can be done in one line. The code is easy to learn and easy to understand for newcomers. * **Flexible**. You have total control over the frames of the video and audio, and creating your own effects is easy as Py. * **Portable**. The code uses very common software (Numpy and FFmpeg) and can run on (almost) any machine with (almost) any version of Python. Limitations: - MoviePy cannot stream videos (e.g. reading from a webcam, or rendering a video live on a distant machine). - MoviePy is not really designed for video processing involving many successive frames of a movie (e.g. video stabilization - there is other software better suited for that). - You can also have memory problems if you use many video, audio, and image sources at the same time (>100). Example code[#](#example-code "Permalink to this heading") ----------------------------------------------------------- In 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, 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 import \* \# Load file example.mp4 and extract only the subclip from 00:00:10 to 00:00:20 clip \= VideoFileClip("long\_examples/example2.mp4").subclipped(10, 20) \# Reduce the audio volume to 80% of his original volume clip \= clip.with\_volume\_scaled(0.8) \# Generate a text clip. You can customize the font, color, etc. txt\_clip \= TextClip( font\="example.ttf", text\="Big Buck Bunny", font\_size\=70, color\="white" ) \# Say that you want it to appear for 10s at the center of the screen txt\_clip \= txt\_clip.with\_position("center").with\_duration(10) \# Overlay the text clip on the first video clip video \= CompositeVideoClip(\[clip, txt\_clip\]) \# Write the result to a file (many options available!) video.write\_videofile("result.mp4") How MoviePy works[#](#how-moviepy-works "Permalink to this heading") --------------------------------------------------------------------- MoviePy uses the software `ffmpeg` to read and to export video and audio files. It also (optionally) uses `ffplay` to allow for video previewing. Internally, the representation and manipulation of the different media is done using Python’s fast numerical library Numpy. Advanced effects and enhancements also use `pillow` library. [![../_images/explanations.jpeg](../_images/explanations.jpeg)](../_images/explanations.jpeg) The central concept, the clips[#](#the-central-concept-the-clips "Permalink to this heading") ---------------------------------------------------------------------------------------------- The central object of MoviePy is the the [`Clip`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") , with either [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") for any audio element, or [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") for any visual element. Clips really are the base unit of MoviePy, everything you do is with and on them. Clips can be created from more than just videos or audios though. They can also be created from an image, a text, a custom animation, a folder of images, and even a simple lambda function! To create your final video, what you will do is essentially: 1. Load different resources as clips (see [Loading resources as clips](../user_guide/loading.html#loading) ) 2. Modify them (see [Modifying clips and apply effects](../user_guide/modifying.html#modifying) ) 3. Mixing them into one final clip (see [Compositing multiple clips](../user_guide/compositing.html#compositing) ) 4. Render them into a file (see [Previewing and saving video clips](../user_guide/rendering.html#rendering) ) Of course, MoviePy offer multiple handy solution and tools to facilitate all these steps, and lets you add new ones by writing your own effects (see [Creating your own effects](../user_guide/create_effects.html#create-effects) )! On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/quick_presentation.rst) [Show Source](../_sources/getting_started/quick_presentation.rst.txt) --- # Installation for MoviePy developers — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Installation for MoviePy developers[#](#installation-for-moviepy-developers "Permalink to this heading") ========================================================================================================= Warning This part is only destined to people who want to build the MoviePy documentation by themselves, or to contribute to MoviePy. Normal users don’t need it. In addition to MoviePy main libraries, MoviePy developers will also need to install additional libraries to be able to run MoviePy tests and build the MoviePy documentation. Libraries for documentation[#](#libraries-for-documentation "Permalink to this heading") ----------------------------------------------------------------------------------------- You can install the libraries required to build documentation with: $ (sudo) pip install moviepy\[doc\] Once libraries installed you can build the documentation with: $ python setup.py build\_docs Libraries for testing and linting[#](#libraries-for-testing-and-linting "Permalink to this heading") ----------------------------------------------------------------------------------------------------- You can install the libraries required for testing and linting with: $ (sudo) pip install moviepy\[test\] $ (sudo) pip install moviepy\[lint\] Once libraries installed you can test with: $ python \-m pytest And you can lint with: $ python \-m black . and $ python3 \-m flake8 \-v \--show-source \--max-line-length\=92 moviepy docs/conf.py examples tests On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/developer_guide/developers_install.rst) [Show Source](../_sources/developer_guide/developers_install.rst.txt) --- # Modifying clips and apply effects — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Modifying clips and apply effects[#](#modifying-clips-and-apply-effects "Permalink to this heading") ===================================================================================================== Of course, once you will have loaded a [`Clip`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") the next step of action will be to modify it to be able to integrate it in your final video. To modify a clip, there is three main courses of actions : * The built-in methods of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") or [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") modifying the properties of the object. * The already-implemented effects of MoviePy you can apply on clips, usually affecting the clip by applying filters on each frame of the clip at rendering time. * The transformation filters that you can apply using [`transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.transform "moviepy.Clip.Clip.transform") and [`time_transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") . How modifications are applied to a clip ?[#](#how-modifications-are-applied-to-a-clip "Permalink to this heading") ------------------------------------------------------------------------------------------------------------------- ### Clip copy during modification[#](#clip-copy-during-modification "Permalink to this heading") The first thing you must know is that when modifying a clip, MoviePy **will never modify that clip directly**. Instead it will return **a modified copy of the original** and let the original untouched. This is known as out-place instead of in-place behavior. To illustrate: \# Import everything needed to edit video clips from moviepy import VideoFileClip \# Load example.mp4 clip \= VideoFileClip("example.mp4") \# This does nothing, as multiply\_volume will return a copy of clip \# which you will loose immediatly as you don't store it \# If you was to render clip now, the audio would still be at full volume clip.with\_volume\_scaled(0.1) \# This create a copy of clip in clip\_whisper with a volume of only 10% the original, \# but does not modify the original clip \# If you was to render clip right now, the audio would still be at full volume \# If you was to render clip\_whisper, the audio would be a 10% of the original volume clip\_whisper \= clip.with\_volume\_scaled(0.1) \# This replace the original clip with a copy of it where volume is only 10% of \# the original. If you was to render clip now, the audio would be at 10% \# The original clip is now lost clip \= clip.with\_volume\_scaled(0.1) This is an important point to understand, because it is one of the most recurrent source of bug for newcomers. ### Memory consumption of effect and modifications[#](#memory-consumption-of-effect-and-modifications "Permalink to this heading") When applying an effect or modification, it does not immediately apply the effect to all the frames of the clip, but only to the first frame: all the other frames will only be modified when required (that is, when you will write the whole clip to a file or when you will preview it). It means that creating a new clip is neither time nor memory hungry, all the computation happen during the final rendering. ### Time representations in MoviePy[#](#time-representations-in-moviepy "Permalink to this heading") Many methods that we will see accept duration or timepoint as arguments. For instance `clip.subclipped(t_start, t_end)` which cuts the clip between two timepoints. MoviePy usually accept duration and timepoint as either: * a number of seconds as a `float`. * a `tuple` with `(minutes, seconds)` or `(hours, minutes, seconds)`. * a `string` such as `'00:03:50.54'`. Also, you can usually provide negative times, indicating a time from the end of the clip. For example, `clip.subclipped(-20, -10)` cuts the clip between 20s before the end and 10s before the end. Modify a clip using the `with_*` methods[#](#modify-a-clip-using-the-with-methods "Permalink to this heading") --------------------------------------------------------------------------------------------------------------- The first way to modify a clip is by modifying internal properties of your object, thus modifying his behavior. These methods usually start with the prefix `with_` or `without_`, indicating that they will return a copy of the clip with the properties modified. So, you may write something like: from moviepy import VideoFileClip myclip \= VideoFileClip("example.mp4") myclip \= myclip.with\_end(5) \# stop the clip after 5 sec myclip \= myclip.without\_audio() \# remove the audio of the clip In addition to the `with_*` methods, a handful of very common methods are also accessible under shorter names: * [`resized()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.resized "moviepy.video.VideoClip.VideoClip.resized") * `crop()` * `rotate()` For a list of all those methods, see [`Clip`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") and [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") . Modify a clip using effects[#](#modify-a-clip-using-effects "Permalink to this heading") ----------------------------------------------------------------------------------------- The second way to modify a clip is by using effects that will modify the frames of the clip (which internally are no more than [numpy arrays](https://numpy.org) ) by applying some sort of functions on them. MoviePy come with many effects implemented in [`moviepy.video.fx`](../reference/reference/moviepy.video.fx.html#module-moviepy.video.fx "moviepy.video.fx") for visual effects and [`moviepy.audio.fx`](../reference/reference/moviepy.audio.fx.html#module-moviepy.audio.fx "moviepy.audio.fx") for audio effects. For practicality, these two modules are loaded in MoviePy as `vfx` and `afx`, letting you import them as `from moviepy import vfx, afx`. To use these effects, you simply need to instantiate them as object and apply them on your [`Clip`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") using method [`with_effects()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_effects "moviepy.Clip.Clip.with_effects") , with a list of [`Effect`](../reference/reference/moviepy.Effect.html#moviepy.Effect.Effect "moviepy.Effect.Effect") objects you want to apply. For convenience the effects are also dynamically added as method of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") and `AudioClip` classes at runtime, letting you call them as simple method of your clip. So, you may write something like: from moviepy import VideoFileClip from moviepy import vfx, afx myclip \= VideoFileClip("example.mp4") \# resize clip to be 460px in width, keeping aspect ratio myclip \= myclip.with\_effects(\[vfx.Resize(width\=460)\]) \# fx method return a copy of the clip, so we can easily chain them \# double the speed and half the audio volume myclip \= myclip.with\_effects(\[vfx.MultiplySpeed(2), afx.MultiplyVolume(0.5)\]) \# because effects are added to Clip at runtime, you can also call \# them directly from your clip as methods myclip \= myclip.with\_effects(\[vfx.MultiplyColor(0.5)\]) \# darken the clip Note MoviePy effects are automatically applied to both the sound and the mask of the clip if it is relevant, so that you don’t have to worry about modifying these. For a list of those effects, see [`moviepy.video.fx`](../reference/reference/moviepy.video.fx.html#module-moviepy.video.fx "moviepy.video.fx") and [`moviepy.audio.fx`](../reference/reference/moviepy.audio.fx.html#module-moviepy.audio.fx "moviepy.audio.fx") . In addition to the effects already provided by MoviePy, you can obviously [Creating your own effects](create_effects.html#create-effects) and use them the same way. Modify a clip appearance and timing using filters[#](#modify-a-clip-appearance-and-timing-using-filters "Permalink to this heading") ------------------------------------------------------------------------------------------------------------------------------------- In addition to modifying a clip’s properties and using effects, you can also modify the appearance or timing of a clip by using your own custom _filters_ with [`time_transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") , `image_transform()`, and more generally with [`transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.transform "moviepy.Clip.Clip.transform") . All these methods work by taking as first parameter a callback function that will receive either a clip frame, a timepoint, or both, and return a modified version of these. ### Modify only the timing of a Clip[#](#modify-only-the-timing-of-a-clip "Permalink to this heading") You can change the timeline of the clip with [`time_transform(your_filter)`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") . Where `your_filter` is a callback function taking clip time as a parameter and returning a new time: from moviepy import VideoFileClip import math my\_clip \= VideoFileClip("example.mp4") \# Let's accelerate the video by a factor of 3 modified\_clip1 \= my\_clip.time\_transform(lambda t: t \* 3) \# Let's play the video back and forth with a "sine" time-warping effect modified\_clip2 \= my\_clip.time\_transform(lambda t: 1 + math.sin(t)) Now the clip `modified_clip1` plays three times faster than `my_clip`, while `modified_clip2` will be oscillating between 00:00:00 to 00:00:02 of `my_clip`. Note that in the last case you have created a clip of infinite duration (which is not a problem for the moment). Note By default [`time_transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") will only modify the clip main frame, without modifying clip audio or mask for [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") . If you wish to also modify audio and/or mask you can provide the parameter `apply_to` with either `'audio'`, `'mask'`, or `['audio', 'mask']`. ### Modifying only the appearance of a Clip[#](#modifying-only-the-appearance-of-a-clip "Permalink to this heading") For [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") , you can change the appearance of the clip with [`image_transform(your_filter)`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.image_transform "moviepy.video.VideoClip.VideoClip.image_transform") . Where `your_filter` is a callback function, taking clip frame (a numpy array) as a parameter and returning the transformed frame: """Let's invert the green and blue channels of a video.""" from moviepy import VideoFileClip import numpy my\_clip \= VideoFileClip("example.mp4") def invert\_green\_blue(image: numpy.ndarray) \-> numpy.ndarray: return image\[:, :, \[0, 2, 1\]\] modified\_clip1 \= my\_clip.image\_transform(invert\_green\_blue) Now the clip `modified_clip1` will have his green and blue canals inverted. Note You can define if transformation should be applied to audio and mask same as for [`time_transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") . Note Sometimes need to treat clip frames and mask frames in a different way. To distinguish between the two, you can always look at their shape, clips are `H*W*3`, and masks `H*W`. ### Modifying both the appearance and the timing of a Clip[#](#modifying-both-the-appearance-and-the-timing-of-a-clip "Permalink to this heading") Finally, you may want to process the clip by taking into account both the time and the frame picture, for example to apply visual effects variating with time. This is possible with the method [`transform(your_filter)`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.transform "moviepy.Clip.Clip.transform") . Where `your_filter` is a callback function taking two parameters, and returning a new frame picture. Where first argument is a `get_frame` method (i.e. a function `get_frame(time)` which given a time returns the clip’s frame at that time), and the second argument is the time. """Let's create a scolling video effect from scratch.""" from moviepy import VideoFileClip my\_clip \= VideoFileClip("example.mp4") def scroll(get\_frame, t): """ This function returns a 'region' of the current frame. The position of this region depends on the time. """ frame \= get\_frame(t) frame\_region \= frame\[int(t) : int(t) + 360, :\] return frame\_region modified\_clip1 \= my\_clip.transform(scroll) This will scroll down the clip, with a constant height of 360 pixels. Note You can define if transformation should be applied to audio and mask same as for [`time_transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") . Note When programming a new effect, whenever it is possible, prefer using `time_transform` and `image_transform` instead of `transform` when implementing new effects. The reason is that, though they both internally rely on `transform` when these effects are applied to `ImageClip` objects, MoviePy will recognize they only need to be applied once instead of on each frame, resulting in faster renderings. To keep things simple, we have only addressed the case of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") , but know that the same principle applies to [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") , except that instead of a picture frame, you will have an audio frame, which is also a numpy array. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/user_guide/modifying.rst) [Show Source](../_sources/user_guide/modifying.rst.txt) --- # Creating your own effects — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Creating your own effects[#](#creating-your-own-effects "Permalink to this heading") ===================================================================================== In addition to the existing effects already offered by MoviePy, we can create our own effects to modify a clip however we want. Why creating your own effects?[#](#why-creating-your-own-effects "Permalink to this heading") ---------------------------------------------------------------------------------------------- For simple enough tasks, we’ve seen that we can [Modify a clip appearance and timing using filters](modifying.html#modifying-filters) . Though it might be enough for simple tasks, filters are kind of limited: * They can only access frame and/or timepoint * We cannot pass arguments to them * They are hard to maintain and re-use To allow for more complex and reusable clip modifications, we can create our own custom effects, that we will later apply with [`with_effects()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_effects "moviepy.Clip.Clip.with_effects") . For example, imagine we want to add a progress bar to a clip, to do so we will not only need the time and image of the current frame, but also the total duration of the clip. We will also probably want to be able to pass parameters to define the appearance of the progress bar, such as color or height. This is a perfect task for an effect! Creating an effect[#](#creating-an-effect "Permalink to this heading") ----------------------------------------------------------------------- In MoviePy, effects are objects of type [`moviepy.Effect.Effect`](../reference/reference/moviepy.Effect.html#moviepy.Effect.Effect "moviepy.Effect.Effect") , which is the base `abstract class` for all effects (kind of the same as [`Clip`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") is the base for all [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") and [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") ). So, to create an effect, we will need to inherit the [`Effect`](../reference/reference/moviepy.Effect.html#moviepy.Effect.Effect "moviepy.Effect.Effect") class, and do two things: * Create an `__init__` method to be able to received the parameters of our effect. * Implement the inherited [`apply()`](../reference/reference/moviepy.Effect.html#moviepy.Effect.Effect.apply "moviepy.Effect.Effect.apply") method, which must take as an argument the clip we want to modify, and return the modified version. In the end, your effect will probably use [`time_transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.time_transform "moviepy.Clip.Clip.time_transform") , `image_transform()`, or [`transform()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.transform "moviepy.Clip.Clip.transform") to really apply your modifications on the clip, The main difference is, because your filter will be a method or an anonymous function inside your effect class, you will be able to access all properties of your object from it! So, lets see how we could create our progress bar effect: """Let's write a custom effect that will add a basic progress bar at the bottom of our clip.""" from moviepy import VideoClip from moviepy.decorators import requires\_duration \# Here you see a decorator that will verify if our clip have a duration \# MoviePy offer a few of them that may come handy when writing your own effects @requires\_duration def progress\_bar(clip: VideoClip, color: tuple, height: int \= 10): """ Add a progress bar at the bottom of our clip Parameters ---------- color: Color of the bar as a RGB tuple height: The height of the bar in pixels. Default = 10 """ \# Because we have define the filter func inside our global effect, \# it have access to global effect scope and can use clip from inside filter def filter(get\_frame, t): progression \= t / clip.duration bar\_width \= int(progression \* clip.w) \# Showing a progress bar is just replacing bottom pixels \# on some part of our frame frame \= get\_frame(t) frame\[\-height:, 0:bar\_width\] \= color return frame return clip.transform(filter, apply\_to\="mask") Note When creating an effect, you frequently have to write boilerplate code for assigning properties on object initialization, `dataclasses` is a nice way to limit that. If you want to create your own effects, in addition of this documentation we strongly encourage you to go and take a look at the existing ones (see [`moviepy.video.fx`](../reference/reference/moviepy.video.fx.html#module-moviepy.video.fx "moviepy.video.fx") and [`moviepy.audio.fx`](../reference/reference/moviepy.audio.fx.html#module-moviepy.audio.fx "moviepy.audio.fx") ) to see how they works and take inspiration. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/user_guide/create_effects.rst) [Show Source](../_sources/user_guide/create_effects.rst.txt) --- # MoviePy Docker — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") MoviePy Docker[#](#moviepy-docker "Permalink to this heading") =============================================================== Prerequisites[#](#prerequisites "Permalink to this heading") ------------------------------------------------------------- Docker installed: [Docker Engine for Linux](https://docs.docker.com/engine/install/) or [Docker Desktop for Windows/Mac/Linux](https://docs.docker.com/desktop/) . Build the docker[#](#build-the-docker "Permalink to this heading") ------------------------------------------------------------------- 1. Move into the moviepy root dir 2. Build the Dockerfile docker build \-t moviepy \-f Dockerfile . How to run the unittests from docker[#](#how-to-run-the-unittests-from-docker "Permalink to this heading") ----------------------------------------------------------------------------------------------------------- Run pytest inside the container with the following command docker run \-w /moviepy \-it moviepy python \-m pytest Running your own moviepy script from docker[#](#running-your-own-moviepy-script-from-docker "Permalink to this heading") ------------------------------------------------------------------------------------------------------------------------- Change directory to where your script is located If moviepy docker container is already running, you can connect by: docker exec \-it moviepy python myscript.py If the container isn’t running already docker run \-it moviepy bash python myscript.py You can also start a container and run a script in one command: docker run -it -v \`pwd\`:/code moviepy python myscript.py On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/docker.rst) [Show Source](../_sources/getting_started/docker.rst.txt) --- # MoviePy in 10 Minutes: Creating a Trailer from “Big Buck Bunny” — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") MoviePy in 10 Minutes: Creating a Trailer from “Big Buck Bunny”[#](#moviepy-in-10-minutes-creating-a-trailer-from-big-buck-bunny "Permalink to this heading") ============================================================================================================================================================== Note This tutorial aims to be a simple and short introduction for new users wishing to use MoviePy. For a more in-depth exploration of the concepts seen in this tutorial, see [The MoviePy User Guide](../user_guide/index.html#user-guide) . In this tutorial, you will learn the basics of how to use the MoviePy library in just 10 minutes. As an example project for this tutorial, we will create the following trailer for the movie [“Big Buck Bunny.”](https://peach.blender.org/) . Your browser does not support HTML5 video in MP4 format. Prerequisites[#](#prerequisites "Permalink to this heading") ------------------------------------------------------------- Before we start, make sure you have MoviePy installed. You can install it using pip: pip install moviepy Also, we will need to gather a few resources such as the original movie, font files, images, etc. To make it easy, we have prepared a template project you can download directly: 1. Download [`the project template`](../_downloads/6cdf6df1cdd6ff82115103c53eafc77b/moviepy_10_minutes.zip) and unzip it. 2. Take a look at the resources inside the folder to familiarize yourself. 3. Create a Python script file named `trailer.py` in the project directory. Now, you are ready to proceed to the next steps. Step 1: Import MoviePy and Load the Video[#](#step-1-import-moviepy-and-load-the-video "Permalink to this heading") -------------------------------------------------------------------------------------------------------------------- Let’s start by importing the necessary modules and loading the “Big Buck Bunny” video into our Python program: \# Lets import moviepy, lets also import numpy we will use it a some point from moviepy import \* import numpy as np ################# \# VIDEO LOADING # ################# \# We load our video video \= VideoFileClip("./resources/bbb.mp4") As you see, loading a video file is really easy, but MoviePy isn’t limited to video. It can handle images, audio, texts, and even custom animations. No matter the kind of resources, ultimately any clip will be either a [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") for any visual element, and an [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") for any audio element. In this tutorial, we will only see a few of those, but if you want to explore more, you can find an exhaustive list in the user guide about [Loading resources as clips](../user_guide/loading.html#loading) . Step 2: Extract the Best Scenes[#](#step-2-extract-the-best-scenes "Permalink to this heading") ------------------------------------------------------------------------------------------------ To create our trailer, we will focus on presenting the main characters, so we need to extract parts of the movie. This is a very classic task, so let’s turn our main clip into multiple subclips: ##################### \# SCENES EXTRACTION # ##################### \# We extract the scenes we want to use \# First the characters intro\_clip \= video.subclipped(1, 11) bird\_clip \= video.subclipped(16, 20) bunny\_clip \= video.subclipped(37, 55) rodents\_clip \= video.subclipped( "00:03:34.75", "00:03:56" ) \# we can also use string notation with format HH:MM:SS.uS rambo\_clip \= video.subclipped("04:41.5", "04:44.70") Here, we use the `subclipped` method to extract specific scenes from the main video. We provide the start and end times (in seconds or as text with the format `HH:MM:SS.µS`) for each scene. The extracted clips are stored in their respective variables (`intro_clip`, `bird_clip`, etc.). Step 3: Take a First Look with Preview[#](#step-3-take-a-first-look-with-preview "Permalink to this heading") -------------------------------------------------------------------------------------------------------------- When editing videos, it’s often essential to preview the clips to ensure they meet our vision. This allows you to watch the segment you’re working on and make any necessary adjustments for the perfect result. To do so using MoviePy, you can utilize the `preview()` function available for each clip (the complementary `audio_preview()` is also available for [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") ). Note Note that you will need `ffplay` installed and accessible to MoviePy for preview to work. You can check if `ffplay` is available by running the command `python3 -c "from moviepy.config import check;check()"`. If not, please see [Installation of additional binaries](install.html#install-binaries) . ##################### \# SCENES PREVIEWING # ##################### \# Now, lets have a first look at our clips \# Warning: you need ffplay installed for preview to work \# We set a low fps so our machine can render in real time without slowing down intro\_clip.preview(fps\=20) bird\_clip.preview(fps\=20) bunny\_clip.preview(fps\=20) rodents\_clip.preview(fps\=20) rambo\_clip.preview(fps\=20) By using the preview, you may have noticed that our clips not only contain video but also audio. This is because when loading a video, you not only load the image but also the audio tracks that are turned into [`AudioClip`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") and added to your video clip. Note When previewing, you may encounter video slowing or video/audio shifting. This is not a bug; it’s due to the fact that your computer cannot render the preview in real-time. In such a case, the best course of action is to set the `fps` parameter for the `preview()` at a lower value to make things easier on your machine. Step 4: Modify a Clip by Cutting Out a Part of It[#](#step-4-modify-a-clip-by-cutting-out-a-part-of-it "Permalink to this heading") ------------------------------------------------------------------------------------------------------------------------------------ After previewing the clips, we notice that the rodents’ scene is a bit long. Let’s modify the clip by removing a specific part. It would be nice to remove parts of the scene that we don’t need. This is also quite a common task in video-editing. To do so, we are going to use the `with_section_cut_out` method to remove a portion of the clip between `00:06:00` to `00:10:00`. ############################## \# CLIPS MODIFICATION CUTTING # ############################## \# Well, looking at the rodent scene it is a bit long isn't? \# Let's see how we modify the clip with one of the many clip manipulation method starting by with\_\* \# in that case by removing of the clip the part between 00:06:00 to 00:10:00 of the clip, using with\_section\_cut\_out rodents\_clip \= rodents\_clip.with\_section\_cut\_out(start\_time\=4, end\_time\=10) \# Note: You may have noticed that we have reassign rodents\_clip, this is because all with\_\* methods return a modified \*copy\* of the \# original clip instead of modifying it directly. In MoviePy any function starting by with\_\* is out-place instead of in-place \# meaning it does not modify the original data, but instead copy it and modify/return the copy \# Lets check the result rodents\_clip.preview(fps\=10) In that particular case, we have used the `with_section_cut_out`, but this is only one of the many clip manipulation methods starting with `with_`. We will see a few others in this tutorial, but we will miss a lot more. If you want an exhaustive list, go see [Api Reference](../reference/index.html#reference-manual) . Note You may have noticed that we have reassigned the `rodents_clip` variable instead of just calling a method on it. This is because in MoviePy, any function starting with `with_` is out-of-place instead of in-place, meaning it does not modify the original data but instead copies it and modifies/returns the copy. So you need to store the result of the method and, if necessary, reassign the original variable to update your clip. Step 5: Creating Text/Logo Clips[#](#step-5-creating-text-logo-clips "Permalink to this heading") -------------------------------------------------------------------------------------------------- In addition to videos, we often need to work with images and texts. MoviePy offers some specialized kinds of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") specifically for that purpose: `ImageClip` and `TextClip`. In our case, we want to create text clips to add text overlays between the video clips. We’ll define the font, text content, font size, and color for each text clip. We also want to create image clips for the “Big Buck Bunny” logo and the “Made with MoviePy” logo and resize them as needed. ############################ \# TEXT/LOGO CLIPS CREATION # ############################ \# Lets create the texts to put between our clips font \= "./resources/font/font.ttf" intro\_text \= TextClip( font\=font, text\="The Blender Foundation and\\nPeach Project presents", font\_size\=50, color\="#fff", text\_align\="center", ) bird\_text \= TextClip(font\=font, text\="An unlucky bird", font\_size\=50, color\="#fff") bunny\_text \= TextClip( font\=font, text\="A (slightly overweight) bunny", font\_size\=50, color\="#fff" ) rodents\_text \= TextClip( font\=font, text\="And three rodent pests", font\_size\=50, color\="#fff" ) revenge\_text \= TextClip( font\=font, text\="Revenge is coming...", font\_size\=50, color\="#fff" ) made\_with\_text \= TextClip(font\=font, text\="Made with", font\_size\=50, color\="#fff") \# We will also need the big buck bunny logo, so lets load it and resize it logo\_clip \= ImageClip("./resources/logo\_bbb.png").resized(width\=400) moviepy\_clip \= ImageClip("./resources/logo\_moviepy.png").resized(width\=300) As you can see, `ImageClip` is quite simple, but `TextClip` is a rather complicated object. Don’t hesitate to explore the arguments it accepts. Note In our example, we have used the `resized()` method to resize our image clips. This method works just like any `with_*` method, but because resizing is such a common task, the name has been shortened to `resized()`. The same is true for `cropped()` and `rotated()`. Feel free to experiment with different effects and transitions to achieve the desired trailer effect. Step 6: Timing the clips[#](#step-6-timing-the-clips "Permalink to this heading") ---------------------------------------------------------------------------------- We have all the clips we need, but if we were to combine all the clips into a single one using composition (we will see that in the next step), all our clips would start at the same time and play on top of each other, which is obviously not what we want. Also, some video clips, like images and texts, have no endpoint/duration at creation (unless you have provided a duration parameter), which means trying to render them will throw an error as it would result in an infinite video. To fix that, we need to specify when a clip should start and stop in the final clip. So, let’s start by indicating when each clip must start and end using the appropriate with\_\* methods. ################ \# CLIPS TIMING # ################ \# We have all the clips we need, but if we was to turn all the clips into a single one with composition (we will see that during next step) \# all our clips would start at the same time and play on top of each other, which is obviously not what we want. \# To fix that, we need to say when a clip should start and stop in the final clip. \# So, lets start by telling when each clip must start and end with appropriate with\_\* methods intro\_text \= intro\_text.with\_duration(6).with\_start( 3 ) \# Intro for 6 seconds, start after 3 seconds logo\_clip \= logo\_clip.with\_start(intro\_text.start + 2).with\_end( intro\_text.end ) \# Logo start 2 second after intro text and stop with it bird\_clip \= bird\_clip.with\_start( intro\_clip.end ) \# Make bird clip start after intro, duration already known bird\_text \= bird\_text.with\_start(bird\_clip.start).with\_end( bird\_clip.end ) \# Make text synchro with clip bunny\_clip \= bunny\_clip.with\_start(bird\_clip.end) \# Make bunny clip follow bird clip bunny\_text \= bunny\_text.with\_start(bunny\_clip.start + 2).with\_duration(7) rodents\_clip \= rodents\_clip.with\_start(bunny\_clip.end) rodents\_text \= rodents\_text.with\_start(rodents\_clip.start).with\_duration(4) rambo\_clip \= rambo\_clip.with\_start(rodents\_clip.end \- 1.5) revenge\_text \= revenge\_text.with\_start(rambo\_clip.start + 1.5).with\_duration(4) made\_with\_text \= made\_with\_text.with\_start(rambo\_clip.end).with\_duration(3) moviepy\_clip \= moviepy\_clip.with\_start(made\_with\_text.start).with\_duration(3) Note By default, all clips have a start point at `0`. If a clip has no `duration` but you set the `end_time`, then the `duration` will be calculated for you. The reciprocity is also true. So in our case, we either use `duration` or `end_time`, depending on what is more practical for each specific case. Step 7: Seeing how all clips combine[#](#step-7-seeing-how-all-clips-combine "Permalink to this heading") ---------------------------------------------------------------------------------------------------------- Now that all our clips are timed, let’s get a first idea of how our final clip will look. In video editing, the act of assembling multiple videos into a single one is known as composition. So, MoviePy offers a special kind of [`VideoClip`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") dedicated to the act of combining multiple clips into one, the [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") . [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") takes an array of clips as input and will play them on top of each other at render time, starting and stopping each clip at its start and end points. Note If possible, [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") will extract endpoint and size from the biggest/last ending clip. If a clip in the list has no duration, then you will have to manually set the duration of [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") before rendering. ######################## \# CLIPS TIMING PREVIEW # ######################## \# Lets make a first compositing of the clips into one single clip and do a quick preview to see if everything is synchro quick\_compo \= CompositeVideoClip( \[\ intro\_clip,\ intro\_text,\ logo\_clip,\ bird\_clip,\ bird\_text,\ bunny\_clip,\ bunny\_text,\ rodents\_clip,\ rodents\_text,\ rambo\_clip,\ revenge\_text,\ made\_with\_text,\ moviepy\_clip,\ \] ) quick\_compo.preview(fps\=10) Step 8: Positioning our clips[#](#step-8-positioning-our-clips "Permalink to this heading") -------------------------------------------------------------------------------------------- By looking at this first preview, we see that our clips are pretty well timed, but that the positions of our texts and logo are not satisfying. This is because, for now, we have only specified when our clips should appear, and not the position at which they should appear. By default, all clips are positioned from the top left of the video, at `(0, 0)`. All our clips do not have the same sizes (the texts and images are smaller than the videos), and the [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") takes the size of the biggest clip (so in our case, the size of the videos), so the texts and images are all in the top left portion of the clip. To fix this, we simply have to define the position of our clips in the composition with the method `with_position`. ###################### \# CLIPS POSITIONNING # ###################### \# Now that we have set the timing of our different clips, we need to make sure they are in the right position \# We will keep things simple, and almost always set center center for every texts bird\_text \= bird\_text.with\_position(("center", "center")) bunny\_text \= bunny\_text.with\_position(("center", "center")) rodents\_text \= rodents\_text.with\_position(("center", "center")) revenge\_text \= revenge\_text.with\_position(("center", "center")) \# For the logos and intro/end, we will use pixel position instead of center top \= intro\_clip.h // 2 intro\_text \= intro\_text.with\_position(("center", 200)) logo\_clip \= logo\_clip.with\_position(("center", top)) made\_with\_text \= made\_with\_text.with\_position(("center", 300)) moviepy\_clip \= moviepy\_clip.with\_position(("center", 360)) \# Lets take another look to check positions quick\_compo \= CompositeVideoClip( \[\ intro\_clip,\ intro\_text,\ logo\_clip,\ bird\_clip,\ bird\_text,\ bunny\_clip,\ bunny\_text,\ rodents\_clip,\ rodents\_text,\ rambo\_clip,\ revenge\_text,\ made\_with\_text,\ moviepy\_clip,\ \] ) quick\_compo.preview(fps\=10) Note The position is a tuple with horizontal and vertical position. You can give them as pixels, as strings (`top`, `left`, `right`, `bottom`, `center`), and even as a percentage by providing a float and passing the argument `relative=True`. Now, all our clips are in the right place and timed as expected. Step 9: Adding transitions and effects[#](#step-9-adding-transitions-and-effects "Permalink to this heading") -------------------------------------------------------------------------------------------------------------- So, our clips are timed and placed, but for now, the result is quite raw. It would be nice to have smoother transitions between the clips. In MoviePy, this is achieved through the use of effects. Effects play a crucial role in enhancing the visual and auditory appeal of your video clips. Effects are applied to clips to create transitions, transformations, or modifications, resulting in better-looking videos. Whether you want to add smooth transitions between clips, alter visual appearance, or manipulate audio properties, MoviePy comes with many existing effects to help you bring your creative vision to life with ease. You can find these effects under the namespace `vfx` for video effects and `afx` for audio effects. Note You can use audio effects on both audio and video clips because when applying audio effects to a video clip, the effect will actually be applied to the video clip’s embedded audio clip instead. Using an effect is very simple. You just have to call the method `with_effects` on your clip and pass an array of effect objects to apply. In our case, we will add simple fade-in/out and cross-fade-in/out transitions between our clips, as well as slow down the `rambo_clip`. ################################ \# CLIPS TRANSITION AND EFFECTS # ################################ \# Now that our clip are timed and positionned, lets add some transition to make it more natural \# To do so we use the with\_effects method and the video effects in vfx \# We call with\_effects on our clip and pass it an array of effect objects to apply \# We'll keep it simple, nothing fancy just cross fading intro\_text \= intro\_text.with\_effects(\[vfx.CrossFadeIn(1), vfx.CrossFadeOut(1)\]) logo\_clip \= logo\_clip.with\_effects(\[vfx.CrossFadeIn(1), vfx.CrossFadeOut(1)\]) bird\_text \= bird\_text.with\_effects(\[vfx.CrossFadeIn(0.5), vfx.CrossFadeOut(0.5)\]) bunny\_text \= bunny\_text.with\_effects(\[vfx.CrossFadeIn(0.5), vfx.CrossFadeOut(0.5)\]) rodents\_text \= rodents\_text.with\_effects(\[vfx.CrossFadeIn(0.5), vfx.CrossFadeOut(0.5)\]) \# Also add cross fading on video clips and video clips audio \# See how video effects are under vfx and audio ones under afx intro\_clip \= intro\_clip.with\_effects( \[vfx.FadeIn(1), vfx.FadeOut(1), afx.AudioFadeIn(1), afx.AudioFadeOut(1)\] ) bird\_clip \= bird\_clip.with\_effects( \[vfx.FadeIn(1), vfx.FadeOut(1), afx.AudioFadeIn(1), afx.AudioFadeOut(1)\] ) bunny\_clip \= bunny\_clip.with\_effects( \[vfx.FadeIn(1), vfx.FadeOut(1), afx.AudioFadeIn(1), afx.AudioFadeOut(1)\] ) rodents\_clip \= rodents\_clip.with\_effects( \[vfx.FadeIn(1), vfx.CrossFadeOut(1.5), afx.AudioFadeIn(1), afx.AudioFadeOut(1.5)\] ) \# Just fade in, rambo clip will do the cross fade rambo\_clip \= rambo\_clip.with\_effects( \[vfx.CrossFadeIn(1.5), vfx.FadeOut(1), afx.AudioFadeIn(1.5), afx.AudioFadeOut(1)\] ) rambo\_clip \= rambo\_clip.with\_effects( \[vfx.CrossFadeIn(1.5), vfx.FadeOut(1), afx.AudioFadeIn(1.5), afx.AudioFadeOut(1)\] ) \# Effects are not only for transition, they can also change a clip timing or appearance \# To show that, lets also modify the Rambo-like part of our clip to be in slow motion \# PS: We do it for effect, but this is one of the few effects that have a direct shortcut, with\_speed\_scaled \# the others are with\_volume\_scaled, resized, cropped and rotated rambo\_clip \= rambo\_clip.with\_effects(\[vfx.MultiplySpeed(0.5)\]) \# Because we modified timing of rambo\_clip with our MultiplySpeed effect, we must re-assign the following clips timing made\_with\_text \= made\_with\_text.with\_start(rambo\_clip.end).with\_duration(3) moviepy\_clip \= moviepy\_clip.with\_start(made\_with\_text.start).with\_duration(3) \# Let's have a last look at the result to make sure everything is working as expected quick\_comp \= CompositeVideoClip( \[\ intro\_clip,\ intro\_text,\ logo\_clip,\ bird\_clip,\ bird\_text,\ bunny\_clip,\ bunny\_text,\ rodents\_clip,\ rodents\_text,\ rambo\_clip,\ revenge\_text,\ made\_with\_text,\ moviepy\_clip,\ \] ) quick\_comp.preview(fps\=10) Well, this looks a lot nicer! For this tutorial, we want to keep things simple, so we mostly used transitions. However, you can find many different effects and even create your own. For a more in-depth presentation, see [`moviepy.video.fx`](../reference/reference/moviepy.video.fx.html#module-moviepy.video.fx "moviepy.video.fx") , [`moviepy.audio.fx`](../reference/reference/moviepy.audio.fx.html#module-moviepy.audio.fx "moviepy.audio.fx") , and [Creating your own effects](../user_guide/create_effects.html#create-effects) . Note Looking at the result, you may notice that cross-fading makes clips go from transparent to opaque, and reciprocally, and wonder how it works. We won’t get into details, but know that in MoviePy, you can declare some sections of a video clip to be transparent by using masks. Masks are nothing more than special kinds of video clips that are made of values ranging from `0` for a transparent pixel to `1` for a fully opaque one. For more info, see [Mask clips](../user_guide/loading.html#loading-masks) . Step 10: Modifying the appearance of a clip using filters[#](#step-10-modifying-the-appearance-of-a-clip-using-filters "Permalink to this heading") ---------------------------------------------------------------------------------------------------------------------------------------------------- Finally, to make it more epic, we will apply a custom filter to our Rambo clip to make the image sepia. MoviePy does not come with a sepia effect out of the box, and creating a full custom effect is beyond the scope of this tutorial. However, we will see how we can apply a simple filter to our clip using the [`image_transform()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.image_transform "moviepy.video.VideoClip.VideoClip.image_transform") method. To understand how filters work, you first need to understand that in MoviePy, a clip frame is nothing more than a numpy `ndarray` of shape `HxWx3`. This means we can modify how a frame looks like by applying simple math operations. Doing that on all the frames allows us to apply a filter to our clip! The “apply to all frames” part is done by the `image_transform` method. This method takes a callback function as an argument, and at render time, it will trigger the callback for each frame of the clip, passing the current frame. Warning This is a bit of an advanced usage, and the example involves matrix multiplication. If this is too much for you, you can simply ignore it until you really need to make custom filters, then go look for a more detailed explanation on how to do filtering ([Modify a clip appearance and timing using filters](../user_guide/modifying.html#modifying-filters) ) and create custom effects ([Creating your own effects](../user_guide/create_effects.html#create-effects) ) in the user guide. What you need to remember is just that we can apply filters on images. Here we do it mathematically, but you could very well use a library such as Pillow (provided it can understand numpy images) to do the maths for you! ############### \# CLIP FILTER # ############### \# Lets finish by modifying our rambo clip to make it sepia \# We will start by defining a function that turn a numpy image into sepia \# It takes the image as numpy array in entry and return the modified image as output def sepia\_filter(frame: np.ndarray): \# Sepia filter transformation matrix \# Sepia transform works by applying to each pixel of the image the following rules \# res\_R = (R \* .393) + (G \*.769) + (B \* .189) \# res\_G = (R \* .349) + (G \*.686) + (B \* .168) \# res\_B = (R \* .272) + (G \*.534) + (B \* .131) # \# With numpy we can do that very efficiently by multiplying the image matrix by a transformation matrix sepia\_matrix \= np.array( \[\[0.393, 0.769, 0.189\], \[0.349, 0.686, 0.168\], \[0.272, 0.534, 0.131\]\] ) \# Convert the image to float32 format for matrix multiplication frame \= frame.astype(np.float32) \# Apply the sepia transformation \# .T is needed because multiplying matrix of shape (n,m) \* (m,k) result in a matrix of shape (n,k) \# what we want is (n,m), so we must transpose matrix (m,k) to (k,m) sepia\_image \= np.dot(frame, sepia\_matrix.T) \# Because final result can be > 255, we limit the result to range \[0, 255\] sepia\_image \= np.clip(sepia\_image, 0, 255) \# Convert the image back to uint8 format, because we need integer not float sepia\_image \= sepia\_image.astype(np.uint8) return sepia\_image \# Now, we simply apply the filter to our clip by calling image\_transform, which will call our filter on every frame rambo\_clip \= rambo\_clip.image\_transform(sepia\_filter) \# Let's see how our filter look rambo\_clip.preview(fps\=10) Step 11: Rendering the final clip to a file[#](#step-11-rendering-the-final-clip-to-a-file "Permalink to this heading") ------------------------------------------------------------------------------------------------------------------------ So, our final clip is ready, and we have made all the cutting and modifications we want. We are now ready to save the final result into a file. In video editing, this operation is known as rendering. Again, we will keep things simple and just do video rendering without much tweaking. In most cases, MoviePy and FFmpeg will automatically find the best settings. Take a look at [`write_videofile()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_videofile "moviepy.video.VideoClip.VideoClip.write_videofile") for more info. ################## \# CLIP RENDERING # ################## \# Everything is good and ready, we can finally render our clip into a file final\_clip \= CompositeVideoClip( \[\ intro\_clip,\ intro\_text,\ logo\_clip,\ bird\_clip,\ bird\_text,\ bunny\_clip,\ bunny\_text,\ rodents\_clip,\ rodents\_text,\ rambo\_clip,\ revenge\_text,\ made\_with\_text,\ moviepy\_clip,\ \] ) final\_clip.write\_videofile("./result.mp4") Conclusion[#](#conclusion "Permalink to this heading") ------------------------------------------------------- Congratulations! You have successfully created a trailer for the movie “Big Buck Bunny” using the MoviePy library. This tutorial covered the basics of MoviePy, including loading videos, trimming scenes, adding effects and transitions, overlaying text, and even a little bit of filtering. If you want to dig deeper into MoviePy, we encourage you to try and experiment with this base example by using different effects, transitions, and audio elements to make your trailer truly captivating. We also encourage you to go and read the [The MoviePy User Guide](../user_guide/index.html#user-guide) , as well as looking directly at the [Api Reference](../reference/index.html#reference-manual) . On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/moviepy_10_minutes.rst) [Show Source](../_sources/getting_started/moviepy_10_minutes.rst.txt) --- # MoviePy’s Contribution Guidelines — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") MoviePy’s Contribution Guidelines[#](#moviepy-s-contribution-guidelines "Permalink to this heading") ===================================================================================================== Communication on GitHub[#](#communication-on-github "Permalink to this heading") --------------------------------------------------------------------------------- * Keep messages on GitHub issues and pull requests on-topic and to the point. Be aware that each comment triggers a notification which gets sent out to a number of people. * Opinions are OK. * For longer or more in-depth discussions, use the [MoviePy Gitter](https://gitter.im/Movie-py) . If these discussions lead to a decision, like a merge/reject, please leave a message on the relevant MoviePy issue to document the outcome of the discussion/the reason for the decision. * Do not push any commit that changes the API without prior discussion. Preparing for development[#](#preparing-for-development "Permalink to this heading") ------------------------------------------------------------------------------------- * Fork the official MoviePy repository to your own GitHub account: Use the “Fork” button in the top right corner of the GitHub interface while viewing [the official MoviePy](https://github.com/Zulko/moviepy) repository. * Use your fork as the basis for cloning the repository to your local machine: `$ git clone URL_TO_YOUR_FORK` You can get the appropriate URL (SSH- or HTTPS-based) by using the green “Code” button located at the top right of the repository view while looking at your fork. By default, Git refers to any remote you clone from – i.e. in this case your fork on GitHub – as `origin`. * Enter your local clone and add the official MoviePy repository as a second remote, with alias `upstream`: `$ git remote add upstream git@github.com:Zulko/moviepy.git` (using SSL) \_or\_ `$ git remote add upstream https://github.com/Zulko/moviepy.git` (using HTTPS). * Install the library inside a [virtual environment](https://docs.python.org/3/tutorial/venv.html) with all dependencies included using `$ pip install -e ".[optional,doc,test,lint]"` * Configure pre-commit hooks running `$ pre-commit install` Coding conventions, code quality[#](#coding-conventions-code-quality "Permalink to this heading") -------------------------------------------------------------------------------------------------- * Respect [PEP8](https://www.python.org/dev/peps/pep-0008/) conventions. * Add just the “right” amount of comments. Try to write auto-documented code with very explicit variable names. * If you introduce new functionality or fix a bug, document it in the docstring or with code comments. * MoviePy’s team adopted [pre-commit](https://pre-commit.com/) to run code checks using black, flake8 and isort, so make sure that you’ve configured the pre-commit hooks with `pre-commit install`. Standard contribution workflow[#](#standard-contribution-workflow "Permalink to this heading") ----------------------------------------------------------------------------------------------- ### Local development[#](#local-development "Permalink to this heading") * Keep your local `master` branch up-to-date with the official repo’s master by periodically fetching/pulling it: `$ git pull upstream master` * Never make changes on `master` directly, but branch off into separate develop branches: `$ git checkout --branch YOUR_DEVELOP_BRANCH` Ideally, these are given names which function as keywords for what you are working on, and are prefixed with `fix_` (for bug fixes), `feature_` or something similarly appropriate and descriptive. * Base any changes you submit on the most recent `master`. More detailed explanation of the last point: It is likely that the official repo’s `master` branch will move on (get updated, have other PRs merged into it) while you are working on your changes. Before creating a pull request, you will have to make sure your changes are not based on outdated code. For this reason, it makes sense to avoid falling “too much behind” while developing by rebasing your local `master` branch at intervals. Make sure your `master` branch is in sync with the official `master` branch (as per the first point), then, while checked into your develop branch, run: `$ git rebase master` If you **haven’t rebased before**, make sure to **familiarise yourself** with the concept. ### Submitting Pull Requests[#](#submitting-pull-requests "Permalink to this heading") You do not have to have finished your feature or bug fix before submitting a PR; just mention that it still is a work in progress. Before submitting PRs: * run the test suite over your code to expose any problems: `$ pytest` * push your local develop branch to your GitHub fork `$ git push origin YOUR_DEVELOP_BRANCH` When you now look at your forked repo on your GitHub account, you will see GitHub suggest branches for sending pull requests to the official `Zulko/moviepy` repository. Once you open a PR, you will be presented with a template which you are asked to fill out. You are encouraged to add any additional information which helps provide further context to your changes, and to link to any issues or PRs which your pull request references or is informed by. On submitting your PR, an automated test suite runs over your submission, which might take a few minutes to complete. In a next step, a MoviePy maintainer will review your code and, if necessary, help you to get it merge-ready. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/developer_guide/contribution_guidelines.rst) [Show Source](../_sources/developer_guide/contribution_guidelines.rst.txt) --- # Publishing a New Version of MoviePy — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Publishing a New Version of MoviePy[#](#publishing-a-new-version-of-moviepy "Permalink to this heading") ========================================================================================================= This section is for maintainers responsible for publishing new versions of MoviePy. Follow these steps to ensure the process is smooth and consistent: **Pre-requisites**[#](#pre-requisites "Permalink to this heading") ------------------------------------------------------------------- * Ensure you have proper permissions to push changes and create releases in the MoviePy repository. Steps to Publish a New Version[#](#steps-to-publish-a-new-version "Permalink to this heading") ----------------------------------------------------------------------------------------------- 1. **Update the \`CHANGELOG.md\`** * Add a new section for the upcoming version, respecting the format used in previous entries. * Summarize all changes, fixes, and new features. 2. **Update the version in \`pyproject.toml\`** * Open the pyproject.toml file. * Update the version field to the new version, following [Semantic Versioning](https://semver.org/) . 3. **Commit and Push** * Stage your changes: git add CHANGELOG.md pyproject.toml * Commit your changes: git commit \-m "Release vX.Y.Z" * Push your changes: git push 4. **Create a New Tag** * Create a tag for the new version (replace `vX.Y.Z` with the actual version number): git tag \-a vX.Y.Z \-m "Release vX.Y.Z" * Push the tag to the remote repository: git push origin vX.Y.Z 5. **Create a New Release** * Go to the repository’s page on GitHub (or the relevant hosting platform). * Navigate to the “Releases” section and create a new release. * Use the new tag (`vX.Y.Z`) and provide a description for the release. - Copy the changelog for this version into the release description. * Publish the release. GitHub actions will automatically build and publish the new release on PyPi. By following these steps, you ensure that each MoviePy release is well-documented, correctly versioned, and accessible to users. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/developer_guide/maintainers_publish.rst) [Show Source](../_sources/developer_guide/maintainers_publish.rst.txt) --- # Compositing multiple clips — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Compositing multiple clips[#](#compositing-multiple-clips "Permalink to this heading") ======================================================================================= Video composition, also known as non-linear editing, is the fact of mixing and playing several clips together in a new clip. This video is a good example of what compositing you can do with MoviePy: Note Before starting, note that video clips generally carry an audio track and a mask, which are also clips. When you compose these clips together, the soundtrack and mask of the final clip are automatically generated by putting together the soundtracks and masks of the clips. So most of the time you don’t need to worry about mixing the audio and masks. Juxtaposing and concatenating clips[#](#juxtaposing-and-concatenating-clips "Permalink to this heading") --------------------------------------------------------------------------------------------------------- Two simple ways of putting clips together is to concatenate them (to play them one after the other in a single long clip) or to juxtapose them (to put them side by side in a single larger clip). ### Concatenating multiple clips[#](#concatenating-multiple-clips "Permalink to this heading") Concatenation can be done very easily with the function [`concatenate_videoclips()`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips.html#moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips "moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips") . """Let's concatenate (play one after the other) three video clips.""" from moviepy import VideoFileClip, concatenate\_videoclips \# We load all the clips we want to concatenate clip1 \= VideoFileClip("example.mp4") clip2 \= VideoFileClip("example2.mp4").subclipped(0, 1) clip3 \= VideoFileClip("example3.mp4") \# We concatenate them and write the result final\_clip \= concatenate\_videoclips(\[clip1, clip2, clip3\]) final\_clip.write\_videofile("final\_clip.mp4") The `final_clip` is a clip that plays the clips 1, 2, and 3 one after the other. Note The clips do not need to be the same size. If they aren’t, they will all appear centered in a clip large enough to contain the biggest of them, with optionally a color of your choosing to fill the background. For more info, see [`concatenate_videoclips()`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips.html#moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips "moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips") . ### Juxtaposing multiple clips[#](#juxtaposing-multiple-clips "Permalink to this heading") Putting multiple clip side by side is done with `clip_array()`: """Let's juxtapose four video clips in a 2x2 grid.""" from moviepy import VideoFileClip, clips\_array, vfx \# We will use the same clip and transform it in 3 ways clip1 \= VideoFileClip("example.mp4").with\_effects(\[vfx.Margin(10)\]) \# add 10px contour clip2 \= clip1.with\_effects(\[vfx.MirrorX()\]) \# Flip horizontaly clip3 \= clip1.with\_effects(\[vfx.MirrorY()\]) \# Flip verticaly clip4 \= clip1.resized(0.6) \# downsize to 60% of original \# The form of the final clip will depend of the shape of the array \# We want our clip to be our 4 videos, 2x2, so we make an array of 2x2 array \= \[\ \[clip1, clip2\],\ \[clip3, clip4\],\ \] final\_clip \= clips\_array(array) \# let's resize the final clip so it has 480px of width final\_clip \= final\_clip.resized(width\=480) final\_clip.write\_videofile("final\_clip.mp4") You obtain a clip which looks like this: ![../_images/stacked.jpeg](../_images/stacked.jpeg) For more info, see `clip_array()`. More complex video compositing[#](#more-complex-video-compositing "Permalink to this heading") ----------------------------------------------------------------------------------------------- The [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") class is the base of all video compositing. For example, internally, both [`concatenate_videoclips()`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips.html#moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips "moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips") and `clip_array()` create a [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") . It provides a very flexible way to compose clips, by playing multiple clip _on top of_ of each other, in the order they have been passed to [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") , here’s an example : """Let's stack three video clips on top of each other with CompositeVideoClip.""" from moviepy import VideoFileClip, CompositeVideoClip \# We load all the clips we want to compose clip1 \= VideoFileClip("example.mp4") clip2 \= VideoFileClip("example2.mp4").subclipped(0, 1) clip3 \= VideoFileClip("example.mp4") \# We concatenate them and write theme stacked on top of each other, \# with clip3 over clip2 over clip1 final\_clip \= CompositeVideoClip(\[clip1, clip2, clip3\]) final\_clip.write\_videofile("final\_clip.mp4") Now `final_clip` plays all clips at the same time, with `clip3` over `clip2` over `clip1`. It means that, if all clips have the same size, then only `clip3`, which is on top, will be visible in the video… Unless `clip3` and/or `clip2` have masks which hide parts of them. Note Note that by default the composition has the size of its first clip (as it is generally a _background_). But sometimes you will want to make your clips _float_ in a bigger composition. To do so, just pass the size of the final composition as `size` parameter of [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") . For now we have stacked multiple clip on top of each others, but this is obviously not enough for doing real video compositing. For that, we will need to change when some clip starts and stops playing, as well as define the x:y, position of these clips in the final video. For more info, see [`CompositeVideoClip`](../reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip") . ### Changing starting and stopping times of clips[#](#changing-starting-and-stopping-times-of-clips "Permalink to this heading") In a CompositionClip, each clip start to play at a time that is specified by his `clip.start` attribute, and will play until `clip.end`. So, considering that you would want to play `clip1` for the first 6 seconds, `clip2` 5 seconds after the start of the video, and finally `clip3` at the end of `clip2`, you would do as follows: from moviepy import VideoFileClip, CompositeVideoClip \# We load all the clips we want to compose clip1 \= VideoFileClip("example.mp4") clip2 \= VideoFileClip("example2.mp4").subclipped(0, 1) clip3 \= VideoFileClip("example3.mp4") \# We want to stop clip1 after 1s clip1 \= clip1.with\_end(1) \# We want to play clip2 after 1.5s clip2 \= clip2.with\_start(1.5) \# We want to play clip3 at the end of clip2, and so for 3 seconds only \# Some times its more practical to modify the duration of a clip instead \# of his end clip3 \= clip3.with\_start(clip2.end).with\_duration(1) \# We write the result final\_clip \= CompositeVideoClip(\[clip1, clip2, clip3\]) final\_clip.write\_videofile("final\_clip.mp4") Note When working with timing of your clip, you will frequently want to keep only parts of the original clip. To do so, you should take a look at [`subclipped()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.subclipped "moviepy.Clip.Clip.subclipped") and [`with_section_cut_out()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_section_cut_out "moviepy.Clip.Clip.with_section_cut_out") . ### Positioning clips[#](#positioning-clips "Permalink to this heading") Frequently, you will want a smaller clip to appear on top of a larger one, and decide where it will appear in the composition by setting their position. You can do so by using the [`with_position()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.with_position "moviepy.video.VideoClip.VideoClip.with_position") method. The position is always defined from the top left corner, but you can define it in many ways : """Let's position some text and images on a video.""" from moviepy import TextClip, VideoFileClip, CompositeVideoClip, ImageClip \# We load all the clips we want to compose background \= VideoFileClip("example2.mp4").subclipped(0, 2) title \= TextClip( "./example.ttf", text\="Big Buck Bunny", font\_size\=80, color\="#fff", text\_align\="center", duration\=1, ) author \= TextClip( "./example.ttf", text\="Blender Foundation", font\_size\=40, color\="#fff", text\_align\="center", duration\=1, ) copyright \= TextClip( "./example.ttf", text\="© CC BY 3.0", font\_size\=20, color\="#fff", text\_align\="center", duration\=1, ) logo \= ImageClip("./example2.png", duration\=1).resized(height\=50) \# We want our title to be at the center horizontaly and start at 25% \# of the video verticaly. We can set as "center", "left", "right", \# "top" and "bottom", and % relative from the clip size title \= title.with\_position(("center", 0.25), relative\=True) \# We want the author to be in the center, 30px under the title \# We can set as pixels top \= background.h \* 0.25 + title.h + 30 left \= (background.w \- author.w) / 2 author \= author.with\_position((left, top)) \# We want the copyright to be 30px before bottom copyright \= copyright.with\_position(("center", background.h \- copyright.h \- 30)) \# Finally, we want the logo to be in the center, but to drop as time pass \# We can do so by setting position as a function that take time as argument, \# a lot like frame\_function top \= (background.h \- logo.h) / 2 logo \= logo.with\_position(lambda t: ("center", top + t \* 30)) \# We write the result final\_clip \= CompositeVideoClip(\[background, title, author, copyright, logo\]) final\_clip.write\_videofile("final\_clip.mp4") When indicating the position keep in mind that the `y` coordinate has its zero at the top of the picture: ![../_images/videoWH.jpeg](../_images/videoWH.jpeg) ### Adding transitions effects[#](#adding-transitions-effects "Permalink to this heading") The last part of composition is adding transition effects. For example, when a clip start while another is still playing, it would be nice to make the new one fade-in instead of showing abruptly. To do so, we can use the transitions offered by MoviePy in `transitions`, like `crossfadein()` : """In this example, we will concatenate two clips with a 1-second crossfadein of the second clip.""" from moviepy import VideoFileClip, CompositeVideoClip, vfx \# We load all the clips we want to compose clip1 \= VideoFileClip("example.mp4") clip2 \= VideoFileClip("example2.mp4") clips \= \[\ clip1.with\_end(2),\ clip2.with\_start(1).with\_effects(\[vfx.CrossFadeIn(1)\]),\ \] final\_clip \= CompositeVideoClip(clips) final\_clip.write\_videofile("final\_clip.mp4") MoviePy offer only few transitions in `transitions`. But technically, transitions are mostly effects applied to the mask of a clip! That means you can actually use any of the already existing effects, and use them as transitions by applying them on the mask of your clip (see . For more info, see `transitions` and [`moviepy.video.fx`](../reference/reference/moviepy.video.fx.html#module-moviepy.video.fx "moviepy.video.fx") . #### Compositing audio clips[#](#compositing-audio-clips "Permalink to this heading") When you mix video clips together, MoviePy will automatically compose their respective audio tracks to form the audio track of the final clip, so you don’t need to worry about compositing these tracks yourself. If you want to make a custom audio track from several audio sources, audio clips can be mixed together like video clips, with [`CompositeAudioClip`](../reference/reference/moviepy.audio.AudioClip.CompositeAudioClip.html#moviepy.audio.AudioClip.CompositeAudioClip "moviepy.audio.AudioClip.CompositeAudioClip") and [`concatenate_audioclips()`](../reference/reference/moviepy.audio.AudioClip.concatenate_audioclips.html#moviepy.audio.AudioClip.concatenate_audioclips "moviepy.audio.AudioClip.concatenate_audioclips") : """Let's first concatenate (one after the other) then composite (on top of each other) three audio clips.""" from moviepy import AudioFileClip, CompositeAudioClip, concatenate\_audioclips \# We load all the clips we want to compose clip1 \= AudioFileClip("example.wav") clip2 \= AudioFileClip("example2.wav") clip3 \= AudioFileClip("example3.wav") \# All clip will play one after the other concat \= concatenate\_audioclips(\[clip1, clip2, clip3\]) \# We will play clip1, then on top of it clip2 starting at t=5s, \# and clip3 on top of both starting t=9s compo \= CompositeAudioClip( \[\ clip1.with\_volume\_scaled(1.2),\ clip2.with\_start(5), \# start at t=5s\ clip3.with\_start(9),\ \] ) On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/user_guide/compositing.rst) [Show Source](../_sources/user_guide/compositing.rst.txt) --- # Unknown .. \_user\_guide: The MoviePy User Guide ------------------------------ The User Guide covers all of MoviePy's main concepts grouped by tasks (loading, editing, composing, rendering), with a presentation of the different concept/elements relative to the tasks along with short code example. It is a good place for users wishing to understand more precisely one of these aspects and to discover the different MoviePy elements relative to it. For users wanting to have a quick overview of how to use MoviePy, a better place to start is the :ref:\`getting\_started\` section, and more specifically the :ref:\`moviepy\_10\_minutes\` tutorial. For a full overview of MoviePy, see the :ref:\`reference\_manual\`. .. toctree:: :maxdepth: 1 loading modifying create\_effects compositing rendering --- # Unknown .. \_developer\_guide: The MoviePy Developers Guide ------------------------------ The Developers Guide covers most of the things people wanting to participate to MoviePy development need to know. .. toctree:: :maxdepth: 1 developers\_install contribution\_guidelines maintainers\_publish --- # Unknown .. \_getting\_started: Getting started with MoviePy ------------------------------ This section explain everything you need to start editing with MoviePy. To go further, have a look at the :ref:\`user\_guide\` and the :ref:\`reference\_manual\`. .. toctree:: :maxdepth: 1 install quick\_presentation moviepy\_10\_minutes docker updating\_to\_v2 FAQ --- # Previewing and saving video clips — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") Previewing and saving video clips[#](#previewing-and-saving-video-clips "Permalink to this heading") ===================================================================================================== Once you are down working with your clips, the last step will be to export the result into a video/image file, or sometimes to simply preview it in order to verify everything is working as expected. Previewing a clip[#](#previewing-a-clip "Permalink to this heading") --------------------------------------------------------------------- When you are working with a clip, you will frequently need to have a peak at what your clip looks like, either to verify that everything is working as intended, or to check how things looks. To do so you could render your entire clip into a file, but that’s a pretty long task, and you only need a quick look, so a better solution exists: previewing. ### Preview a clip as a video[#](#preview-a-clip-as-a-video "Permalink to this heading") Warning You must have `ffplay` installed and accessible to MoviePy to be able to use `preview()`. If you’r not sure, take a look [Installation of additional binaries](../getting_started/install.html#install-binaries) The first thing you can do is to preview your clip as a video, by calling method `preview()` on your clip: from moviepy import \* myclip \= VideoFileClip("./example.mp4").subclipped(0, 1) \# Keep only 0 to 1 sec \# We preview our clip as a video, inheriting FPS and audio of the original clip myclip.preview() \# We preview our clip as video, but with a custom FPS for video and audio \# making it less consuming for our computer myclip.preview(fps\=5, audio\_fps\=11000) \# Now we preview without audio myclip.preview(audio\=False) You will probably frequently want to preview only a small portion of your clip, though `preview` do not offer such capabilities, you can easily emulate such behavior by using [`subclipped()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.subclipped "moviepy.Clip.Clip.subclipped") . Note It is quite frequent for a clip preview to be out of sync, or to play slower than it should. It means that your computer is not powerful enough to render the clip in real time. Don’t hesitate to play with the options of preview: for instance, lower the fps of the sound (11000 Hz is still fine) and the video. Also, downsizing your video with resize can help. For more info, see `preview()`. Note A quite similar function is also available for [`AudioClip()`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") , see [`ffplay_audiopreview()`](../reference/reference/moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview.html#moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview "moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview") . ### Preview just one frame of a clip[#](#preview-just-one-frame-of-a-clip "Permalink to this heading") In a lot of situation, you don’t really need to preview your all clip, seeing only one frame is enough to see how it looks like and to make sure everything goes as expected. To do so, you can use the method `show()` on your clip, passing the frame time as an argument: from moviepy import \* myclip \= VideoFileClip("./example.mp4") \# We show the first frame of our clip myclip.show() \# We show the frame at point 00:00:01.5 of our clip myclip.show(1.5) \# We want to see our clip without applying his mask myclip.show(1.5, with\_mask\=False) Contrary to video previewing, show does not require `ffplay`, but use `pillow` `Image.show` function. For more info, see `show()`. ### Showing a clip in Jupyter Notebook[#](#showing-a-clip-in-jupyter-notebook "Permalink to this heading") If you work with a [Jupyter Notebook](https://jupyter.org/) , it can be very practical to display your clip the notebook. To do so, you can use the method [`display_in_notebook()`](../reference/reference/moviepy.video.io.display_in_notebook.display_in_notebook.html#moviepy.video.io.display_in_notebook.display_in_notebook "moviepy.video.io.display_in_notebook.display_in_notebook") on your clip. [![../_images/demo_preview.jpeg](../_images/demo_preview.jpeg)](../_images/demo_preview.jpeg) With [`display_in_notebook()`](../reference/reference/moviepy.video.io.display_in_notebook.display_in_notebook.html#moviepy.video.io.display_in_notebook.display_in_notebook "moviepy.video.io.display_in_notebook.display_in_notebook") you can embed videos, images and sounds, either from a file or directly from a clip: from moviepy import \* \# ... \# ... some jupyter specifics stuff \# ... my\_video\_clip \= VideoFileClip("./example.mp4") my\_image\_clip \= ImageClip("./example.png") my\_audio\_clip \= AudioFileClip("./example.wav") \# We can show any type of clip my\_video\_clip.display\_in\_notebook() \# embeds a video my\_image\_clip.display\_in\_notebook() \# embeds an image my\_audio\_clip.display\_in\_notebook() \# embeds a sound \# We can display only a snaphot of a video my\_video\_clip.display\_in\_notebook(t\=1) \# We can provide any valid HTML5 option as keyword argument \# For instance, if the clip is too big, we can set width my\_video\_clip.display\_in\_notebook(width\=400) \# We can also make it loop, for example to check if a GIF is \# looping as expected my\_video\_clip.display\_in\_notebook(autoplay\=1, loop\=1) Warning Know that [`display_in_notebook()`](../reference/reference/moviepy.video.io.display_in_notebook.display_in_notebook.html#moviepy.video.io.display_in_notebook.display_in_notebook "moviepy.video.io.display_in_notebook.display_in_notebook") will only work if it is on the last line a the notebook cell. Also, note that [`display_in_notebook()`](../reference/reference/moviepy.video.io.display_in_notebook.display_in_notebook.html#moviepy.video.io.display_in_notebook.display_in_notebook "moviepy.video.io.display_in_notebook.display_in_notebook") actually embeds the clips physically in your notebook. The advantage is that you can move the notebook or put it online and the videos will work. The drawback is that the file size of the notebook can become very large. Depending on your browser, re-computing and displaying at video many times can take some place in the cache and the RAM (it will only be a problem for intensive uses). Restarting your browser solves the problem. For more info, see [`display_in_notebook()`](../reference/reference/moviepy.video.io.display_in_notebook.display_in_notebook.html#moviepy.video.io.display_in_notebook.display_in_notebook "moviepy.video.io.display_in_notebook.display_in_notebook") . Save your clip into a file[#](#save-your-clip-into-a-file "Permalink to this heading") --------------------------------------------------------------------------------------- Once you are satisfied with how your clip looks, you can save it into a file, a step known in video edition as rendering. MoviePy offer various way to save your clip. ### Video files (.mp4, .webm, .ogv…)[#](#video-files-mp4-webm-ogv "Permalink to this heading") The obvious first choice will be to write your clip to a video file, which you can do with [`write_videofile()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_videofile "moviepy.video.VideoClip.VideoClip.write_videofile") : from moviepy import \* \# We load all the clips we want to compose background \= VideoFileClip("long\_examples/example2.mp4").subclipped(0, 10) title \= TextClip( "./example.ttf", text\="Big Buck Bunny", font\_size\=80, color\="#fff", text\_align\="center", duration\=3, ).with\_position(("center", "center")) \# We make our final clip through composition final\_clip \= CompositeVideoClip(\[background, title\]) \# And finally we can write the result into a file \# Here we just save as MP4, inheriting FPS, etc. from final\_clip final\_clip.write\_videofile("result.mp4") \# Here we save as MP4, but we set the FPS of the clip to our own, here 24 fps, like cinema final\_clip.write\_videofile("result24fps.mp4", fps\=24) \# Now we save as WEBM instead, and we want tu use codec libvpx-vp9 (usefull when mp4 + transparency). \# We also want ffmpeg compression optimisation as minimal as possible. This will not change \# the video quality and it will decrease time for encoding, but increase final file size a lot. \# Finally, we want ffmpeg to use 4 threads for video encoding. You should probably leave that \# to default, as ffmpeg is already quite good at using the best setting on his own. final\_clip.write\_videofile( "result.webm", codec\="libvpx-vp9", fps\=24, preset\="ultrafast", threads\=4 ) MoviePy can find the a default codec name for the most common file extensions. If you want to use exotic formats or if you are not happy with the defaults you can provide the codec with `codec='mpeg4'` for instance. There are many many options when you are writing a video (bitrate, parameters of the audio writing, file size optimization, number of processors to use, etc.), and we will not go in details into each. So, for more info, see [`write_videofile()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_videofile "moviepy.video.VideoClip.VideoClip.write_videofile") . Note Though you are encouraged to play with settings of `write_videofile`, know that lowering the optimization preset or increasing the number of threads will not necessarily improve the rendering time, as the bottleneck may be on MoviePy computation of each frame and not in ffmpeg encoding. Also, know that it is possible to pass additional parameters to ffmpeg command line invoked by MoviePy by using the `ffmpeg_params` argument. Sometimes it is impossible for MoviePy to guess the `duration` attribute of the clip (keep in mind that some clips, like ImageClips displaying a picture, have _a priori_ an infinite duration). Then, the `duration` must be set manually with [`with_duration()`](../reference/reference/moviepy.Clip.Clip.html#moviepy.Clip.Clip.with_duration "moviepy.Clip.Clip.with_duration") : from moviepy import \* \# By default an ImageClip has no duration my\_clip \= ImageClip("example.png") try: \# This will fail! We cannot write a clip with no duration! my\_clip.write\_videofile("result.mp4") except: print("Cannot write a video without duration") \# By calling with\_duration on our clip, we fix the problem! We also need to set fps my\_clip.with\_duration(2).write\_videofile("result.mp4", fps\=1) Note A quite similar function is also available for [`AudioClip()`](../reference/reference/moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip") , see `write_audiofile()`. ### Export a single frame of the clip[#](#export-a-single-frame-of-the-clip "Permalink to this heading") As for previewing, sometimes you will need to export only one frame of a clip, for example to create the preview image of a video. You can do so with [`save_frame()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.save_frame "moviepy.video.VideoClip.VideoClip.save_frame") : from moviepy import \* \# We load all the clips we want to compose myclip \= VideoFileClip("example.mp4") myclip.save\_frame("result.png", t\=1) \# Save frame at 1 sec For more info, see [`save_frame()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.save_frame "moviepy.video.VideoClip.VideoClip.save_frame") . ### Animated GIFs[#](#animated-gifs "Permalink to this heading") In addition to writing video files, MoviePy also let you write GIF file with [`write_gif()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_gif "moviepy.video.VideoClip.VideoClip.write_gif") : from moviepy import \* myclip \= VideoFileClip("example.mp4").subclipped(0, 2) \# Here we just save as GIF myclip.write\_gif("result.gif") \# Here we save as GIF, but we set the FPS of our GIF at 10 myclip.write\_gif("result.gif", fps\=10) For more info, see [`write_gif()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_gif "moviepy.video.VideoClip.VideoClip.write_gif") . ### Export all the clip as images in a directory[#](#export-all-the-clip-as-images-in-a-directory "Permalink to this heading") Lastly, you may wish to export an entire clip as an image sequence (multiple images in one directory, one image per frame). You can do so with the function [`write_images_sequence()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_images_sequence "moviepy.video.VideoClip.VideoClip.write_images_sequence") : from moviepy import \* import os myclip \= VideoFileClip("example.mp4") \# Here we just save in dir output with filename being his index (start at 0, then +1 for each frame) os.mkdir("./output") myclip.write\_images\_sequence("./output/%d.jpg") \# We set the FPS of our GIF at 10, and we leftpad name with 0 up to 4 digits myclip.write\_images\_sequence("./output/%04d.jpg") For more info, see [`write_images_sequence()`](../reference/reference/moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip.write_images_sequence "moviepy.video.VideoClip.VideoClip.write_images_sequence") . On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/user_guide/rendering.rst) [Show Source](../_sources/user_guide/rendering.rst.txt) --- # FAQ and troubleshooting — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") FAQ and troubleshooting[#](#faq-and-troubleshooting "Permalink to this heading") ================================================================================= This section intend to answer the most common questions and errors. Common errors that are not bugs[#](#common-errors-that-are-not-bugs "Permalink to this heading") ------------------------------------------------------------------------------------------------- These are very common errors which are not considered as bugs to be solved (but you can still ask for this to change). If these answers don’t work for you, please open a bug report on [Github](https://github.com/Zulko/moviepy) , or on the dedicated [Subreddit](https://www.reddit.com/r/moviepy/) . ### MoviePy generated a video that cannot be read by my favorite player.[#](#moviepy-generated-a-video-that-cannot-be-read-by-my-favorite-player "Permalink to this heading") Known reason: one of the video’s dimensions were not even, for instance 720x405, and you used a MPEG4 codec like libx264 (default in MoviePy). In this case the video generated uses a format that is readable only on some readers like VLC. ### I can’t seem to read any video with MoviePy[#](#i-can-t-seem-to-read-any-video-with-moviepy "Permalink to this heading") Known reason: you have a deprecated version of FFmpeg, install a recent version from the website, not from your OS’s repositories! (see [Installation](install.html#install) ). ### Previewing videos make them slower than they are[#](#previewing-videos-make-them-slower-than-they-are "Permalink to this heading") It means that your computer is not good enough to render the clip in real time. Don’t hesitate to play with the options of `preview`: for instance, lower the fps of the sound (11000 Hz is still fine) and the video. Also, downsizing your video with `resize` can help. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/getting_started/FAQ.rst) [Show Source](../_sources/getting_started/FAQ.rst.txt) --- # moviepy — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy[#](#module-moviepy "Permalink to this heading") ======================================================== Imports everything that you need from the MoviePy submodules so that every thing can be directly imported with `from moviepy import *`. Modules | | | | --- | --- | | [`moviepy.Clip`](moviepy.Clip.html#module-moviepy.Clip "moviepy.Clip") | Implements the central object of MoviePy, the Clip, and all the methods that are common to the two subclasses of Clip, VideoClip and AudioClip. | | [`moviepy.Effect`](moviepy.Effect.html#module-moviepy.Effect "moviepy.Effect")
() | Base abstract class for all effects in MoviePy. | | [`moviepy.audio`](moviepy.audio.html#module-moviepy.audio "moviepy.audio") | Everything about audio manipulation. | | [`moviepy.config`](moviepy.config.html#module-moviepy.config "moviepy.config") | Third party programs configuration for MoviePy. | | [`moviepy.decorators`](moviepy.decorators.html#module-moviepy.decorators "moviepy.decorators") | Decorators used by moviepy. | | [`moviepy.tools`](moviepy.tools.html#module-moviepy.tools "moviepy.tools") | Misc. | | [`moviepy.video`](moviepy.video.html#module-moviepy.video "moviepy.video") | Everything about video manipulation. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.rst) [Show Source](../../_sources/reference/reference/moviepy.rst.txt) --- # moviepy.video.tools.subtitles.file_to_subtitles — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.subtitles.file\_to\_subtitles[#](#moviepy-video-tools-subtitles-file-to-subtitles "Permalink to this heading") =================================================================================================================================== moviepy.video.tools.subtitles.file\_to\_subtitles(_filename_, _encoding\=None_)[\[source\]](../../_modules/moviepy/video/tools/subtitles.html#file_to_subtitles) [#](#moviepy.video.tools.subtitles.file_to_subtitles "Permalink to this definition") Converts a srt file into subtitles. The returned list is of the form `[((start_time,end_time),'some text'),...]` and can be fed to SubtitlesClip. Only works for ‘.srt’ format for the moment. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.subtitles.file_to_subtitles.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.subtitles.file_to_subtitles.rst.txt) --- # moviepy.Clip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.Clip[#](#module-moviepy.Clip "Permalink to this heading") ================================================================== Implements the central object of MoviePy, the Clip, and all the methods that are common to the two subclasses of Clip, VideoClip and AudioClip. Classes | | | | --- | --- | | [`Clip`](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip")
() | Base class of all clips (VideoClips and AudioClips). | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.Clip.rst) [Show Source](../../_sources/reference/reference/moviepy.Clip.rst.txt) --- # Unknown .. \_updating\_to\_v2: Updating from v1.X to v2.X ========================== MoviePy v2.0 has undergone some large changes with the aim of making the API more consistent and intuitive. In order to do so multiple breaking changes have been made. Therefore, there is a high likelihood that your pre-v2.0 programs will not run without some changes. Dropping support of Python 2 ----------------------------- Starting with version 2.0, MoviePy \*\*no longer supports Python 2\*\*, since Python 2 reached its end of life in 2020. Focusing on Python 3.7+ allows MoviePy to take advantage of the latest language features and improvements while maintaining code quality and security. Users are encouraged to upgrade to a supported version of Python to continue using MoviePy. \`\`moviepy.editor\`\` suppression and simplified importation --------------------------------------------------------- Before v2.0, it was advised to import from \`\`moviepy.editor\`\` whenever you needed to do some sort of manual operations, such as previewing or hand editing, because the \`\`editor\`\` package handled a lot of magic and initialization, making your life easier, at the cost of initializing some complex modules like \`\`pygame\`\`. With version 2.0, the \`\`moviepy.editor\`\` namespace simply no longer exists. You simply import everything from \`\`moviepy\`\` like this: :: from moviepy import \* # Simple and nice, the \_\_all\_\_ is set in moviepy so only useful things will be loaded from moviepy import VideoFileClip # You can also import only the things you really need Renaming and API unification ------------------------------ One of the most significant change has been renaming all \`\`.set\_\`\` methods to \`\`.with\_\`\`. More generally, almost all the method modifying a clip now starts by \`\`with\_\`\`, indicating that they work 'outplace', meaning they do not directly modify the clip, but instead copy it, modify this copy, and return the updated copy, leaving the original clip untouched. We advise you to check in your code for any call of method from \`\`Clip\`\` objects and check for a matching \`\`.with\_\`\` equivalent. Massive refactoring of effects ------------------------------- With version 2.0, effects have undergone massive changes and refactoring. Though the logic of why and when applying effects remain globally the same, the implementation changed quite heavily. If you used any kind of effects, you will have to update your code! Moving effects from function to classes """""""""""""""""""""""""""""""""""""""""""""" MoviePy version 2.0 introduces a more structured and object-oriented approach to handling effects. In previous versions, effects were simply Python functions that manipulated video clips or images. However, in version 2.0 and onwards, effects are now represented as classes. This shift allows for better organization, encapsulation, and reusability of code, as well as more comprehensible code. Each effect is now encapsulated within its own class, making it easier to manage and modify. All effects are now implementing the :py:class:\`~moviepy.Effect.Effect\` abstract class, so if you ever used any custom effect. If you ever write your own effect, you will have to migrate to the new object implementation. For more info see :ref:\`create\_effects\`. Moving from \`\`clip.fx\`\` to :py:meth:\`~moviepy.Clip.Clip.with\_effects\` """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Moving from function to object also meant MoviePy had to drop the method \`\`Clip.fx\`\` previously used to apply effects in favor of the new :py:meth:\`~moviepy.Clip.Clip.with\_effects\`. For more info about how to use effects with v2.0, see :ref:\`modifying#effects\`. Removing effects as clip methods """""""""""""""""""""""""""""""""" Before version 2.0, when importing from \`\`moviepy.editor\`\` the effects was added as clip class method at runtime. This is no longer the case. If you previously used effect by calling them as clips method, you must now use :py:meth:\`~moviepy.Clip.Clip.with\_effects\`. Dropping many external dependencies and unifying environment ------------------------------------------------------------- With v1.0, MoviePy relied on many optional external dependencies, trying to gracefully fallback from one library to another in the event one of them was missing, eventually dropping some features when no library was available. This resulted in complex and hard to maintain code for the MoviePy team, as well as fragmented and hard to understand environment for the users. With v2.0 the MoviePy team tried to offer a simpler, smaller and more unified dependency list, with focusing on \`\`pillow\`\` for all complex image manipulation, and dropping altogether the usage of \`\`ImageMagick\`\`, \`\`PyGame\`\`, \`\`OpenCV\`\`, \`\`scipy\`\`, \`\`scikit\`\`, and a few others. Removed features ----------------- Sadly, reducing the scope of MoviePy and limiting the external libraries mean that some features had to be removed, if you used any of the following features, you will have to create your own replacement: - \`\`moviepy.video.tools.tracking\`\` - \`\`moviepy.video.tools.segmenting\`\` - \`\`moviepy.video.io.sliders\`\` Miscellaneous signature changes ------------------------------ When updating the API and moving from previous libraries to \`\`pillow\`\`, some miscellaneous changes also happen, meaning some methods signatures may have changed. You should check the new signatures if you used any of the following: - \`\`TextClip\`\` some arguments named have changed and a path to a font file is now needed at object instantiation - \`\`clip.resize\`\` is now \`\`clip.resized\`\` - \`\`clip.crop\`\` is now \`\`clip.cropped\`\` - \`\`clip.rotate\`\` is now \`\`clip.rotated\`\` - Any previous \`\`Clip\`\` method not starting by \`\`with\_\`\` now probably start with it Why all these changes and updating from v1.0 to v2.0? ------------------------------------------------------- You may ask yourself why were all these changes introduced? The answer is: time. MoviePy have seen many evolution since his first release and have became kind of a complex project, with ambitions sometimes too important in regards to available manpower on the development team. Over time, as in any project, inconsistencies have been introduced in order to support new functionalities without breaking current API, and some initial choices no longer reflected the current state of things. Due to multiple factors, MoviePy have also undergone a long period of time during which the main version distributed through PiPy diverged from the GitHub distributed version, introducing confusion and chaos. In a global effort to simplify future development and limit confusion by providing a unified environment, it has been decided to release a new major version including the many evolutions than happened over the years, which meant breaking changes, and so a new major version released was required. For anyone interested in how and why all of these things have been decided, you can find a lot of the discussion that went into this in GitHub issues \`#1874 \`\_, \`#1089 \`\_ and \`#2012 \`\_. --- # moviepy.Clip.Clip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.Clip.Clip[#](#moviepy-clip-clip "Permalink to this heading") ===================================================================== _class_ moviepy.Clip.Clip[\[source\]](../../_modules/moviepy/Clip.html#Clip) [#](#moviepy.Clip.Clip "Permalink to this definition") Base class of all clips (VideoClips and AudioClips). start[#](#moviepy.Clip.Clip.start "Permalink to this definition") When the clip is included in a composition, time of the composition at which the clip starts playing (in seconds). Type: float end[#](#moviepy.Clip.Clip.end "Permalink to this definition") When the clip is included in a composition, time of the composition at which the clip stops playing (in seconds). Type: float duration[#](#moviepy.Clip.Clip.duration "Permalink to this definition") Duration of the clip (in seconds). Some clips are infinite, in this case their duration will be `None`. Type: float close()[\[source\]](../../_modules/moviepy/Clip.html#Clip.close) [#](#moviepy.Clip.Clip.close "Permalink to this definition") Release any resources that are in use. copy()[\[source\]](../../_modules/moviepy/Clip.html#Clip.copy) [#](#moviepy.Clip.Clip.copy "Permalink to this definition") Allows the usage of `.copy()` in clips as chained methods invocation. get\_frame(_t_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.get_frame) [#](#moviepy.Clip.Clip.get_frame "Permalink to this definition") Gets a numpy array representing the RGB picture of the clip, or (mono or stereo) value for a sound clip, at time `t`. Parameters: **t** (_float_ _or_ _tuple_ _or_ _str_) – Moment of the clip whose frame will be returned. is\_playing(_t_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.is_playing) [#](#moviepy.Clip.Clip.is_playing "Permalink to this definition") If `t` is a time, returns true if t is between the start and the end of the clip. `t` can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. If `t` is a numpy array, returns False if none of the `t` is in the clip, else returns a vector \[b\_1, b\_2, b\_3…\] where b\_i is true if tti is in the clip. iter\_frames(_fps\=None_, _with\_times\=False_, _logger\=None_, _dtype\=None_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.iter_frames) [#](#moviepy.Clip.Clip.iter_frames "Permalink to this definition") Iterates over all the frames of the clip. Returns each frame of the clip as a HxWxN Numpy array, where N=1 for mask clips and N=3 for RGB clips. This function is not really meant for video editing. It provides an easy way to do frame-by-frame treatment of a video, for fields like science, computer vision… Parameters: * **fps** (_int__,_ _optional_) – Frames per second for clip iteration. Is optional if the clip already has a `fps` attribute. * **with\_times** (_bool__,_ _optional_) – Ff `True` yield tuples of `(t, frame)` where `t` is the current time for the frame, otherwise only a `frame` object. * **logger** (_str__,_ _optional_) – Either `"bar"` for progress bar or `None` or any Proglog logger. * **dtype** (_type__,_ _optional_) – Type to cast Numpy array frames. Use `dtype="uint8"` when using the pictures to write video, images.. Examples \# prints the maximum of red that is contained \# on the first line of each frame of the clip. from moviepy import VideoFileClip myclip \= VideoFileClip('myvideo.mp4') print(\[frame\[0,:,0\].max()\ for frame in myclip.iter\_frames()\]) subclipped(_start\_time\=0_, _end\_time\=None_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.subclipped) [#](#moviepy.Clip.Clip.subclipped "Permalink to this definition") Returns a clip playing the content of the current clip between times `start_time` and `end_time`, which can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. The `mask` and `audio` of the resulting subclip will be subclips of `mask` and `audio` the original clip, if they exist. It’s equivalent to slice the clip as a sequence, like `clip[t_start:t_end]`. Parameters: * **start\_time** (_float_ _or_ _tuple_ _or_ _str__,_ _optional_) – Moment that will be chosen as the beginning of the produced clip. If is negative, it is reset to `clip.duration + start_time`. * **end\_time** (_float_ _or_ _tuple_ _or_ _str__,_ _optional_) – Moment that will be chosen as the end of the produced clip. If not provided, it is assumed to be the duration of the clip (potentially infinite). If is negative, it is reset to `clip.duration + end_time`. For instance: \>>> \# cut the last two seconds of the clip: \>>> new\_clip \= clip.subclipped(0, \-2) If `end_time` is provided or if the clip has a duration attribute, the duration of the returned clip is set automatically. time\_transform(_time\_func_, _apply\_to\=None_, _keep\_duration\=False_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.time_transform) [#](#moviepy.Clip.Clip.time_transform "Permalink to this definition") Returns a Clip instance playing the content of the current clip but with a modified timeline, time `t` being replaced by the return of time\_func(t). Parameters: * **time\_func** (_function_) – A function `t -> new_t`. * **apply\_to** (_{"mask"__,_ _"audio"__,_ _\[__"mask"__,_ _"audio"__\]__}__,_ _optional_) – Can be either ‘mask’, or ‘audio’, or \[‘mask’,’audio’\]. Specifies if the filter `transform` should also be applied to the audio or the mask of the clip, if any. * **keep\_duration** (_bool__,_ _optional_) – `False` (default) if the transformation modifies the `duration` of the clip. Examples \# plays the clip (and its mask and sound) twice faster new\_clip \= clip.time\_transform(lambda t: 2\*t, apply\_to\=\['mask', 'audio'\]) \# plays the clip starting at t=3, and backwards: new\_clip \= clip.time\_transform(lambda t: 3\-t) transform(_func_, _apply\_to\=None_, _keep\_duration\=True_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.transform) [#](#moviepy.Clip.Clip.transform "Permalink to this definition") General processing of a clip. Returns a new Clip whose frames are a transformation (through function `func`) of the frames of the current clip. Parameters: * **func** (_function_) – A function with signature (gf,t -> frame) where `gf` will represent the current clip’s `get_frame` method, i.e. `gf` is a function (t->image). Parameter t is a time in seconds, frame is a picture (=Numpy array) which will be returned by the transformed clip (see examples below). * **apply\_to** (_{"mask"__,_ _"audio"__,_ _\[__"mask"__,_ _"audio"__\]__}__,_ _optional_) – Can be either `'mask'`, or `'audio'`, or `['mask','audio']`. Specifies if the filter should also be applied to the audio or the mask of the clip, if any. * **keep\_duration** (_bool__,_ _optional_) – Set to True if the transformation does not change the `duration` of the clip. Examples In the following `new_clip` a 100 pixels-high clip whose video content scrolls from the top to the bottom of the frames of `clip` at 50 pixels per second. \>>> filter \= lambda get\_frame,t : get\_frame(t)\[int(t):int(t)+50, :\] \>>> new\_clip \= clip.transform(filter, apply\_to\='mask') with\_duration(_duration_, _change\_end\=True_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_duration) [#](#moviepy.Clip.Clip.with_duration "Permalink to this definition") Returns a copy of the clip, with the `duration` attribute set to `t`, which can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. Also sets the duration of the mask and audio, if any, of the returned clip. If `change_end is False`, the start attribute of the clip will be modified in function of the duration and the preset end of the clip. Parameters: * **duration** (_float_) – New duration attribute value for the clip. * **change\_end** (_bool__,_ _optional_) – If `True`, the `end` attribute value of the clip will be adjusted accordingly to the new duration using `clip.start + duration`. with\_effects(_effects: List\[[Effect](moviepy.Effect.html#moviepy.Effect.Effect "moviepy.Effect.Effect")\ \]_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_effects) [#](#moviepy.Clip.Clip.with_effects "Permalink to this definition") Return a copy of the current clip with the effects applied \>>> new\_clip \= clip.with\_effects(\[vfx.Resize(0.2, method\="bilinear")\]) You can also pass multiple effect as a list \>>> clip.with\_effects(\[afx.VolumeX(0.5), vfx.Resize(0.3), vfx.Mirrorx()\]) with\_end(_t_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_end) [#](#moviepy.Clip.Clip.with_end "Permalink to this definition") Returns a copy of the clip, with the `end` attribute set to `t`, which can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. Also sets the duration of the mask and audio, if any, of the returned clip. note:: The start and end attribute of a clip define when a clip will start playing when used in a composite video clip, not the start time of the clip itself. i.e: with\_start(10) mean the clip will still start at his first frame, but if used in a composite video clip it will only start to show at 10 seconds. Parameters: **t** (_float_ _or_ _tuple_ _or_ _str_) – New `end` attribute value for the clip. with\_fps(_fps_, _change\_duration\=False_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_fps) [#](#moviepy.Clip.Clip.with_fps "Permalink to this definition") Returns a copy of the clip with a new default fps for functions like write\_videofile, iterframe, etc. Parameters: * **fps** (_int_) – New `fps` attribute value for the clip. * **change\_duration** (_bool__,_ _optional_) – If `change_duration=True`, then the video speed will change to match the new fps (conserving all frames 1:1). For example, if the fps is halved in this mode, the duration will be doubled. with\_is\_mask(_is\_mask_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_is_mask) [#](#moviepy.Clip.Clip.with_is_mask "Permalink to this definition") Says whether the clip is a mask or not. Parameters: **is\_mask** (_bool_) – New `is_mask` attribute value for the clip. with\_memoize(_memoize_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_memoize) [#](#moviepy.Clip.Clip.with_memoize "Permalink to this definition") Sets whether the clip should keep the last frame read in memory. Parameters: **memoize** (_bool_) – Indicates if the clip should keep the last frame read in memory. with\_section\_cut\_out(_start\_time_, _end\_time_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_section_cut_out) [#](#moviepy.Clip.Clip.with_section_cut_out "Permalink to this definition") Returns a clip playing the content of the current clip but skips the extract between `start_time` and `end_time`, which can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. If the original clip has a `duration` attribute set, the duration of the returned clip is automatically computed as \`\` duration - (end\_time - start\_time)\`\`. The resulting clip’s `audio` and `mask` will also be cutout if they exist. Parameters: * **start\_time** (_float_ _or_ _tuple_ _or_ _str_) – Moment from which frames will be ignored in the resulting output. * **end\_time** (_float_ _or_ _tuple_ _or_ _str_) – Moment until which frames will be ignored in the resulting output. with\_speed\_scaled(_factor: float \= None_, _final\_duration: float \= None_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_speed_scaled) [#](#moviepy.Clip.Clip.with_speed_scaled "Permalink to this definition") Returns a clip playing the current clip but at a speed multiplied by `factor`. For info on the parameters, please see `vfx.MultiplySpeed`. with\_start(_t_, _change\_end\=True_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_start) [#](#moviepy.Clip.Clip.with_start "Permalink to this definition") Returns a copy of the clip, with the `start` attribute set to `t`, which can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. These changes are also applied to the `audio` and `mask` clips of the current clip, if they exist. note:: The start and end attribute of a clip define when a clip will start playing when used in a composite video clip, not the start time of the clip itself. i.e: with\_start(10) mean the clip will still start at his first frame, but if used in a composite video clip it will only start to show at 10 seconds. Parameters: * **t** (_float_ _or_ _tuple_ _or_ _str_) – New `start` attribute value for the clip. * **change\_end** (_bool optional_) – Indicates if the `end` attribute value must be changed accordingly, if possible. If `change_end=True` and the clip has a `duration` attribute, the `end` attribute of the clip will be updated to `start + duration`. If `change_end=False` and the clip has a `end` attribute, the `duration` attribute of the clip will be updated to `end - start`. with\_updated\_frame\_function(_frame\_function_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_updated_frame_function) [#](#moviepy.Clip.Clip.with_updated_frame_function "Permalink to this definition") Sets a `frame_function` attribute for the clip. Useful for setting arbitrary/complicated videoclips. Parameters: **frame\_function** (_function_) – New frame creator function for the clip. with\_volume\_scaled(_factor: float_, _start\_time\=None_, _end\_time\=None_)[\[source\]](../../_modules/moviepy/Clip.html#Clip.with_volume_scaled) [#](#moviepy.Clip.Clip.with_volume_scaled "Permalink to this definition") Returns a new clip with audio volume multiplied by the value factor. For info on the parameters, please see `afx.MultiplyVolume` On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.Clip.Clip.rst) [Show Source](../../_sources/reference/reference/moviepy.Clip.Clip.rst.txt) --- # moviepy.Effect — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.Effect[#](#module-moviepy.Effect "Permalink to this heading") ====================================================================== Defines the base class for all effects in MoviePy. _class_ moviepy.Effect.Effect[\[source\]](../../_modules/moviepy/Effect.html#Effect) [#](#moviepy.Effect.Effect "Permalink to this definition") Base abstract class for all effects in MoviePy. Any new effect have to extend this base class. _abstract_ apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/Effect.html#Effect.apply) [#](#moviepy.Effect.Effect.apply "Permalink to this definition") Apply the current effect on a clip Parameters: **clip** – The target clip to apply the effect on. (Internally, MoviePy will always pass a copy of the original clip) copy()[\[source\]](../../_modules/moviepy/Effect.html#Effect.copy) [#](#moviepy.Effect.Effect.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.Effect.rst) [Show Source](../../_sources/reference/reference/moviepy.Effect.rst.txt) --- # moviepy.audio — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio[#](#module-moviepy.audio "Permalink to this heading") ==================================================================== Everything about audio manipulation. Modules | | | | --- | --- | | [`moviepy.audio.AudioClip`](moviepy.audio.AudioClip.html#module-moviepy.audio.AudioClip "moviepy.audio.AudioClip") | Implements AudioClip (base class for audio clips) and its main subclasses: | | [`moviepy.audio.fx`](moviepy.audio.fx.html#module-moviepy.audio.fx "moviepy.audio.fx") | All the audio effects that can be applied to AudioClip and VideoClip. | | [`moviepy.audio.io`](moviepy.audio.io.html#module-moviepy.audio.io "moviepy.audio.io") | Class and methods to read, write, preview audiofiles. | | [`moviepy.audio.tools`](moviepy.audio.tools.html#module-moviepy.audio.tools "moviepy.audio.tools") | Tools to better processing and edition of audio. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.rst.txt) --- # moviepy.audio.AudioClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.AudioClip[#](#module-moviepy.audio.AudioClip "Permalink to this heading") ======================================================================================== Implements AudioClip (base class for audio clips) and its main subclasses: * Audio clips: AudioClip, AudioFileClip, AudioArrayClip * Composition: CompositeAudioClip Classes | | | | --- | --- | | [`AudioArrayClip`](moviepy.audio.AudioClip.AudioArrayClip.html#moviepy.audio.AudioClip.AudioArrayClip "moviepy.audio.AudioClip.AudioArrayClip")
(array, fps) | An audio clip made from a sound array. | | [`AudioClip`](moviepy.audio.AudioClip.AudioClip.html#moviepy.audio.AudioClip.AudioClip "moviepy.audio.AudioClip.AudioClip")
(\[frame\_function, duration, fps\]) | Base class for audio clips. | | [`CompositeAudioClip`](moviepy.audio.AudioClip.CompositeAudioClip.html#moviepy.audio.AudioClip.CompositeAudioClip "moviepy.audio.AudioClip.CompositeAudioClip")
(clips) | Clip made by composing several AudioClips. | Functions | | | | --- | --- | | [`concatenate_audioclips`](moviepy.audio.AudioClip.concatenate_audioclips.html#moviepy.audio.AudioClip.concatenate_audioclips "moviepy.audio.AudioClip.concatenate_audioclips")
(clips) | Concatenates one AudioClip after another, in the order that are passed to `clips` parameter. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.AudioClip.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.AudioClip.rst.txt) --- # moviepy.audio.AudioClip.AudioArrayClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.AudioClip.AudioArrayClip[#](#moviepy-audio-audioclip-audioarrayclip "Permalink to this heading") =============================================================================================================== _class_ moviepy.audio.AudioClip.AudioArrayClip(_array_, _fps_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioArrayClip) [#](#moviepy.audio.AudioClip.AudioArrayClip "Permalink to this definition") An audio clip made from a sound array. Parameters: * **array** – A Numpy array representing the sound, of size Nx1 for mono, Nx2 for stereo. * **fps** – Frames per second : speed at which the sound is supposed to be played. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.AudioClip.AudioArrayClip.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.AudioClip.AudioArrayClip.rst.txt) --- # Unknown .. \_install: Installation ========================== Installation is done with \`\`pip\`\`. If you don't have \`\`pip\`\`, take a look at \`how to install it \`\_. With \`\`pip\`\` installed, just type this in a terminal: .. code:: bash $ (sudo) pip install moviepy .. \_install#binaries: Installation of additional binaries ------------------------------------ MoviePy depends on the software ffmpeg\_ for video reading and writing and on \`\`ffplay\`\` for video previewing. You don't need to worry about ffmpeg\_, as it should be automatically downloaded/installed by ImageIO during your first use of MoviePy (it takes a few seconds). You do need to worry about \`\`ffplay\`\` if you plan on using video/audio previewing. For these cases, make sure to have \`\`ffplay\`\` installed (it can usually be found alongside \`\`ffmpeg\`\`) and make sure it is accessible to Python, or define a custom path (see below). Define custom paths to binaries ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you want to use a specific version of FFmpeg and FFplay, you can do so using environment variables. There are a couple of environment variables used by MoviePy that allow you to configure custom paths to the external tools. To setup any of these variables, the easiest way is to do it in Python before importing objects from MoviePy. For example: .. code-block:: python import os os.environ\["FFMPEG\_BINARY"\] = "/path/to/custom/ffmpeg" os.environ\["FFPLAY\_BINARY"\] = "/path/to/custom/ffplay" Alternatively, after installing the optional dependencies, you can create a \`\`.env\`\` file in your working directory that will be automatically read. For example .. code-block:: ini FFMPEG\_BINARY=/path/to/custom/ffmpeg FFPLAY\_BINARY=/path/to/custom/ffplay Environment variables """"""""""""""""""""""" There are 2 available environment variables for external binaries : \`\`FFMPEG\_BINARY\`\` Normally you can leave it to its default ('ffmpeg-imageio') in which case imageio will download the right ffmpeg binary (on first use) and then always use that binary. The second option is \`\`"auto-detect"\`\`. In this case ffmpeg will be whatever binary is found on the computer: generally \`\`ffmpeg\`\` (on Linux/macOS) or \`\`ffmpeg.exe\`\` (on Windows). Lastly, you can set it to use a binary at a specific location on your disk by specifying the exact path. \`\`FFPLAY\_BINARY\`\` The default is \`\`"auto-detect"\`\`. MoviePy will try to find and use the installed \`\`ffplay\`\` binary. You can set it to use a binary at a specific location on your disk. On Windows, this might look like:: os.environ\["FFPLAY\_BINARY"\] = r"C:\\Program Files\\ffmpeg\\ffplay.exe" Verify if MoviePy find binaries """""""""""""""""""""""""""""""" To test if FFmpeg and FFplay are found by MoviePy, in a Python console, you can run : .. code-block:: python from moviepy.config import check check() .. \_ffmpeg: https://www.ffmpeg.org/download.html --- # moviepy.audio.AudioClip.AudioClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.AudioClip.AudioClip[#](#moviepy-audio-audioclip-audioclip "Permalink to this heading") ===================================================================================================== _class_ moviepy.audio.AudioClip.AudioClip(_frame\_function\=None_, _duration\=None_, _fps\=None_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioClip) [#](#moviepy.audio.AudioClip.AudioClip "Permalink to this definition") Base class for audio clips. See `AudioFileClip` and `CompositeAudioClip` for usable classes. An AudioClip is a Clip with a `frame_function` attribute of the form \`\` t -> \[ f\_t \]\`\` for mono sound and `t-> [ f1_t, f2_t ]` for stereo sound (the arrays are Numpy arrays). The f\_t are floats between -1 and 1. These bounds can be trespassed without problems (the program will put the sound back into the bounds at conversion time, without much impact). Parameters: * **frame\_function** – A function t-> frame at time t. The frame does not mean much for a sound, it is just a float. What ‘makes’ the sound are the variations of that float in the time. * **duration** – Duration of the clip (in seconds). Some clips are infinite, in this case their duration will be `None`. * **nchannels** – Number of channels (one or two for mono or stereo). Examples \# Plays the note A in mono (a sine wave of frequency 440 Hz) import numpy as np frame\_function \= lambda t: np.sin(440 \* 2 \* np.pi \* t) clip \= AudioClip(frame\_function, duration\=5, fps\=44100) clip.preview() \# Plays the note A in stereo (two sine waves of frequencies 440 and 880 Hz) frame\_function \= lambda t: np.array(\[\ np.sin(440 \* 2 \* np.pi \* t),\ np.sin(880 \* 2 \* np.pi \* t)\ \]).T.copy(order\="C") clip \= AudioClip(frame\_function, duration\=3, fps\=44100) clip.preview() audiopreview(_fps\=None_, _buffersize\=2000_, _nbytes\=2_, _audio\_flag\=None_, _video\_flag\=None_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioClip.audiopreview) [#](#moviepy.audio.AudioClip.AudioClip.audiopreview "Permalink to this definition") Preview an AudioClip using ffplay Parameters: * **fps** – Frame rate of the sound. 44100 gives top quality, but may cause problems if your computer is not fast enough and your clip is complicated. If the sound jumps during the preview, lower it (11025 is still fine, 5000 is tolerable). * **buffersize** – The sound is not generated all at once, but rather made by bunches of frames (chunks). `buffersize` is the size of such a chunk. Try varying it if you meet audio problems (but you shouldn’t have to). * **nbytes** – Number of bytes to encode the sound: 1 for 8bit sound, 2 for 16bit, 4 for 32bit sound. 2 bytes is fine. * **audio\_flag** – Instances of class threading events that are used to synchronize video and audio during `VideoClip.preview()`. * **video\_flag** – Instances of class threading events that are used to synchronize video and audio during `VideoClip.preview()`. display\_in\_notebook(_filetype\=None_, _maxduration\=60_, _t\=None_, _fps\=None_, _rd\_kwargs\=None_, _center\=True_, _\*\*html\_kwargs_)[#](#moviepy.audio.AudioClip.AudioClip.display_in_notebook "Permalink to this definition") Displays clip content in an Jupyter Notebook. Remarks: If your browser doesn’t support HTML5, this should warn you. If nothing is displayed, maybe your file or filename is wrong. Important: The media will be physically embedded in the notebook. Parameters: * **clip** ([_moviepy.Clip.Clip_](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") ) – Either the name of a file, or a clip to preview. The clip will actually be written to a file and embedded as if a filename was provided. * **filetype** (_str__,_ _optional_) – One of `"video"`, `"image"` or `"audio"`. If None is given, it is determined based on the extension of `filename`, but this can bug. * **maxduration** (_float__,_ _optional_) – An error will be raised if the clip’s duration is more than the indicated value (in seconds), to avoid spoiling the browser’s cache and the RAM. * **t** (_float__,_ _optional_) – If not None, only the frame at time t will be displayed in the notebook, instead of a video of the clip. * **fps** (_int__,_ _optional_) – Enables to specify an fps, as required for clips whose fps is unknown. * **rd\_kwargs** (_dict__,_ _optional_) – Keyword arguments for the rendering, like `dict(fps=15, bitrate="50k")`. Allow you to give some options to the render process. You can, for example, disable the logger bar passing `dict(logger=None)`. * **center** (_bool__,_ _optional_) – If true (default), the content will be wrapped in a `
` HTML container, so the content will be displayed at the center. * **kwargs** – Allow you to give some options, like `width=260`, etc. When editing looping gifs, a good choice is `loop=1, autoplay=1`. Examples from moviepy import \* \# later ... clip.display\_in\_notebook(width\=360) clip.audio.display\_in\_notebook() clip.write\_gif("test.gif") display\_in\_notebook('test.gif') clip.save\_frame("first\_frame.jpeg") display\_in\_notebook("first\_frame.jpeg") iter\_chunks(_chunksize\=None_, _chunk\_duration\=None_, _fps\=None_, _quantize\=False_, _nbytes\=2_, _logger\=None_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioClip.iter_chunks) [#](#moviepy.audio.AudioClip.AudioClip.iter_chunks "Permalink to this definition") Iterator that returns the whole sound array of the clip by chunks max\_volume(_stereo\=False_, _chunksize\=50000_, _logger\=None_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioClip.max_volume) [#](#moviepy.audio.AudioClip.AudioClip.max_volume "Permalink to this definition") Returns the maximum volume level of the clip. to\_soundarray(_tt\=None_, _fps\=None_, _quantize\=False_, _nbytes\=2_, _buffersize\=50000_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioClip.to_soundarray) [#](#moviepy.audio.AudioClip.AudioClip.to_soundarray "Permalink to this definition") Transforms the sound into an array that can be played by pygame or written in a wav file. See `AudioClip.preview`. Parameters: * **fps** – Frame rate of the sound for the conversion. 44100 for top quality. * **nbytes** – Number of bytes to encode the sound: 1 for 8bit sound, 2 for 16bit, 4 for 32bit sound. write\_audiofile(_filename_, _fps\=None_, _nbytes\=2_, _buffersize\=2000_, _codec\=None_, _bitrate\=None_, _ffmpeg\_params\=None_, _write\_logfile\=False_, _logger\='bar'_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#AudioClip.write_audiofile) [#](#moviepy.audio.AudioClip.AudioClip.write_audiofile "Permalink to this definition") Writes an audio file from the AudioClip. Parameters: * **filename** – Name of the output file, as a string or a path-like object. * **fps** – Frames per second. If not set, it will try default to self.fps if already set, otherwise it will default to 44100. * **nbytes** – Sample width (set to 2 for 16-bit sound, 4 for 32-bit sound) * **buffersize** – The sound is not generated all at once, but rather made by bunches of frames (chunks). `buffersize` is the size of such a chunk. Try varying it if you meet audio problems (but you shouldn’t have to). Default to 2000 * **codec** – Which audio codec should be used. If None provided, the codec is determined based on the extension of the filename. Choose ‘pcm\_s16le’ for 16-bit wav and ‘pcm\_s32le’ for 32-bit wav. * **bitrate** – Audio bitrate, given as a string like ‘50k’, ‘500k’, ‘3000k’. Will determine the size and quality of the output file. Note that it mainly an indicative goal, the bitrate won’t necessarily be the this in the output file. * **ffmpeg\_params** – Any additional parameters you would like to pass, as a list of terms, like \[‘-option1’, ‘value1’, ‘-option2’, ‘value2’\] * **write\_logfile** – If true, produces a detailed logfile named filename + ‘.log’ when writing the file * **logger** – Either `"bar"` for progress bar or `None` or any Proglog logger. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.AudioClip.AudioClip.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.AudioClip.AudioClip.rst.txt) --- # moviepy.audio.AudioClip.concatenate_audioclips — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.AudioClip.concatenate\_audioclips[#](#moviepy-audio-audioclip-concatenate-audioclips "Permalink to this heading") ================================================================================================================================ moviepy.audio.AudioClip.concatenate\_audioclips(_clips_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#concatenate_audioclips) [#](#moviepy.audio.AudioClip.concatenate_audioclips "Permalink to this definition") Concatenates one AudioClip after another, in the order that are passed to `clips` parameter. Parameters: **clips** – List of audio clips, which will be played one after other. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.AudioClip.concatenate_audioclips.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.AudioClip.concatenate_audioclips.rst.txt) --- # moviepy.audio.AudioClip.CompositeAudioClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.AudioClip.CompositeAudioClip[#](#moviepy-audio-audioclip-compositeaudioclip "Permalink to this heading") ======================================================================================================================= _class_ moviepy.audio.AudioClip.CompositeAudioClip(_clips_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#CompositeAudioClip) [#](#moviepy.audio.AudioClip.CompositeAudioClip "Permalink to this definition") Clip made by composing several AudioClips. An audio clip made by putting together several audio clips. Parameters: **clips** – List of audio clips, which may start playing at different times or together, depends on their `start` attributes. If all have their `duration` attribute set, the duration of the composite clip is computed automatically. _property_ ends[#](#moviepy.audio.AudioClip.CompositeAudioClip.ends "Permalink to this definition") Returns ending times for all clips in the composition. frame\_function(_t_)[\[source\]](../../_modules/moviepy/audio/AudioClip.html#CompositeAudioClip.frame_function) [#](#moviepy.audio.AudioClip.CompositeAudioClip.frame_function "Permalink to this definition") Renders a frame for the composition for the time `t`. _property_ starts[#](#moviepy.audio.AudioClip.CompositeAudioClip.starts "Permalink to this definition") Returns starting times for all clips in the composition. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.AudioClip.CompositeAudioClip.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.AudioClip.CompositeAudioClip.rst.txt) --- # moviepy.audio.fx.AudioDelay — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.AudioDelay[#](#module-moviepy.audio.fx.AudioDelay "Permalink to this heading") ================================================================================================ _class_ moviepy.audio.fx.AudioDelay.AudioDelay(_offset: float \= 0.2_, _n\_repeats: int \= 8_, _decay: float \= 1_)[\[source\]](../../_modules/moviepy/audio/fx/AudioDelay.html#AudioDelay) [#](#moviepy.audio.fx.AudioDelay.AudioDelay "Permalink to this definition") Repeats audio certain number of times at constant intervals multiplying their volume levels using a linear space in the range 1 to `decay` argument value. Parameters: * **offset** (_float__,_ _optional_) – Gap between repetitions start times, in seconds. * **n\_repeats** (_int__,_ _optional_) – Number of repetitions (without including the clip itself). * **decay** (_float__,_ _optional_) – Multiplication factor for the volume level of the last repetition. Each repetition will have a value in the linear function between 1 and this value, increasing or decreasing constantly. Keep in mind that the last repetition will be muted if this is 0, and if is greater than 1, the volume will increase for each repetition. Examples from moviepy import \* videoclip \= AudioFileClip('myaudio.wav').with\_effects(\[\ afx.AudioDelay(offset\=.2, n\_repeats\=10, decayment\=.2)\ \]) \# stereo A note frame\_function \= lambda t: np.array( \[np.sin(440 \* 2 \* np.pi \* t), np.sin(880 \* 2 \* np.pi \* t)\] ).T clip \= AudioClip(frame\_function\=frame\_function, duration\=0.1, fps\=44100) clip \= clip.with\_effects(\[afx.AudioDelay(offset\=.2, n\_repeats\=11, decay\=0)\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/AudioDelay.html#AudioDelay.apply) [#](#moviepy.audio.fx.AudioDelay.AudioDelay.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.AudioDelay.AudioDelay.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.AudioDelay.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.AudioDelay.rst.txt) --- # moviepy.audio.fx — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx[#](#module-moviepy.audio.fx "Permalink to this heading") ========================================================================== All the audio effects that can be applied to AudioClip and VideoClip. Modules | | | | --- | --- | | [`moviepy.audio.fx.AudioDelay`](moviepy.audio.fx.AudioDelay.html#module-moviepy.audio.fx.AudioDelay "moviepy.audio.fx.AudioDelay")
(\[offset, ...\]) | Repeats audio certain number of times at constant intervals multiplying their volume levels using a linear space in the range 1 to `decay` argument value. | | [`moviepy.audio.fx.AudioFadeIn`](moviepy.audio.fx.AudioFadeIn.html#module-moviepy.audio.fx.AudioFadeIn "moviepy.audio.fx.AudioFadeIn")
(duration) | Return an audio (or video) clip that is first mute, then the sound arrives progressively over `duration` seconds. | | [`moviepy.audio.fx.AudioFadeOut`](moviepy.audio.fx.AudioFadeOut.html#module-moviepy.audio.fx.AudioFadeOut "moviepy.audio.fx.AudioFadeOut")
(duration) | Return a sound clip where the sound fades out progressively over `duration` seconds at the end of the clip. | | [`moviepy.audio.fx.AudioLoop`](moviepy.audio.fx.AudioLoop.html#module-moviepy.audio.fx.AudioLoop "moviepy.audio.fx.AudioLoop")
(\[n\_loops, duration\]) | Loops over an audio clip. | | [`moviepy.audio.fx.AudioNormalize`](moviepy.audio.fx.AudioNormalize.html#module-moviepy.audio.fx.AudioNormalize "moviepy.audio.fx.AudioNormalize")
() | Return a clip whose volume is normalized to 0db. | | [`moviepy.audio.fx.MultiplyStereoVolume`](moviepy.audio.fx.MultiplyStereoVolume.html#module-moviepy.audio.fx.MultiplyStereoVolume "moviepy.audio.fx.MultiplyStereoVolume")
(\[...\]) | For a stereo audioclip, this function enables to change the volume of the left and right channel separately (with the factors left and right). | | [`moviepy.audio.fx.MultiplyVolume`](moviepy.audio.fx.MultiplyVolume.html#module-moviepy.audio.fx.MultiplyVolume "moviepy.audio.fx.MultiplyVolume")
(factor\[, ...\]) | Returns a clip with audio volume multiplied by the value factor. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.rst.txt) --- # moviepy.audio.fx.AudioFadeOut — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.AudioFadeOut[#](#module-moviepy.audio.fx.AudioFadeOut "Permalink to this heading") ==================================================================================================== _class_ moviepy.audio.fx.AudioFadeOut.AudioFadeOut(_duration: float_)[\[source\]](../../_modules/moviepy/audio/fx/AudioFadeOut.html#AudioFadeOut) [#](#moviepy.audio.fx.AudioFadeOut.AudioFadeOut "Permalink to this definition") Return a sound clip where the sound fades out progressively over `duration` seconds at the end of the clip. Parameters: **duration** (_float_) – How long does it take for the sound to reach the zero level at the end of the clip. Examples clip \= VideoFileClip("media/chaplin.mp4") clip.with\_effects(\[afx.AudioFadeOut("00:00:06")\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/AudioFadeOut.html#AudioFadeOut.apply) [#](#moviepy.audio.fx.AudioFadeOut.AudioFadeOut.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.AudioFadeOut.AudioFadeOut.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.AudioFadeOut.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.AudioFadeOut.rst.txt) --- # moviepy.audio.fx.AudioFadeIn — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.AudioFadeIn[#](#module-moviepy.audio.fx.AudioFadeIn "Permalink to this heading") ================================================================================================== _class_ moviepy.audio.fx.AudioFadeIn.AudioFadeIn(_duration: float_)[\[source\]](../../_modules/moviepy/audio/fx/AudioFadeIn.html#AudioFadeIn) [#](#moviepy.audio.fx.AudioFadeIn.AudioFadeIn "Permalink to this definition") Return an audio (or video) clip that is first mute, then the sound arrives progressively over `duration` seconds. Parameters: **duration** (_float_) – How long does it take for the sound to return to its normal level. Examples clip \= VideoFileClip("media/chaplin.mp4") clip.with\_effects(\[afx.AudioFadeIn("00:00:06")\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/AudioFadeIn.html#AudioFadeIn.apply) [#](#moviepy.audio.fx.AudioFadeIn.AudioFadeIn.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.AudioFadeIn.AudioFadeIn.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.AudioFadeIn.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.AudioFadeIn.rst.txt) --- # moviepy.audio.fx.AudioLoop — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.AudioLoop[#](#module-moviepy.audio.fx.AudioLoop "Permalink to this heading") ============================================================================================== _class_ moviepy.audio.fx.AudioLoop.AudioLoop(_n\_loops: int \= None_, _duration: float \= None_)[\[source\]](../../_modules/moviepy/audio/fx/AudioLoop.html#AudioLoop) [#](#moviepy.audio.fx.AudioLoop.AudioLoop "Permalink to this definition") Loops over an audio clip. Returns an audio clip that plays the given clip either n\_loops times, or during duration seconds. Examples from moviepy import \* videoclip \= VideoFileClip('myvideo.mp4') music \= AudioFileClip('music.ogg') audio \= music.with\_effects(\[afx.AudioLoop(duration\=videoclip.duration)\]) videoclip.with\_audio(audio) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/AudioLoop.html#AudioLoop.apply) [#](#moviepy.audio.fx.AudioLoop.AudioLoop.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.AudioLoop.AudioLoop.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.AudioLoop.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.AudioLoop.rst.txt) --- # moviepy.audio.fx.AudioNormalize — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.AudioNormalize[#](#module-moviepy.audio.fx.AudioNormalize "Permalink to this heading") ======================================================================================================== _class_ moviepy.audio.fx.AudioNormalize.AudioNormalize[\[source\]](../../_modules/moviepy/audio/fx/AudioNormalize.html#AudioNormalize) [#](#moviepy.audio.fx.AudioNormalize.AudioNormalize "Permalink to this definition") Return a clip whose volume is normalized to 0db. Return an audio (or video) clip whose audio volume is normalized so that the maximum volume is at 0db, the maximum achievable volume. Examples \>>> from moviepy import \* \>>> videoclip \= VideoFileClip('myvideo.mp4').with\_effects(\[afx.AudioNormalize()\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/AudioNormalize.html#AudioNormalize.apply) [#](#moviepy.audio.fx.AudioNormalize.AudioNormalize.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.AudioNormalize.AudioNormalize.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.AudioNormalize.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.AudioNormalize.rst.txt) --- # moviepy.audio.fx.MultiplyStereoVolume — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.MultiplyStereoVolume[#](#module-moviepy.audio.fx.MultiplyStereoVolume "Permalink to this heading") ==================================================================================================================== _class_ moviepy.audio.fx.MultiplyStereoVolume.MultiplyStereoVolume(_left: float \= 1_, _right: float \= 1_)[\[source\]](../../_modules/moviepy/audio/fx/MultiplyStereoVolume.html#MultiplyStereoVolume) [#](#moviepy.audio.fx.MultiplyStereoVolume.MultiplyStereoVolume "Permalink to this definition") For a stereo audioclip, this function enables to change the volume of the left and right channel separately (with the factors left and right). Makes a stereo audio clip in which the volume of left and right is controllable. Examples from moviepy import AudioFileClip music \= AudioFileClip('music.ogg') \# mutes left channel audio\_r \= music.with\_effects(\[afx.MultiplyStereoVolume(left\=0, right\=1)\]) \# halves audio volume audio\_h \= music.with\_effects(\[afx.MultiplyStereoVolume(left\=0.5, right\=0.5)\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/MultiplyStereoVolume.html#MultiplyStereoVolume.apply) [#](#moviepy.audio.fx.MultiplyStereoVolume.MultiplyStereoVolume.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.MultiplyStereoVolume.MultiplyStereoVolume.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.MultiplyStereoVolume.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.MultiplyStereoVolume.rst.txt) --- # moviepy.audio.fx.MultiplyVolume — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.fx.MultiplyVolume[#](#module-moviepy.audio.fx.MultiplyVolume "Permalink to this heading") ======================================================================================================== _class_ moviepy.audio.fx.MultiplyVolume.MultiplyVolume(_factor: float_, _start\_time: float \= None_, _end\_time: float \= None_)[\[source\]](../../_modules/moviepy/audio/fx/MultiplyVolume.html#MultiplyVolume) [#](#moviepy.audio.fx.MultiplyVolume.MultiplyVolume "Permalink to this definition") Returns a clip with audio volume multiplied by the value factor. Can be applied to both audio and video clips. Parameters: * **factor** (_float_) – Volume multiplication factor. * **start\_time** (_float__,_ _optional_) – Time from the beginning of the clip until the volume transformation begins to take effect, in seconds. By default at the beginning. * **end\_time** (_float__,_ _optional_) – Time from the beginning of the clip until the volume transformation ends to take effect, in seconds. By default at the end. Examples from moviepy import AudioFileClip music \= AudioFileClip("music.ogg") \# doubles audio volume doubled\_audio\_clip \= music.with\_effects(\[afx.MultiplyVolume(2)\]) \# halves audio volume half\_audio\_clip \= music.with\_effects(\[afx.MultiplyVolume(0.5)\]) \# silences clip during one second at third effect \= afx.MultiplyVolume(0, start\_time\=2, end\_time\=3) silenced\_clip \= clip.with\_effects(\[effect\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/audio/fx/MultiplyVolume.html#MultiplyVolume.apply) [#](#moviepy.audio.fx.MultiplyVolume.MultiplyVolume.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.audio.fx.MultiplyVolume.MultiplyVolume.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.fx.MultiplyVolume.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.fx.MultiplyVolume.rst.txt) --- # moviepy.audio.io — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io[#](#module-moviepy.audio.io "Permalink to this heading") ========================================================================== Class and methods to read, write, preview audiofiles. Modules | | | | --- | --- | | [`moviepy.audio.io.AudioFileClip`](moviepy.audio.io.AudioFileClip.html#module-moviepy.audio.io.AudioFileClip "moviepy.audio.io.AudioFileClip") | Implements AudioFileClip, a class for audio clips creation using audio files. | | [`moviepy.audio.io.ffmpeg_audiowriter`](moviepy.audio.io.ffmpeg_audiowriter.html#module-moviepy.audio.io.ffmpeg_audiowriter "moviepy.audio.io.ffmpeg_audiowriter") | MoviePy audio writing with ffmpeg. | | [`moviepy.audio.io.ffplay_audiopreviewer`](moviepy.audio.io.ffplay_audiopreviewer.html#module-moviepy.audio.io.ffplay_audiopreviewer "moviepy.audio.io.ffplay_audiopreviewer") | MoviePy audio writing with ffmpeg. | | [`moviepy.audio.io.readers`](moviepy.audio.io.readers.html#module-moviepy.audio.io.readers "moviepy.audio.io.readers") | MoviePy audio reading with ffmpeg. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.rst.txt) --- # moviepy.audio.io.AudioFileClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.AudioFileClip[#](#module-moviepy.audio.io.AudioFileClip "Permalink to this heading") ====================================================================================================== Implements AudioFileClip, a class for audio clips creation using audio files. Classes | | | | --- | --- | | [`AudioFileClip`](moviepy.audio.io.AudioFileClip.AudioFileClip.html#moviepy.audio.io.AudioFileClip.AudioFileClip "moviepy.audio.io.AudioFileClip.AudioFileClip")
(filename\[, decode\_file, ...\]) | An audio clip read from a sound file, or an array. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.AudioFileClip.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.AudioFileClip.rst.txt) --- # moviepy.audio.io.ffmpeg_audiowriter — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.ffmpeg\_audiowriter[#](#module-moviepy.audio.io.ffmpeg_audiowriter "Permalink to this heading") ================================================================================================================= MoviePy audio writing with ffmpeg. Classes | | | | --- | --- | | [`FFMPEG_AudioWriter`](moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter.html#moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter "moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter")
(filename, fps\_input\[, ...\]) | A class to write an AudioClip into an audio file. | Functions | | | | --- | --- | | [`ffmpeg_audiowrite`](moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite.html#moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite "moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite")
(clip, filename, fps, ...) | A function that wraps the FFMPEG\_AudioWriter to write an AudioClip to a file. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.ffmpeg_audiowriter.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.ffmpeg_audiowriter.rst.txt) --- # moviepy.audio.io.ffplay_audiopreviewer — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.ffplay\_audiopreviewer[#](#module-moviepy.audio.io.ffplay_audiopreviewer "Permalink to this heading") ======================================================================================================================= MoviePy audio writing with ffmpeg. Classes | | | | --- | --- | | [`FFPLAY_AudioPreviewer`](moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer.html#moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer "moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer")
(fps\_input\[, nbytes, ...\]) | A class to preview an AudioClip. | Functions | | | | --- | --- | | [`ffplay_audiopreview`](moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview.html#moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview "moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview")
(clip\[, fps, buffersize, ...\]) | A function that wraps the FFPLAY\_AudioPreviewer to preview an AudioClip | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.ffplay_audiopreviewer.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.ffplay_audiopreviewer.rst.txt) --- # moviepy.audio.io.readers — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.readers[#](#module-moviepy.audio.io.readers "Permalink to this heading") ========================================================================================== MoviePy audio reading with ffmpeg. Classes | | | | --- | --- | | [`FFMPEG_AudioReader`](moviepy.audio.io.readers.FFMPEG_AudioReader.html#moviepy.audio.io.readers.FFMPEG_AudioReader "moviepy.audio.io.readers.FFMPEG_AudioReader")
(filename, buffersize\[, ...\]) | A class to read the audio in either video files or audio files using ffmpeg. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.readers.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.readers.rst.txt) --- # moviepy.audio.tools.cuts — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.tools.cuts[#](#module-moviepy.audio.tools.cuts "Permalink to this heading") ========================================================================================== Cutting utilities working with audio. Functions | | | | --- | --- | | [`find_audio_period`](moviepy.audio.tools.cuts.find_audio_period.html#moviepy.audio.tools.cuts.find_audio_period "moviepy.audio.tools.cuts.find_audio_period")
(clip\[, min\_time, ...\]) | Finds the period, in seconds of an audioclip. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.tools.cuts.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.tools.cuts.rst.txt) --- # moviepy.audio.tools — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.tools[#](#module-moviepy.audio.tools "Permalink to this heading") ================================================================================ Tools to better processing and edition of audio. Modules | | | | --- | --- | | [`moviepy.audio.tools.cuts`](moviepy.audio.tools.cuts.html#module-moviepy.audio.tools.cuts "moviepy.audio.tools.cuts") | Cutting utilities working with audio. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.tools.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.tools.rst.txt) --- # moviepy.config — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.config[#](#module-moviepy.config "Permalink to this heading") ====================================================================== Third party programs configuration for MoviePy. Functions | | | | --- | --- | | [`check`](moviepy.config.check.html#moviepy.config.check "moviepy.config.check")
() | Check if moviepy has found the binaries for FFmpeg. | | [`try_cmd`](moviepy.config.try_cmd.html#moviepy.config.try_cmd "moviepy.config.try_cmd")
(cmd) | Verify if the OS support command invocation as expected by moviepy | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.config.rst) [Show Source](../../_sources/reference/reference/moviepy.config.rst.txt) --- # moviepy.config.check — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.config.check[#](#moviepy-config-check "Permalink to this heading") =========================================================================== moviepy.config.check()[\[source\]](../../_modules/moviepy/config.html#check) [#](#moviepy.config.check "Permalink to this definition") Check if moviepy has found the binaries for FFmpeg. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.config.check.rst) [Show Source](../../_sources/reference/reference/moviepy.config.check.rst.txt) --- # moviepy.config.try_cmd — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.config.try\_cmd[#](#moviepy-config-try-cmd "Permalink to this heading") ================================================================================ moviepy.config.try\_cmd(_cmd_)[\[source\]](../../_modules/moviepy/config.html#try_cmd) [#](#moviepy.config.try_cmd "Permalink to this definition") Verify if the OS support command invocation as expected by moviepy On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.config.try_cmd.rst) [Show Source](../../_sources/reference/reference/moviepy.config.try_cmd.rst.txt) --- # moviepy.decorators — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators[#](#module-moviepy.decorators "Permalink to this heading") ============================================================================== Decorators used by moviepy. Functions | | | | --- | --- | | [`add_mask_if_none`](moviepy.decorators.add_mask_if_none.html#moviepy.decorators.add_mask_if_none "moviepy.decorators.add_mask_if_none")
(func, clip, \*args, \*\*kwargs) | Add a mask to the clip if there is none. | | [`apply_to_audio`](moviepy.decorators.apply_to_audio.html#moviepy.decorators.apply_to_audio "moviepy.decorators.apply_to_audio")
(func, clip, \*args, \*\*kwargs) | Applies the function `func` to the audio of the clip created with `func`. | | [`apply_to_mask`](moviepy.decorators.apply_to_mask.html#moviepy.decorators.apply_to_mask "moviepy.decorators.apply_to_mask")
(func, clip, \*args, \*\*kwargs) | Applies the same function `func` to the mask of the clip created with `func`. | | [`audio_video_effect`](moviepy.decorators.audio_video_effect.html#moviepy.decorators.audio_video_effect "moviepy.decorators.audio_video_effect")
(func, effect, clip, ...) | Use an audio function on a video/audio clip. | | [`convert_masks_to_RGB`](moviepy.decorators.convert_masks_to_RGB.html#moviepy.decorators.convert_masks_to_RGB "moviepy.decorators.convert_masks_to_RGB")
(func, clip, \*args, \*\*kwargs) | If the clip is a mask, convert it to RGB before running the function. | | [`convert_parameter_to_seconds`](moviepy.decorators.convert_parameter_to_seconds.html#moviepy.decorators.convert_parameter_to_seconds "moviepy.decorators.convert_parameter_to_seconds")
(varnames) | Converts the specified variables to seconds. | | [`convert_path_to_string`](moviepy.decorators.convert_path_to_string.html#moviepy.decorators.convert_path_to_string "moviepy.decorators.convert_path_to_string")
(varnames) | Converts the specified variables to a path string. | | [`outplace`](moviepy.decorators.outplace.html#moviepy.decorators.outplace "moviepy.decorators.outplace")
(func, clip, \*args, \*\*kwargs) | Applies `func(clip.copy(), *args, **kwargs)` and returns `clip.copy()`. | | [`preprocess_args`](moviepy.decorators.preprocess_args.html#moviepy.decorators.preprocess_args "moviepy.decorators.preprocess_args")
(preprocess\_func, varnames) | Applies preprocess\_func to variables in varnames before launching the function. | | [`requires_duration`](moviepy.decorators.requires_duration.html#moviepy.decorators.requires_duration "moviepy.decorators.requires_duration")
(func, clip, \*args, \*\*kwargs) | Raises an error if the clip has no duration. | | [`requires_fps`](moviepy.decorators.requires_fps.html#moviepy.decorators.requires_fps "moviepy.decorators.requires_fps")
(func, clip, \*args, \*\*kwargs) | Raises an error if the clip has no fps. | | [`use_clip_fps_by_default`](moviepy.decorators.use_clip_fps_by_default.html#moviepy.decorators.use_clip_fps_by_default "moviepy.decorators.use_clip_fps_by_default")
(func) | Will use `clip.fps` if no `fps=...` is provided in **kwargs**. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.rst.txt) --- # moviepy.decorators.add_mask_if_none — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.add\_mask\_if\_none[#](#moviepy-decorators-add-mask-if-none "Permalink to this heading") ============================================================================================================ moviepy.decorators.add\_mask\_if\_none(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#add_mask_if_none) [#](#moviepy.decorators.add_mask_if_none "Permalink to this definition") Add a mask to the clip if there is none. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.add_mask_if_none.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.add_mask_if_none.rst.txt) --- # moviepy.decorators.apply_to_audio — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.apply\_to\_audio[#](#moviepy-decorators-apply-to-audio "Permalink to this heading") ======================================================================================================= moviepy.decorators.apply\_to\_audio(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#apply_to_audio) [#](#moviepy.decorators.apply_to_audio "Permalink to this definition") Applies the function `func` to the audio of the clip created with `func`. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.apply_to_audio.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.apply_to_audio.rst.txt) --- # moviepy.decorators.apply_to_mask — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.apply\_to\_mask[#](#moviepy-decorators-apply-to-mask "Permalink to this heading") ===================================================================================================== moviepy.decorators.apply\_to\_mask(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#apply_to_mask) [#](#moviepy.decorators.apply_to_mask "Permalink to this definition") Applies the same function `func` to the mask of the clip created with `func`. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.apply_to_mask.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.apply_to_mask.rst.txt) --- # moviepy.decorators.audio_video_effect — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.audio\_video\_effect[#](#moviepy-decorators-audio-video-effect "Permalink to this heading") =============================================================================================================== moviepy.decorators.audio\_video\_effect(_func_, _effect_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#audio_video_effect) [#](#moviepy.decorators.audio_video_effect "Permalink to this definition") Use an audio function on a video/audio clip. This decorator tells that the function func (audioclip -> audioclip) can be also used on a video clip, at which case it returns a videoclip with unmodified video and modified audio. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.audio_video_effect.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.audio_video_effect.rst.txt) --- # moviepy.decorators.convert_parameter_to_seconds — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.convert\_parameter\_to\_seconds[#](#moviepy-decorators-convert-parameter-to-seconds "Permalink to this heading") ==================================================================================================================================== moviepy.decorators.convert\_parameter\_to\_seconds(_varnames_)[\[source\]](../../_modules/moviepy/decorators.html#convert_parameter_to_seconds) [#](#moviepy.decorators.convert_parameter_to_seconds "Permalink to this definition") Converts the specified variables to seconds. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.convert_parameter_to_seconds.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.convert_parameter_to_seconds.rst.txt) --- # moviepy.decorators.convert_masks_to_RGB — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.convert\_masks\_to\_RGB[#](#moviepy-decorators-convert-masks-to-rgb "Permalink to this heading") ==================================================================================================================== moviepy.decorators.convert\_masks\_to\_RGB(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#convert_masks_to_RGB) [#](#moviepy.decorators.convert_masks_to_RGB "Permalink to this definition") If the clip is a mask, convert it to RGB before running the function. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.convert_masks_to_RGB.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.convert_masks_to_RGB.rst.txt) --- # moviepy.decorators.outplace — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.outplace[#](#moviepy-decorators-outplace "Permalink to this heading") ========================================================================================= moviepy.decorators.outplace(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#outplace) [#](#moviepy.decorators.outplace "Permalink to this definition") Applies `func(clip.copy(), *args, **kwargs)` and returns `clip.copy()`. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.outplace.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.outplace.rst.txt) --- # moviepy.decorators.convert_path_to_string — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.convert\_path\_to\_string[#](#moviepy-decorators-convert-path-to-string "Permalink to this heading") ======================================================================================================================== moviepy.decorators.convert\_path\_to\_string(_varnames_)[\[source\]](../../_modules/moviepy/decorators.html#convert_path_to_string) [#](#moviepy.decorators.convert_path_to_string "Permalink to this definition") Converts the specified variables to a path string. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.convert_path_to_string.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.convert_path_to_string.rst.txt) --- # moviepy.decorators.preprocess_args — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.preprocess\_args[#](#moviepy-decorators-preprocess-args "Permalink to this heading") ======================================================================================================== moviepy.decorators.preprocess\_args(_preprocess\_func_, _varnames_)[\[source\]](../../_modules/moviepy/decorators.html#preprocess_args) [#](#moviepy.decorators.preprocess_args "Permalink to this definition") Applies preprocess\_func to variables in varnames before launching the function. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.preprocess_args.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.preprocess_args.rst.txt) --- # moviepy.decorators.requires_fps — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.requires\_fps[#](#moviepy-decorators-requires-fps "Permalink to this heading") ================================================================================================== moviepy.decorators.requires\_fps(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#requires_fps) [#](#moviepy.decorators.requires_fps "Permalink to this definition") Raises an error if the clip has no fps. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.requires_fps.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.requires_fps.rst.txt) --- # moviepy.decorators.requires_duration — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.requires\_duration[#](#moviepy-decorators-requires-duration "Permalink to this heading") ============================================================================================================ moviepy.decorators.requires\_duration(_func_, _clip_, _\*args_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/decorators.html#requires_duration) [#](#moviepy.decorators.requires_duration "Permalink to this definition") Raises an error if the clip has no duration. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.requires_duration.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.requires_duration.rst.txt) --- # moviepy.decorators.use_clip_fps_by_default — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.decorators.use\_clip\_fps\_by\_default[#](#moviepy-decorators-use-clip-fps-by-default "Permalink to this heading") =========================================================================================================================== moviepy.decorators.use\_clip\_fps\_by\_default(_func_)[\[source\]](../../_modules/moviepy/decorators.html#use_clip_fps_by_default) [#](#moviepy.decorators.use_clip_fps_by_default "Permalink to this definition") Will use `clip.fps` if no `fps=...` is provided in **kwargs**. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.decorators.use_clip_fps_by_default.rst) [Show Source](../../_sources/reference/reference/moviepy.decorators.use_clip_fps_by_default.rst.txt) --- # moviepy.tools — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools[#](#module-moviepy.tools "Permalink to this heading") ==================================================================== Misc. useful functions that can be used at many places in the program. Functions | | | | --- | --- | | [`close_all_clips`](moviepy.tools.close_all_clips.html#moviepy.tools.close_all_clips "moviepy.tools.close_all_clips")
(\[objects, types\]) | Closes all clips in a context. | | [`compute_position`](moviepy.tools.compute_position.html#moviepy.tools.compute_position "moviepy.tools.compute_position")
(clip1\_size, clip2\_size, pos) | Return the position to put clip 1 on clip 2 based on both clip size and the position of clip 1, as return by clip1.pos() method | | [`convert_to_seconds`](moviepy.tools.convert_to_seconds.html#moviepy.tools.convert_to_seconds "moviepy.tools.convert_to_seconds")
(time) | Will convert any time into seconds. | | [`cross_platform_popen_params`](moviepy.tools.cross_platform_popen_params.html#moviepy.tools.cross_platform_popen_params "moviepy.tools.cross_platform_popen_params")
(popen\_params) | Wrap with this function a dictionary of `subprocess.Popen` kwargs and will be ready to work without unexpected behaviours in any platform. | | [`deprecated_version_of`](moviepy.tools.deprecated_version_of.html#moviepy.tools.deprecated_version_of "moviepy.tools.deprecated_version_of")
(func, old\_name) | Indicates that a function is deprecated and has a new name. | | [`ffmpeg_escape_filename`](moviepy.tools.ffmpeg_escape_filename.html#moviepy.tools.ffmpeg_escape_filename "moviepy.tools.ffmpeg_escape_filename")
(filename) | Escape a filename that we want to pass to the ffmpeg command line | | [`find_extension`](moviepy.tools.find_extension.html#moviepy.tools.find_extension "moviepy.tools.find_extension")
(codec) | Returns the correspondent file extension for a codec. | | [`no_display_available`](moviepy.tools.no_display_available.html#moviepy.tools.no_display_available "moviepy.tools.no_display_available")
() | Return True if we determine the host system has no graphical environment. | | [`subprocess_call`](moviepy.tools.subprocess_call.html#moviepy.tools.subprocess_call "moviepy.tools.subprocess_call")
(cmd\[, logger\]) | Executes the given subprocess command. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.rst.txt) --- # moviepy.tools.close_all_clips — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.close\_all\_clips[#](#moviepy-tools-close-all-clips "Permalink to this heading") =============================================================================================== moviepy.tools.close\_all\_clips(_objects\='globals'_, _types\=('audio', 'video', 'image')_)[\[source\]](../../_modules/moviepy/tools.html#close_all_clips) [#](#moviepy.tools.close_all_clips "Permalink to this definition") Closes all clips in a context. Follows different strategies retrieving the namespace from which the clips to close will be retrieved depending on the `objects` argument, and filtering by type of clips depending on the `types` argument. Parameters: * **objects** (_str_ _or_ _dict__,_ _optional_) – * If is a string an the value is `"globals"`, will close all the clips contained by the `globals()` namespace. * If is a dictionary, the values of the dictionary could be clips to close, useful if you want to use `locals()`. * **types** (_Iterable__,_ _optional_) – Set of types of clips to close, being “audio”, “video” or “image” the supported values. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.close_all_clips.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.close_all_clips.rst.txt) --- # moviepy.tools.convert_to_seconds — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.convert\_to\_seconds[#](#moviepy-tools-convert-to-seconds "Permalink to this heading") ===================================================================================================== moviepy.tools.convert\_to\_seconds(_time_)[\[source\]](../../_modules/moviepy/tools.html#convert_to_seconds) [#](#moviepy.tools.convert_to_seconds "Permalink to this definition") Will convert any time into seconds. If the type of time is not valid, it’s returned as is. Here are the accepted formats: convert\_to\_seconds(15.4) \# seconds 15.4 convert\_to\_seconds((1, 21.5)) \# (min,sec) 81.5 convert\_to\_seconds((1, 1, 2)) \# (hr, min, sec) 3662 convert\_to\_seconds('01:01:33.045') 3693.045 convert\_to\_seconds('01:01:33,5') \# coma works too 3693.5 convert\_to\_seconds('1:33,5') \# only minutes and secs 99.5 convert\_to\_seconds('33.5') \# only secs 33.5 On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.convert_to_seconds.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.convert_to_seconds.rst.txt) --- # moviepy.tools.compute_position — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.compute\_position[#](#moviepy-tools-compute-position "Permalink to this heading") ================================================================================================ moviepy.tools.compute\_position(_clip1\_size: tuple_, _clip2\_size: tuple_, _pos: any_, _relative: bool \= False_) → tuple\[int, int\][\[source\]](../../_modules/moviepy/tools.html#compute_position) [#](#moviepy.tools.compute_position "Permalink to this definition") Return the position to put clip 1 on clip 2 based on both clip size and the position of clip 1, as return by clip1.pos() method Parameters: * **clip1\_size** (_tuple_) – The width and height of clip1 (e.g., (width, height)). * **clip2\_size** (_tuple_) – The width and height of clip2 (e.g., (width, height)). * **pos** (_Any_) – The position of clip1 as returned by the clip1.pos() method. * **relative** (_bool_) – Is the position relative (% of clip size), default False. Returns: A tuple (x, y) representing the top-left corner of clip1 relative to clip2. Return type: tuple\[int, int\] Notes For more information on pos, see the documentation for VideoClip.with\_position. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.compute_position.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.compute_position.rst.txt) --- # moviepy.tools.deprecated_version_of — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.deprecated\_version\_of[#](#moviepy-tools-deprecated-version-of "Permalink to this heading") =========================================================================================================== moviepy.tools.deprecated\_version\_of(_func_, _old\_name_)[\[source\]](../../_modules/moviepy/tools.html#deprecated_version_of) [#](#moviepy.tools.deprecated_version_of "Permalink to this definition") Indicates that a function is deprecated and has a new name. func is the new function and old\_name is the name of the deprecated function. Returns: A function that does the same thing as func, but with a docstring and a printed message on call which say that the function is deprecated and that you should use func instead. Return type: deprecated\_func Examples \# The badly named method 'to\_file' is replaced by 'write\_file' class Clip: def write\_file(self, some args): \# blablabla Clip.to\_file \= deprecated\_version\_of(Clip.write\_file, 'to\_file') On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.deprecated_version_of.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.deprecated_version_of.rst.txt) --- # moviepy.tools.ffmpeg_escape_filename — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.ffmpeg\_escape\_filename[#](#moviepy-tools-ffmpeg-escape-filename "Permalink to this heading") ============================================================================================================= moviepy.tools.ffmpeg\_escape\_filename(_filename_)[\[source\]](../../_modules/moviepy/tools.html#ffmpeg_escape_filename) [#](#moviepy.tools.ffmpeg_escape_filename "Permalink to this definition") Escape a filename that we want to pass to the ffmpeg command line That will ensure the filename doesn’t start with a ‘-’ (which would raise an error) On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.ffmpeg_escape_filename.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.ffmpeg_escape_filename.rst.txt) --- # moviepy.tools.cross_platform_popen_params — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.cross\_platform\_popen\_params[#](#moviepy-tools-cross-platform-popen-params "Permalink to this heading") ======================================================================================================================== moviepy.tools.cross\_platform\_popen\_params(_popen\_params_)[\[source\]](../../_modules/moviepy/tools.html#cross_platform_popen_params) [#](#moviepy.tools.cross_platform_popen_params "Permalink to this definition") Wrap with this function a dictionary of `subprocess.Popen` kwargs and will be ready to work without unexpected behaviours in any platform. Currently, the implementation will add to them: * `creationflags=0x08000000`: no extra unwanted window opens on Windows when the child process is created. Only added on Windows. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.cross_platform_popen_params.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.cross_platform_popen_params.rst.txt) --- # moviepy.tools.no_display_available — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.no\_display\_available[#](#moviepy-tools-no-display-available "Permalink to this heading") ========================================================================================================= moviepy.tools.no\_display\_available() → bool[\[source\]](../../_modules/moviepy/tools.html#no_display_available) [#](#moviepy.tools.no_display_available "Permalink to this definition") Return True if we determine the host system has no graphical environment. This is usefull to remove tests requiring display, like preview ..info:: Currently this only works for Linux/BSD systems with X11 or wayland. It probably works for SunOS, AIX and CYGWIN On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.no_display_available.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.no_display_available.rst.txt) --- # moviepy.tools.find_extension — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.find\_extension[#](#moviepy-tools-find-extension "Permalink to this heading") ============================================================================================ moviepy.tools.find\_extension(_codec_)[\[source\]](../../_modules/moviepy/tools.html#find_extension) [#](#moviepy.tools.find_extension "Permalink to this definition") Returns the correspondent file extension for a codec. Parameters: **codec** (_str_) – Video or audio codec name. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.find_extension.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.find_extension.rst.txt) --- # moviepy.tools.subprocess_call — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.tools.subprocess\_call[#](#moviepy-tools-subprocess-call "Permalink to this heading") ============================================================================================== moviepy.tools.subprocess\_call(_cmd_, _logger\='bar'_)[\[source\]](../../_modules/moviepy/tools.html#subprocess_call) [#](#moviepy.tools.subprocess_call "Permalink to this definition") Executes the given subprocess command. Set logger to None or a custom Proglog logger to avoid printings. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.tools.subprocess_call.rst) [Show Source](../../_sources/reference/reference/moviepy.tools.subprocess_call.rst.txt) --- # moviepy.video — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video[#](#module-moviepy.video "Permalink to this heading") ==================================================================== Everything about video manipulation. Modules | | | | --- | --- | | [`moviepy.video.VideoClip`](moviepy.video.VideoClip.html#module-moviepy.video.VideoClip "moviepy.video.VideoClip") | Implements VideoClip (base class for video clips) and its main subclasses: | | [`moviepy.video.compositing`](moviepy.video.compositing.html#module-moviepy.video.compositing "moviepy.video.compositing") | All for compositing video clips. | | [`moviepy.video.fx`](moviepy.video.fx.html#module-moviepy.video.fx "moviepy.video.fx") | All the visual effects that can be applied to VideoClip. | | [`moviepy.video.io`](moviepy.video.io.html#module-moviepy.video.io "moviepy.video.io") | Classes and methods for reading, writing and previewing video files. | | [`moviepy.video.tools`](moviepy.video.tools.html#module-moviepy.video.tools "moviepy.video.tools") | | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.rst) [Show Source](../../_sources/reference/reference/moviepy.video.rst.txt) --- # moviepy.video.VideoClip.BitmapClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.BitmapClip[#](#moviepy-video-videoclip-bitmapclip "Permalink to this heading") ======================================================================================================= _class_ moviepy.video.VideoClip.BitmapClip(_bitmap\_frames_, _\*_, _fps\=None_, _duration\=None_, _color\_dict\=None_, _is\_mask\=False_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#BitmapClip) [#](#moviepy.video.VideoClip.BitmapClip "Permalink to this definition") Clip made of color bitmaps. Mainly designed for testing purposes. to\_bitmap(_color\_dict\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#BitmapClip.to_bitmap) [#](#moviepy.video.VideoClip.BitmapClip.to_bitmap "Permalink to this definition") Returns a valid bitmap list that represents each frame of the clip. If color\_dict is not specified, then it will use the same color\_dict that was used to create the clip. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.BitmapClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.BitmapClip.rst.txt) --- # moviepy.video.VideoClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip[#](#module-moviepy.video.VideoClip "Permalink to this heading") ======================================================================================== Implements VideoClip (base class for video clips) and its main subclasses: * Animated clips: VideoFileClip, ImageSequenceClip, BitmapClip * Static image clips: ImageClip, ColorClip, TextClip, Classes | | | | --- | --- | | [`BitmapClip`](moviepy.video.VideoClip.BitmapClip.html#moviepy.video.VideoClip.BitmapClip "moviepy.video.VideoClip.BitmapClip")
(bitmap\_frames, \*\[, fps, ...\]) | Clip made of color bitmaps. | | [`ColorClip`](moviepy.video.VideoClip.ColorClip.html#moviepy.video.VideoClip.ColorClip "moviepy.video.VideoClip.ColorClip")
(size\[, color, is\_mask, duration\]) | An ImageClip showing just one color. | | [`DataVideoClip`](moviepy.video.VideoClip.DataVideoClip.html#moviepy.video.VideoClip.DataVideoClip "moviepy.video.VideoClip.DataVideoClip")
(data, data\_to\_frame, fps\[, ...\]) | Class of video clips whose successive frames are functions of successive datasets | | [`ImageClip`](moviepy.video.VideoClip.ImageClip.html#moviepy.video.VideoClip.ImageClip "moviepy.video.VideoClip.ImageClip")
(img\[, is\_mask, transparent, ...\]) | Class for non-moving VideoClips. | | [`TextClip`](moviepy.video.VideoClip.TextClip.html#moviepy.video.VideoClip.TextClip "moviepy.video.VideoClip.TextClip")
(\[font, text, filename, font\_size, ...\]) | Class for autogenerated text clips. | | [`UpdatedVideoClip`](moviepy.video.VideoClip.UpdatedVideoClip.html#moviepy.video.VideoClip.UpdatedVideoClip "moviepy.video.VideoClip.UpdatedVideoClip")
(world\[, is\_mask, duration\]) | Class of clips whose frame\_function requires some objects to be updated. | | [`VideoClip`](moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip")
(\[frame\_function, is\_mask, ...\]) | Base class for video clips. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.rst.txt) --- # moviepy.video.VideoClip.ColorClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.ColorClip[#](#moviepy-video-videoclip-colorclip "Permalink to this heading") ===================================================================================================== _class_ moviepy.video.VideoClip.ColorClip(_size_, _color\=None_, _is\_mask\=False_, _duration\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#ColorClip) [#](#moviepy.video.VideoClip.ColorClip "Permalink to this definition") An ImageClip showing just one color. Parameters: * **size** – Size tuple (width, height) in pixels of the clip. * **color** – If argument `is_mask` is False, `color` indicates the color in RGB of the clip (default is black). If is\_mask\` is True, `color` must be a float between 0 and 1 (default is 1) * **is\_mask** – Set to true if the clip will be used as a mask. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.ColorClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.ColorClip.rst.txt) --- # moviepy.video.VideoClip.DataVideoClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.DataVideoClip[#](#moviepy-video-videoclip-datavideoclip "Permalink to this heading") ============================================================================================================= _class_ moviepy.video.VideoClip.DataVideoClip(_data_, _data\_to\_frame_, _fps_, _is\_mask\=False_, _has\_constant\_size\=True_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#DataVideoClip) [#](#moviepy.video.VideoClip.DataVideoClip "Permalink to this definition") Class of video clips whose successive frames are functions of successive datasets Parameters: * **data** – A list of datasets, each dataset being used for one frame of the clip * **data\_to\_frame** – A function d -> video frame, where d is one element of the list data * **fps** – Number of frames per second in the animation On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.DataVideoClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.DataVideoClip.rst.txt) --- # moviepy.video.VideoClip.ImageClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.ImageClip[#](#moviepy-video-videoclip-imageclip "Permalink to this heading") ===================================================================================================== _class_ moviepy.video.VideoClip.ImageClip(_img_, _is\_mask\=False_, _transparent\=True_, _fromalpha\=False_, _duration\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#ImageClip) [#](#moviepy.video.VideoClip.ImageClip "Permalink to this definition") Class for non-moving VideoClips. A video clip originating from a picture. This clip will simply display the given picture at all times. Examples \>>> clip \= ImageClip("myHouse.jpeg") \>>> clip \= ImageClip( someArray ) \# a Numpy array represent Parameters: * **img** – Any picture file (png, tiff, jpeg, etc.) as a string or a path-like object, or any array representing an RGB image (for instance a frame from a VideoClip). * **is\_mask** – Set this parameter to True if the clip is a mask. * **transparent** – Set this parameter to True (default) if you want the alpha layer of the picture (if it exists) to be used as a mask. img[#](#moviepy.video.VideoClip.ImageClip.img "Permalink to this definition") Array representing the image of the clip. image\_transform(_image\_func_, _apply\_to\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#ImageClip.image_transform) [#](#moviepy.video.VideoClip.ImageClip.image_transform "Permalink to this definition") Image-transformation filter. Does the same as VideoClip.image\_transform, but for ImageClip the transformed clip is computed once and for all at the beginning, and not for each ‘frame’. time\_transform(_time\_func_, _apply\_to\=None_, _keep\_duration\=False_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#ImageClip.time_transform) [#](#moviepy.video.VideoClip.ImageClip.time_transform "Permalink to this definition") Time-transformation filter. Applies a transformation to the clip’s timeline (see Clip.time\_transform). This method does nothing for ImageClips (but it may affect their masks or their audios). The result is still an ImageClip. transform(_func_, _apply\_to\=None_, _keep\_duration\=True_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#ImageClip.transform) [#](#moviepy.video.VideoClip.ImageClip.transform "Permalink to this definition") General transformation filter. Equivalent to VideoClip.transform. The result is no more an ImageClip, it has the class VideoClip (since it may be animated) On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.ImageClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.ImageClip.rst.txt) --- # moviepy.video.VideoClip.TextClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.TextClip[#](#moviepy-video-videoclip-textclip "Permalink to this heading") =================================================================================================== _class_ moviepy.video.VideoClip.TextClip(_font\=None_, _text\=None_, _filename\=None_, _font\_size\=None_, _size\=(None, None)_, _margin\=(None, None)_, _color\='black'_, _bg\_color\=None_, _stroke\_color\=None_, _stroke\_width\=0_, _method\='label'_, _text\_align\='left'_, _horizontal\_align\='center'_, _vertical\_align\='center'_, _interline\=4_, _transparent\=True_, _duration\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#TextClip) [#](#moviepy.video.VideoClip.TextClip "Permalink to this definition") Class for autogenerated text clips. Creates an ImageClip originating from a script-generated text image. Parameters: * **font** – Path to the font to use. Must be an OpenType font. If set to None (default) will use Pillow default font * **text** – A string of the text to write. Can be replaced by argument `filename`. * **filename** – The name of a file in which there is the text to write, as a string or a path-like object. Can be provided instead of argument `text` * **font\_size** – Font size in point. Can be auto-set if method=’caption’, or if method=’label’ and size is set. * **size** – Size of the picture in pixels. Can be auto-set if method=’label’ and font\_size is set, but mandatory if method=’caption’. the height can be None for caption if font\_size is defined, it will then be auto-determined. * **margin** – Margin to be added arround the text as a tuple of two (symmetrical) or four (asymmetrical). Either `(horizontal, vertical)` or `(left, top, right, bottom)`. By default no margin (None, None). This is especially usefull for auto-compute size to give the text some extra room. * **color** – Color of the text. Default to “black”. Can be a RGB (or RGBA if transparent = `True`) `tuple`, a color name, or an hexadecimal notation. * **bg\_color** – Color of the background. Default to None for no background. Can be a RGB (or RGBA if transparent = `True`) `tuple`, a color name, or an hexadecimal notation. * **stroke\_color** – Color of the stroke (=contour line) of the text. If `None`, there will be no stroke. * **stroke\_width** – Width of the stroke, in pixels. Must be an int. * **method** – Either : * ’label’ (default), the picture will be autosized so as to fit the text either by auto-computing font size if width is provided or auto-computing width and eight if font size is defined * ’caption’ the text will be drawn in a picture with fixed size provided with the `size` argument. The text will be wrapped automagically, either by auto-computing font size if width and height are provided or adding line break when necesarry if font size is defined * **text\_align** – center | left | right. Text align similar to css. Default to `left`. * **horizontal\_align** – center | left | right. Define horizontal align of text bloc in image. Default to `center`. * **vertical\_align** – center | top | bottom. Define vertical align of text bloc in image. Default to `center`. * **interline** – Interline spacing. Default to `4`. * **transparent** – `True` (default) if you want to take into account the transparency in the image. * **duration** – Duration of the clip * **note::** (_.._) – \*\* About final TextClip size \*\* The final TextClip size will be of the absolute maximum height possible for the font and the number of line. It specifically mean that the final height might be a bit bigger than the real text height, i.e, absolute bottom pixel of text - absolute top pixel of text. This is because in a font, some letter go above standard top line (e.g letters with accents), and bellow standard baseline (e.g letters such as p, y, g). This notion is knowned under the name ascent and descent meaning the highest and lowest pixel above and below baseline If your first line dont have an “accent character” and your last line dont have a “descent character”, you’ll have some “fat” arround On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.TextClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.TextClip.rst.txt) --- # moviepy.video.VideoClip.UpdatedVideoClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.UpdatedVideoClip[#](#moviepy-video-videoclip-updatedvideoclip "Permalink to this heading") =================================================================================================================== _class_ moviepy.video.VideoClip.UpdatedVideoClip(_world_, _is\_mask\=False_, _duration\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#UpdatedVideoClip) [#](#moviepy.video.VideoClip.UpdatedVideoClip "Permalink to this definition") Class of clips whose frame\_function requires some objects to be updated. Particularly practical in science where some algorithm needs to make some steps before a new frame can be generated. UpdatedVideoClips have the following frame\_function: def frame\_function(t): while self.world.clip\_t < t: world.update() \# updates, and increases world.clip\_t return world.to\_frame() Parameters: * **world** – An object with the following attributes: - world.clip\_t: the clip’s time corresponding to the world’s state. - world.update() : update the world’s state, (including increasing world.clip\_t of one time step). - world.to\_frame() : renders a frame depending on the world’s state. * **is\_mask** – True if the clip is a WxH mask with values in 0-1 * **duration** – Duration of the clip, in seconds On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.UpdatedVideoClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.UpdatedVideoClip.rst.txt) --- # moviepy.video.compositing — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.compositing[#](#module-moviepy.video.compositing "Permalink to this heading") ============================================================================================ All for compositing video clips. Modules | | | | --- | --- | | [`moviepy.video.compositing.CompositeVideoClip`](moviepy.video.compositing.CompositeVideoClip.html#module-moviepy.video.compositing.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip") | Main video composition interface of MoviePy. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.compositing.rst) [Show Source](../../_sources/reference/reference/moviepy.video.compositing.rst.txt) --- # moviepy.video.fx.AccelDecel — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.AccelDecel[#](#module-moviepy.video.fx.AccelDecel "Permalink to this heading") ================================================================================================ _class_ moviepy.video.fx.AccelDecel.AccelDecel(_new\_duration: float \= None_, _abruptness: float \= 1.0_, _soonness: float \= 1.0_)[\[source\]](../../_modules/moviepy/video/fx/AccelDecel.html#AccelDecel) [#](#moviepy.video.fx.AccelDecel.AccelDecel "Permalink to this definition") Accelerates and decelerates a clip, useful for GIF making. Parameters: * **new\_duration** (_float_) – Duration for the new transformed clip. If None, will be that of the current clip. * **abruptness** (_float_) – Slope shape in the acceleration-deceleration function. It will depend on the value of the parameter: * `-1 < abruptness < 0`: speed up, down, up. * `abruptness == 0`: no effect. * `abruptness > 0`: speed down, up, down. * **soonness** (_float_) – For positive abruptness, determines how soon the transformation occurs. Should be a positive number. Raises: **ValueError** – When `sooness` argument is lower than 0. Examples The following graphs show functions generated by different combinations of arguments, where the value of the slopes represents the speed of the videos generated, being the linear function (in red) a combination that does not produce any transformation. ![acced_decel FX parameters combinations](../../_images/accel_decel-fx-params.png) apply(_clip_)[\[source\]](../../_modules/moviepy/video/fx/AccelDecel.html#AccelDecel.apply) [#](#moviepy.video.fx.AccelDecel.AccelDecel.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.AccelDecel.AccelDecel.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.AccelDecel.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.AccelDecel.rst.txt) --- # moviepy.video.fx.BlackAndWhite — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.BlackAndWhite[#](#module-moviepy.video.fx.BlackAndWhite "Permalink to this heading") ====================================================================================================== _class_ moviepy.video.fx.BlackAndWhite.BlackAndWhite(_RGB: str \= None_, _preserve\_luminosity: bool \= True_)[\[source\]](../../_modules/moviepy/video/fx/BlackAndWhite.html#BlackAndWhite) [#](#moviepy.video.fx.BlackAndWhite.BlackAndWhite "Permalink to this definition") Desaturates the picture, makes it black and white. Parameter RGB allows to set weights for the different color channels. If RBG is ‘CRT\_phosphor’ a special set of values is used. preserve\_luminosity maintains the sum of RGB to 1. apply(_clip_)[\[source\]](../../_modules/moviepy/video/fx/BlackAndWhite.html#BlackAndWhite.apply) [#](#moviepy.video.fx.BlackAndWhite.BlackAndWhite.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.BlackAndWhite.BlackAndWhite.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.BlackAndWhite.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.BlackAndWhite.rst.txt) --- # moviepy.video.VideoClip.VideoClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.VideoClip.VideoClip[#](#moviepy-video-videoclip-videoclip "Permalink to this heading") ===================================================================================================== _class_ moviepy.video.VideoClip.VideoClip(_frame\_function\=None_, _is\_mask\=False_, _duration\=None_, _has\_constant\_size\=True_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip) [#](#moviepy.video.VideoClip.VideoClip "Permalink to this definition") Base class for video clips. See `VideoFileClip`, `ImageClip` etc. for more user-friendly classes. Parameters: * **is\_mask** – True if the clip is going to be used as a mask. * **duration** – Duration of the clip in seconds. If None we got a clip of infinite duration * **has\_constant\_size** – Define if clip size is constant or if it may vary with time. Default to True size[#](#moviepy.video.VideoClip.VideoClip.size "Permalink to this definition") The size of the clip, (width,height), in pixels. w, h The width and height of the clip, in pixels. is\_mask[#](#moviepy.video.VideoClip.VideoClip.is_mask "Permalink to this definition") Boolean set to True if the clip is a mask. frame\_function[#](#moviepy.video.VideoClip.VideoClip.frame_function "Permalink to this definition") A function `t-> frame at time t` where `frame` is a w\*h\*3 RGB array. mask(_default None_)[#](#moviepy.video.VideoClip.VideoClip.mask "Permalink to this definition") VideoClip mask attached to this clip. If mask is `None`, The video clip is fully opaque. audio(_default None_)[#](#moviepy.video.VideoClip.VideoClip.audio "Permalink to this definition") An AudioClip instance containing the audio of the video clip. pos[#](#moviepy.video.VideoClip.VideoClip.pos "Permalink to this definition") A function `t->(x,y)` where `x,y` is the position of the clip when it is composed with other clips. See `VideoClip.set_pos` for more details relative\_pos[#](#moviepy.video.VideoClip.VideoClip.relative_pos "Permalink to this definition") See variable `pos`. layer[#](#moviepy.video.VideoClip.VideoClip.layer "Permalink to this definition") Indicates which clip is rendered on top when two clips overlap in a CompositeVideoClip. The highest number is rendered on top. Default is 0. _property_ aspect\_ratio[#](#moviepy.video.VideoClip.VideoClip.aspect_ratio "Permalink to this definition") Returns the aspect ratio of the video. compose\_mask(_background\_mask: ndarray_, _t: float_) → ndarray[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.compose_mask) [#](#moviepy.video.VideoClip.VideoClip.compose_mask "Permalink to this definition") Returns the result of the clip’s mask at time t composited on the given background\_mask, the position of the clip being given by the clip’s `pos` attribute. Meant for compositing. (warning: only use this function to blit two masks together, never images) Parameters: * **background\_mask** – The underlying mask onto which the clip mask will be composed. * **t** – The time position in the clip at which to extract the mask. compose\_on(_background: Image_, _t_) → Image[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.compose_on) [#](#moviepy.video.VideoClip.VideoClip.compose_on "Permalink to this definition") Returns the result of the clip’s frame at time t on top on the given picture, the position of the clip being given by the clip’s `pos` attribute. Meant for compositing. If the clip/backgrounds have transparency the transparency will be accounted for. The return is a Pillow Image Parameters: * **(****Image****)** (_backrgound_) – The background image to apply current clip on top of if the background image is transparent it must be given as a RGBA image * **t** – The time of clip to apply on top of clip * **Return** – copy()[#](#moviepy.video.VideoClip.VideoClip.copy "Permalink to this definition") Mixed copy of the clip. Returns a shallow copy of the clip whose mask and audio will be shallow copies of the clip’s mask and audio if they exist. This method is intensively used to produce new clips every time there is an outplace transformation of the clip (clip.resize, clip.subclipped, etc.) Acts like a deepcopy except for the fact that readers and other possible unpickleables objects are not copied. cropped(_x1: int \= None_, _y1: int \= None_, _x2: int \= None_, _y2: int \= None_, _width: int \= None_, _height: int \= None_, _x\_center: int \= None_, _y\_center: int \= None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.cropped) [#](#moviepy.video.VideoClip.VideoClip.cropped "Permalink to this definition") Returns a new clip in which just a rectangular subregion of the original clip is conserved. x1,y1 indicates the top left corner and x2,y2 is the lower right corner of the cropped region. All coordinates are in pixels. Float numbers are accepted. For info on the parameters, please see `vfx.Crop` display\_in\_notebook(_filetype\=None_, _maxduration\=60_, _t\=None_, _fps\=None_, _rd\_kwargs\=None_, _center\=True_, _\*\*html\_kwargs_)[#](#moviepy.video.VideoClip.VideoClip.display_in_notebook "Permalink to this definition") Displays clip content in an Jupyter Notebook. Remarks: If your browser doesn’t support HTML5, this should warn you. If nothing is displayed, maybe your file or filename is wrong. Important: The media will be physically embedded in the notebook. Parameters: * **clip** ([_moviepy.Clip.Clip_](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") ) – Either the name of a file, or a clip to preview. The clip will actually be written to a file and embedded as if a filename was provided. * **filetype** (_str__,_ _optional_) – One of `"video"`, `"image"` or `"audio"`. If None is given, it is determined based on the extension of `filename`, but this can bug. * **maxduration** (_float__,_ _optional_) – An error will be raised if the clip’s duration is more than the indicated value (in seconds), to avoid spoiling the browser’s cache and the RAM. * **t** (_float__,_ _optional_) – If not None, only the frame at time t will be displayed in the notebook, instead of a video of the clip. * **fps** (_int__,_ _optional_) – Enables to specify an fps, as required for clips whose fps is unknown. * **rd\_kwargs** (_dict__,_ _optional_) – Keyword arguments for the rendering, like `dict(fps=15, bitrate="50k")`. Allow you to give some options to the render process. You can, for example, disable the logger bar passing `dict(logger=None)`. * **center** (_bool__,_ _optional_) – If true (default), the content will be wrapped in a `
` HTML container, so the content will be displayed at the center. * **kwargs** – Allow you to give some options, like `width=260`, etc. When editing looping gifs, a good choice is `loop=1, autoplay=1`. Examples from moviepy import \* \# later ... clip.display\_in\_notebook(width\=360) clip.audio.display\_in\_notebook() clip.write\_gif("test.gif") display\_in\_notebook('test.gif') clip.save\_frame("first\_frame.jpeg") display\_in\_notebook("first\_frame.jpeg") fill\_array(_pre\_array_, _shape\=(0, 0)_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.fill_array) [#](#moviepy.video.VideoClip.VideoClip.fill_array "Permalink to this definition") Fills an array to match the specified shape. If the pre\_array is smaller than the desired shape, the missing rows or columns are added with ones to the bottom or right, respectively, until the shape matches. If the pre\_array is larger than the desired shape, the excess rows or columns are cropped from the bottom or right, respectively, until the shape matches. The resulting array with the filled shape is returned. Parameters: * **(****numpy.ndarray****)** (_pre\_array_) – The original array to be filled. * **(****tuple****)** (_shape_) – The desired shape of the resulting array. _property_ h[#](#moviepy.video.VideoClip.VideoClip.h "Permalink to this definition") Returns the height of the video. image\_transform(_image\_func_, _apply\_to\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.image_transform) [#](#moviepy.video.VideoClip.VideoClip.image_transform "Permalink to this definition") Modifies the images of a clip by replacing the frame get\_frame(t) by another frame, image\_func(get\_frame(t)). _property_ n\_frames[#](#moviepy.video.VideoClip.VideoClip.n_frames "Permalink to this definition") Returns the number of frames of the video. preview(_fps\=15_, _audio\=True_, _audio\_fps\=22050_, _audio\_buffersize\=3000_, _audio\_nbytes\=2_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.preview) [#](#moviepy.video.VideoClip.VideoClip.preview "Permalink to this definition") Displays the clip in a window, at the given frames per second. It will avoid that the clip be played faster than normal, but it cannot avoid the clip to be played slower than normal if the computations are complex. In this case, try reducing the `fps`. Parameters: * **fps** (_int__,_ _optional_) – * **15.** (_Number_ _of_ _frames per seconds in the displayed video. Default to_) – * **audio** (_bool__,_ _optional_) – * **during** (_True_ _(__default__)_ _if you want the clip's audio be played_) – * **preview.** (_the_) – * **audio\_fps** (_int__,_ _optional_) – * **sound.** (_The number_ _of_ _bytes used generating the audio_) – * **audio\_buffersize** (_int__,_ _optional_) – * **sound.** – * **audio\_nbytes** (_int__,_ _optional_) – * **sound.** – Examples from moviepy import \* clip \= VideoFileClip("media/chaplin.mp4") clip.preview(fps\=10, audio\=False) resized(_new\_size\=None_, _height\=None_, _width\=None_, _apply\_to\_mask\=True_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.resized) [#](#moviepy.video.VideoClip.VideoClip.resized "Permalink to this definition") Returns a video clip that is a resized version of the clip. For info on the parameters, please see `vfx.Resize` rotated(_angle: float_, _unit: str \= 'deg'_, _resample: str \= 'bicubic'_, _expand: bool \= False_, _center: tuple \= None_, _translate: tuple \= None_, _bg\_color: tuple \= None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.rotated) [#](#moviepy.video.VideoClip.VideoClip.rotated "Permalink to this definition") Rotates the specified clip by `angle` degrees (or radians) anticlockwise If the angle is not a multiple of 90 (degrees) or `center`, `translate`, and `bg_color` are not `None`. For info on the parameters, please see `vfx.Rotate` save\_frame(_filename_, _t\=0_, _with\_mask\=True_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.save_frame) [#](#moviepy.video.VideoClip.VideoClip.save_frame "Permalink to this definition") Save a clip’s frame to an image file. Saves the frame of clip corresponding to time `t` in `filename`. `t` can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. Parameters: * **filename** (_str_) – Name of the file in which the frame will be stored. * **t** (_float_ _or_ _tuple_ _or_ _str__,_ _optional_) – Moment of the frame to be saved. As default, the first frame will be saved. * **with\_mask** (_bool__,_ _optional_) – If is `True` the mask is saved in the alpha layer of the picture (only works with PNGs). show(_t\=0_, _with\_mask\=True_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.show) [#](#moviepy.video.VideoClip.VideoClip.show "Permalink to this definition") Splashes the frame of clip corresponding to time `t`. Parameters: * **t** (_float_ _or_ _tuple_ _or_ _str__,_ _optional_) – * **display.** (_Time in seconds_ _of_ _the frame to_) – * **with\_mask** (_bool__,_ _optional_) – * **without** (_False if the clip has a mask but you want to see the clip_) – * **mask.** (_the_) – Examples from moviepy import \* clip \= VideoFileClip("media/chaplin.mp4") clip.show(t\=4) to\_ImageClip(_t\=0_, _with\_mask\=True_, _duration\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.to_ImageClip) [#](#moviepy.video.VideoClip.VideoClip.to_ImageClip "Permalink to this definition") Returns an ImageClip made out of the clip’s frame at time `t`, which can be expressed in seconds (15.35), in (min, sec), in (hour, min, sec), or as a string: ‘01:03:05.35’. to\_RGB()[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.to_RGB) [#](#moviepy.video.VideoClip.VideoClip.to_RGB "Permalink to this definition") Return a non-mask video clip made from the mask video clip. to\_mask(_canal\=0_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.to_mask) [#](#moviepy.video.VideoClip.VideoClip.to_mask "Permalink to this definition") Return a mask a video clip made from the clip. _property_ w[#](#moviepy.video.VideoClip.VideoClip.w "Permalink to this definition") Returns the width of the video. with\_audio(_audioclip_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_audio) [#](#moviepy.video.VideoClip.VideoClip.with_audio "Permalink to this definition") Attach an AudioClip to the VideoClip. Returns a copy of the VideoClip instance, with the audio attribute set to `audio`, which must be an AudioClip instance. with\_background\_color(_size\=None_, _color\=(0, 0, 0)_, _pos\=None_, _opacity\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_background_color) [#](#moviepy.video.VideoClip.VideoClip.with_background_color "Permalink to this definition") Place the clip on a colored background. Returns a clip made of the current clip overlaid on a color clip of a possibly bigger size. Can serve to flatten transparent clips. Parameters: * **size** – Size (width, height) in pixels of the final clip. By default it will be the size of the current clip. * **color** – Background color of the final clip (\[R,G,B\]). * **pos** – Position of the clip in the final clip. ‘center’ is the default * **opacity** – Parameter in 0..1 indicating the opacity of the colored background. with\_effects\_on\_subclip(_effects: List\[[Effect](moviepy.Effect.html#moviepy.Effect.Effect "moviepy.Effect.Effect")\ \]_, _start\_time\=0_, _end\_time\=None_, _\*\*kwargs_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_effects_on_subclip) [#](#moviepy.video.VideoClip.VideoClip.with_effects_on_subclip "Permalink to this definition") Apply a transformation to a part of the clip. Returns a new clip in which the function `fun` (clip->clip) has been applied to the subclip between times start\_time and end\_time (in seconds). Examples \# The scene between times t=3s and t=6s in \`\`clip\`\` will be \# be played twice slower in \`\`new\_clip\`\` new\_clip \= clip.with\_sub\_effect(MultiplySpeed(0.5), 3, 6) with\_layer\_index(_index_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_layer_index) [#](#moviepy.video.VideoClip.VideoClip.with_layer_index "Permalink to this definition") Set the clip’s layer in compositions. Clips with a greater `layer` attribute will be displayed on top of others. Note: Only has effect when the clip is used in a CompositeVideoClip. with\_mask(_mask: [VideoClip](#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") | str \= 'auto'_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_mask) [#](#moviepy.video.VideoClip.VideoClip.with_mask "Permalink to this definition") Set the clip’s mask. Returns a copy of the VideoClip with the mask attribute set to `mask`, which must be a greyscale (values in 0-1) VideoClip. Parameters: **mask** (_Union__\[__"VideoClip"__,_ _str__\]__,_ _optional_) – The mask to apply to the clip. If set to “auto”, a default mask will be generated: - If the clip has a constant size, a solid mask with a value of 1.0 will be created. - Otherwise, a dynamic solid mask will be created based on the frame size. with\_opacity(_opacity_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_opacity) [#](#moviepy.video.VideoClip.VideoClip.with_opacity "Permalink to this definition") Set the opacity/transparency level of the clip. Returns a semi-transparent copy of the clip where the mask is multiplied by `op` (any float, normally between 0 and 1). with\_position(_pos_, _relative\=False_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_position) [#](#moviepy.video.VideoClip.VideoClip.with_position "Permalink to this definition") Set the clip’s position in compositions. Sets the position that the clip will have when included in compositions. The argument `pos` can be either a couple `(x,y)` or a function `t-> (x,y)`. x and y mark the location of the top left corner of the clip, and can be of several types. Examples clip.with\_position((45,150)) \# x=45, y=150 \# clip horizontally centered, at the top of the picture clip.with\_position(("center","top")) \# clip is at 40% of the width, 70% of the height: clip.with\_position((0.4,0.7), relative\=True) \# clip's position is horizontally centered, and moving up ! clip.with\_position(lambda t: ('center', 50+t)) with\_updated\_frame\_function(_frame\_function: Callable\[\[float\], ndarray\]_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.with_updated_frame_function) [#](#moviepy.video.VideoClip.VideoClip.with_updated_frame_function "Permalink to this definition") Change the clip’s `get_frame`. Returns a copy of the VideoClip instance, with the frame\_function attribute set to mf. without\_audio()[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.without_audio) [#](#moviepy.video.VideoClip.VideoClip.without_audio "Permalink to this definition") Remove the clip’s audio. Return a copy of the clip with audio set to None. without\_mask()[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.without_mask) [#](#moviepy.video.VideoClip.VideoClip.without_mask "Permalink to this definition") Remove the clip’s mask. write\_gif(_filename_, _fps\=None_, _loop\=0_, _logger\='bar'_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.write_gif) [#](#moviepy.video.VideoClip.VideoClip.write_gif "Permalink to this definition") Write the VideoClip to a GIF file. Converts a VideoClip into an animated GIF using imageio Parameters: * **filename** – Name of the resulting gif file, as a string or a path-like object. * **fps** – Number of frames per second (see note below). If it isn’t provided, then the function will look for the clip’s `fps` attribute (VideoFileClip, for instance, have one). * **loop** (_int__,_ _optional_) – Repeat the clip using `loop` iterations in the resulting GIF. * **progress\_bar** – If True, displays a progress bar Notes The gif will be playing the clip in real time (you can only change the frame rate). If you want the gif to be played slower than the clip you will use \# slow down clip 50% and make it a gif myClip.multiply\_speed(0.5).to\_gif('myClip.gif') write\_images\_sequence(_name\_format_, _fps\=None_, _with\_mask\=True_, _logger\='bar'_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.write_images_sequence) [#](#moviepy.video.VideoClip.VideoClip.write_images_sequence "Permalink to this definition") Writes the videoclip to a sequence of image files. Parameters: * **name\_format** – A filename specifying the numerotation format and extension of the pictures. For instance “frame%03d.png” for filenames indexed with 3 digits and PNG format. Also possible: “some\_folder/frame%04d.jpeg”, etc. * **fps** – Number of frames per second to consider when writing the clip. If not specified, the clip’s `fps` attribute will be used if it has one. * **with\_mask** – will save the clip’s mask (if any) as an alpha canal (PNGs only). * **logger** – Either `"bar"` for progress bar or `None` or any Proglog logger. Returns: A list of all the files generated. Return type: names\_list Notes The resulting image sequence can be read using e.g. the class `ImageSequenceClip`. write\_videofile(_filename_, _fps\=None_, _codec\=None_, _bitrate\=None_, _audio\=True_, _audio\_fps\=44100_, _preset\='medium'_, _audio\_nbytes\=4_, _audio\_codec\=None_, _audio\_bitrate\=None_, _audio\_bufsize\=2000_, _temp\_audiofile\=None_, _temp\_audiofile\_path\=''_, _remove\_temp\=True_, _write\_logfile\=False_, _threads\=None_, _ffmpeg\_params\=None_, _logger\='bar'_, _pixel\_format\=None_)[\[source\]](../../_modules/moviepy/video/VideoClip.html#VideoClip.write_videofile) [#](#moviepy.video.VideoClip.VideoClip.write_videofile "Permalink to this definition") Write the clip to a videofile. Parameters: * **filename** – Name of the video file to write in, as a string or a path-like object. The extension must correspond to the “codec” used (see below), or simply be ‘.avi’ (which will work with any codec). * **fps** – Number of frames per second in the resulting video file. If None is provided, and the clip has an fps attribute, this fps will be used. * **codec** – Codec to use for image encoding. Can be any codec supported by ffmpeg. If the filename is has extension ‘.mp4’, ‘.ogv’, ‘.webm’, the codec will be set accordingly, but you can still set it if you don’t like the default. For other extensions, the output filename must be set accordingly. Some examples of codecs are: * `'libx264'` (default codec for file extension `.mp4`) makes well-compressed videos (quality tunable using ‘bitrate’). * `'mpeg4'` (other codec for extension `.mp4`) can be an alternative to `'libx264'`, and produces higher quality videos by default. * `'rawvideo'` (use file extension `.avi`) will produce a video of perfect quality, of possibly very huge size. * `png` (use file extension `.avi`) will produce a video of perfect quality, of smaller size than with `rawvideo`. * `'libvorbis'` (use file extension `.ogv`) is a nice video format, which is completely free/ open source. However not everyone has the codecs installed by default on their machine. * `'libvpx'` (use file extension `.webm`) is tiny a video format well indicated for web videos (with HTML5). Open source. * **audio** – Either `True`, `False`, or a file name. If `True` and the clip has an audio clip attached, this audio clip will be incorporated as a soundtrack in the movie. If `audio` is the name of an audio file, this audio file will be incorporated as a soundtrack in the movie. * **audio\_fps** – frame rate to use when generating the sound. * **temp\_audiofile** – the name of the temporary audiofile, as a string or path-like object, to be created and then used to write the complete video, if any. * **temp\_audiofile\_path** – the location that the temporary audiofile is placed, as a string or path-like object. Defaults to the current working directory. * **audio\_codec** – Which audio codec should be used. Examples are ‘libmp3lame’ for ‘.mp3’, ‘libvorbis’ for ‘ogg’, ‘libfdk\_aac’:’m4a’, ‘pcm\_s16le’ for 16-bit wav and ‘pcm\_s32le’ for 32-bit wav. Default is ‘libmp3lame’, unless the video extension is ‘ogv’ or ‘webm’, at which case the default is ‘libvorbis’. * **audio\_bitrate** – Audio bitrate, given as a string like ‘50k’, ‘500k’, ‘3000k’. Will determine the size/quality of audio in the output file. Note that it mainly an indicative goal, the bitrate won’t necessarily be the this in the final file. * **preset** – Sets the time that FFMPEG will spend optimizing the compression. Choices are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Note that this does not impact the quality of the video, only the size of the video file. So choose ultrafast when you are in a hurry and file size does not matter. * **threads** – Number of threads to use for ffmpeg. Can speed up the writing of the video on multicore computers. * **ffmpeg\_params** – Any additional ffmpeg parameters you would like to pass, as a list of terms, like \[‘-option1’, ‘value1’, ‘-option2’, ‘value2’\]. * **write\_logfile** – If true, will write log files for the audio and the video. These will be files ending with ‘.log’ with the name of the output file in them. * **logger** – Either `"bar"` for progress bar or `None` or any Proglog logger. * **pixel\_format** – Pixel format for the output video file. Examples from moviepy import VideoFileClip clip \= VideoFileClip("myvideo.mp4").subclipped(100,120) clip.write\_videofile("my\_new\_video.mp4") clip.close() On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.VideoClip.VideoClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.VideoClip.VideoClip.rst.txt) --- # moviepy.video.compositing.CompositeVideoClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.compositing.CompositeVideoClip[#](#module-moviepy.video.compositing.CompositeVideoClip "Permalink to this heading") ================================================================================================================================== Main video composition interface of MoviePy. Classes | | | | --- | --- | | [`CompositeVideoClip`](moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.html#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip")
(clips\[, size, bg\_color, ...\]) | A VideoClip made of other videoclips displayed together. | Functions | | | | --- | --- | | [`clips_array`](moviepy.video.compositing.CompositeVideoClip.clips_array.html#moviepy.video.compositing.CompositeVideoClip.clips_array "moviepy.video.compositing.CompositeVideoClip.clips_array")
(array\[, rows\_widths, ...\]) | Given a matrix whose rows are clips, creates a CompositeVideoClip where all clips are placed side by side horizontally for each clip in each row and one row on top of the other for each row. | | [`concatenate_videoclips`](moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips.html#moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips "moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips")
(clips\[, method, ...\]) | Concatenates several video clips. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.compositing.CompositeVideoClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.compositing.CompositeVideoClip.rst.txt) --- # moviepy.video.fx.Blink — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.Blink[#](#module-moviepy.video.fx.Blink "Permalink to this heading") ====================================================================================== _class_ moviepy.video.fx.Blink.Blink(_duration\_on: float_, _duration\_off: float_)[\[source\]](../../_modules/moviepy/video/fx/Blink.html#Blink) [#](#moviepy.video.fx.Blink.Blink "Permalink to this definition") Makes the clip blink. At each blink it will be displayed `duration_on` seconds and disappear `duration_off` seconds. Will only work in composite clips. apply(_clip_)[\[source\]](../../_modules/moviepy/video/fx/Blink.html#Blink.apply) [#](#moviepy.video.fx.Blink.Blink.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.Blink.Blink.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.Blink.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.Blink.rst.txt) --- # moviepy.video.fx.Crop — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.Crop[#](#module-moviepy.video.fx.Crop "Permalink to this heading") ==================================================================================== _class_ moviepy.video.fx.Crop.Crop(_x1: int \= None_, _y1: int \= None_, _x2: int \= None_, _y2: int \= None_, _width: int \= None_, _height: int \= None_, _x\_center: int \= None_, _y\_center: int \= None_)[\[source\]](../../_modules/moviepy/video/fx/Crop.html#Crop) [#](#moviepy.video.fx.Crop.Crop "Permalink to this definition") Effect to crop a clip to get a new clip in which just a rectangular subregion of the original clip is conserved. x1,y1 indicates the top left corner and x2,y2 is the lower right corner of the cropped region. All coordinates are in pixels. Float numbers are accepted. To crop an arbitrary rectangle: \>>> Crop(x1\=50, y1\=60, x2\=460, y2\=275) Only remove the part above y=30: \>>> Crop(y1\=30) Crop a rectangle that starts 10 pixels left and is 200px wide \>>> Crop(x1\=10, width\=200) Crop a rectangle centered in x,y=(300,400), width=50, height=150 : \>>> Crop(x\_center\=300, y\_center\=400, width\=50, height\=150) Any combination of the above should work, like for this rectangle centered in x=300, with explicit y-boundaries: \>>> Crop(x\_center\=300, width\=400, y1\=100, y2\=600) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/Crop.html#Crop.apply) [#](#moviepy.video.fx.Crop.Crop.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.Crop.Crop.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.Crop.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.Crop.rst.txt) --- # moviepy.video.fx — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx[#](#module-moviepy.video.fx "Permalink to this heading") ========================================================================== All the visual effects that can be applied to VideoClip. Modules | | | | --- | --- | | [`moviepy.video.fx.AccelDecel`](moviepy.video.fx.AccelDecel.html#module-moviepy.video.fx.AccelDecel "moviepy.video.fx.AccelDecel")
(\[new\_duration, ...\]) | Accelerates and decelerates a clip, useful for GIF making. | | [`moviepy.video.fx.BlackAndWhite`](moviepy.video.fx.BlackAndWhite.html#module-moviepy.video.fx.BlackAndWhite "moviepy.video.fx.BlackAndWhite")
(\[RGB, ...\]) | Desaturates the picture, makes it black and white. | | [`moviepy.video.fx.Blink`](moviepy.video.fx.Blink.html#module-moviepy.video.fx.Blink "moviepy.video.fx.Blink")
(duration\_on, duration\_off) | Makes the clip blink. | | [`moviepy.video.fx.Crop`](moviepy.video.fx.Crop.html#module-moviepy.video.fx.Crop "moviepy.video.fx.Crop")
(\[x1, y1, x2, y2, ...\]) | Effect to crop a clip to get a new clip in which just a rectangular subregion of the original clip is conserved. | | [`moviepy.video.fx.CrossFadeIn`](moviepy.video.fx.CrossFadeIn.html#module-moviepy.video.fx.CrossFadeIn "moviepy.video.fx.CrossFadeIn")
(duration) | Makes the clip appear progressively, over `duration` seconds. | | [`moviepy.video.fx.CrossFadeOut`](moviepy.video.fx.CrossFadeOut.html#module-moviepy.video.fx.CrossFadeOut "moviepy.video.fx.CrossFadeOut")
(duration) | Makes the clip disappear progressively, over `duration` seconds. | | [`moviepy.video.fx.EvenSize`](moviepy.video.fx.EvenSize.html#module-moviepy.video.fx.EvenSize "moviepy.video.fx.EvenSize")
() | Crops the clip to make dimensions even. | | [`moviepy.video.fx.FadeIn`](moviepy.video.fx.FadeIn.html#module-moviepy.video.fx.FadeIn "moviepy.video.fx.FadeIn")
(duration\[, ...\]) | Makes the clip progressively appear from some color (black by default), over `duration` seconds at the beginning of the clip. | | [`moviepy.video.fx.FadeOut`](moviepy.video.fx.FadeOut.html#module-moviepy.video.fx.FadeOut "moviepy.video.fx.FadeOut")
(duration\[, final\_color\]) | Makes the clip progressively fade to some color (black by default), over `duration` seconds at the end of the clip. | | [`moviepy.video.fx.Freeze`](moviepy.video.fx.Freeze.html#module-moviepy.video.fx.Freeze "moviepy.video.fx.Freeze")
(\[t, ...\]) | Momentarily freeze the clip at time t. | | [`moviepy.video.fx.FreezeRegion`](moviepy.video.fx.FreezeRegion.html#module-moviepy.video.fx.FreezeRegion "moviepy.video.fx.FreezeRegion")
(\[t, region, ...\]) | Freezes one region of the clip while the rest remains animated. | | [`moviepy.video.fx.GammaCorrection`](moviepy.video.fx.GammaCorrection.html#module-moviepy.video.fx.GammaCorrection "moviepy.video.fx.GammaCorrection")
(gamma) | Gamma-correction of a video clip. | | [`moviepy.video.fx.HeadBlur`](moviepy.video.fx.HeadBlur.html#module-moviepy.video.fx.HeadBlur "moviepy.video.fx.HeadBlur")
(fx, fy, radius\[, ...\]) | Returns a filter that will blur a moving part (a head ?) of the frames. | | [`moviepy.video.fx.InvertColors`](moviepy.video.fx.InvertColors.html#module-moviepy.video.fx.InvertColors "moviepy.video.fx.InvertColors")
() | Returns the color-inversed clip. | | [`moviepy.video.fx.Loop`](moviepy.video.fx.Loop.html#module-moviepy.video.fx.Loop "moviepy.video.fx.Loop")
(\[n, duration\]) | Returns a clip that plays the current clip in an infinite loop. | | [`moviepy.video.fx.LumContrast`](moviepy.video.fx.LumContrast.html#module-moviepy.video.fx.LumContrast "moviepy.video.fx.LumContrast")
(\[lum, ...\]) | Luminosity-contrast correction of a clip. | | [`moviepy.video.fx.MakeLoopable`](moviepy.video.fx.MakeLoopable.html#module-moviepy.video.fx.MakeLoopable "moviepy.video.fx.MakeLoopable")
(overlap\_duration) | Makes the clip fade in progressively at its own end, this way it can be looped indefinitely. | | [`moviepy.video.fx.Margin`](moviepy.video.fx.Margin.html#module-moviepy.video.fx.Margin "moviepy.video.fx.Margin")
(\[margin\_size, left, ...\]) | Draws an external margin all around the frame. | | [`moviepy.video.fx.MaskColor`](moviepy.video.fx.MaskColor.html#module-moviepy.video.fx.MaskColor "moviepy.video.fx.MaskColor")
(\[color, ...\]) | Returns a new clip with a mask for transparency where the original clip is of the given color. | | [`moviepy.video.fx.MasksAnd`](moviepy.video.fx.MasksAnd.html#module-moviepy.video.fx.MasksAnd "moviepy.video.fx.MasksAnd")
(other\_clip) | Returns the logical 'and' (minimum pixel color values) between two masks. | | [`moviepy.video.fx.MasksOr`](moviepy.video.fx.MasksOr.html#module-moviepy.video.fx.MasksOr "moviepy.video.fx.MasksOr")
(other\_clip) | Returns the logical 'or' (maximum pixel color values) between two masks. | | [`moviepy.video.fx.MirrorX`](moviepy.video.fx.MirrorX.html#module-moviepy.video.fx.MirrorX "moviepy.video.fx.MirrorX")
(\[apply\_to\]) | Flips the clip horizontally (and its mask too, by default). | | [`moviepy.video.fx.MirrorY`](moviepy.video.fx.MirrorY.html#module-moviepy.video.fx.MirrorY "moviepy.video.fx.MirrorY")
(\[apply\_to\]) | Flips the clip vertically (and its mask too, by default). | | [`moviepy.video.fx.MultiplyColor`](moviepy.video.fx.MultiplyColor.html#module-moviepy.video.fx.MultiplyColor "moviepy.video.fx.MultiplyColor")
(factor) | Multiplies the clip's colors by the given factor, can be used to decrease or increase the clip's brightness (is that the right word ?) | | [`moviepy.video.fx.MultiplySpeed`](moviepy.video.fx.MultiplySpeed.html#module-moviepy.video.fx.MultiplySpeed "moviepy.video.fx.MultiplySpeed")
(\[factor, ...\]) | Returns a clip playing the current clip but at a speed multiplied by `factor`. | | [`moviepy.video.fx.Painting`](moviepy.video.fx.Painting.html#module-moviepy.video.fx.Painting "moviepy.video.fx.Painting")
(\[saturation, black\]) | Transforms any photo into some kind of painting. | | [`moviepy.video.fx.Resize`](moviepy.video.fx.Resize.html#module-moviepy.video.fx.Resize "moviepy.video.fx.Resize")
(\[new\_size, height, ...\]) | Effect returning a video clip that is a resized version of the clip. | | [`moviepy.video.fx.Rotate`](moviepy.video.fx.Rotate.html#module-moviepy.video.fx.Rotate "moviepy.video.fx.Rotate")
(angle\[, unit, ...\]) | Rotates the specified clip by `angle` degrees (or radians) anticlockwise If the angle is not a multiple of 90 (degrees) or `center`, `translate`, and `bg_color` are not `None`, there will be black borders. | | [`moviepy.video.fx.Scroll`](moviepy.video.fx.Scroll.html#module-moviepy.video.fx.Scroll "moviepy.video.fx.Scroll")
(\[w, h, x\_speed, ...\]) | Effect that scrolls horizontally or vertically a clip, e.g. | | [`moviepy.video.fx.SlideIn`](moviepy.video.fx.SlideIn.html#module-moviepy.video.fx.SlideIn "moviepy.video.fx.SlideIn")
(duration, side) | Makes the clip arrive from one side of the screen. | | [`moviepy.video.fx.SlideOut`](moviepy.video.fx.SlideOut.html#module-moviepy.video.fx.SlideOut "moviepy.video.fx.SlideOut")
(duration, side) | Makes the clip goes away by one side of the screen. | | [`moviepy.video.fx.SuperSample`](moviepy.video.fx.SuperSample.html#module-moviepy.video.fx.SuperSample "moviepy.video.fx.SuperSample")
(d, n\_frames) | Replaces each frame at time t by the mean of n\_frames equally spaced frames taken in the interval \[t-d, t+d\]. | | [`moviepy.video.fx.TimeMirror`](moviepy.video.fx.TimeMirror.html#module-moviepy.video.fx.TimeMirror "moviepy.video.fx.TimeMirror")
() | Returns a clip that plays the current clip backwards. | | [`moviepy.video.fx.TimeSymmetrize`](moviepy.video.fx.TimeSymmetrize.html#module-moviepy.video.fx.TimeSymmetrize "moviepy.video.fx.TimeSymmetrize")
() | Returns a clip that plays the current clip once forwards and then once backwards. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.rst.txt) --- # moviepy.video.fx.CrossFadeIn — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.CrossFadeIn[#](#module-moviepy.video.fx.CrossFadeIn "Permalink to this heading") ================================================================================================== _class_ moviepy.video.fx.CrossFadeIn.CrossFadeIn(_duration: float_)[\[source\]](../../_modules/moviepy/video/fx/CrossFadeIn.html#CrossFadeIn) [#](#moviepy.video.fx.CrossFadeIn.CrossFadeIn "Permalink to this definition") Makes the clip appear progressively, over `duration` seconds. Only works when the clip is included in a CompositeVideoClip. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/CrossFadeIn.html#CrossFadeIn.apply) [#](#moviepy.video.fx.CrossFadeIn.CrossFadeIn.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.CrossFadeIn.CrossFadeIn.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.CrossFadeIn.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.CrossFadeIn.rst.txt) --- # moviepy.video.fx.CrossFadeOut — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.CrossFadeOut[#](#module-moviepy.video.fx.CrossFadeOut "Permalink to this heading") ==================================================================================================== _class_ moviepy.video.fx.CrossFadeOut.CrossFadeOut(_duration: float_)[\[source\]](../../_modules/moviepy/video/fx/CrossFadeOut.html#CrossFadeOut) [#](#moviepy.video.fx.CrossFadeOut.CrossFadeOut "Permalink to this definition") Makes the clip disappear progressively, over `duration` seconds. Only works when the clip is included in a CompositeVideoClip. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/CrossFadeOut.html#CrossFadeOut.apply) [#](#moviepy.video.fx.CrossFadeOut.CrossFadeOut.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.CrossFadeOut.CrossFadeOut.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.CrossFadeOut.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.CrossFadeOut.rst.txt) --- # moviepy.video.fx.EvenSize — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.EvenSize[#](#module-moviepy.video.fx.EvenSize "Permalink to this heading") ============================================================================================ _class_ moviepy.video.fx.EvenSize.EvenSize[\[source\]](../../_modules/moviepy/video/fx/EvenSize.html#EvenSize) [#](#moviepy.video.fx.EvenSize.EvenSize "Permalink to this definition") Crops the clip to make dimensions even. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/EvenSize.html#EvenSize.apply) [#](#moviepy.video.fx.EvenSize.EvenSize.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.EvenSize.EvenSize.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.EvenSize.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.EvenSize.rst.txt) --- # moviepy.video.fx.FadeIn — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.FadeIn[#](#module-moviepy.video.fx.FadeIn "Permalink to this heading") ======================================================================================== _class_ moviepy.video.fx.FadeIn.FadeIn(_duration: float_, _initial\_color: list \= None_)[\[source\]](../../_modules/moviepy/video/fx/FadeIn.html#FadeIn) [#](#moviepy.video.fx.FadeIn.FadeIn "Permalink to this definition") Makes the clip progressively appear from some color (black by default), over `duration` seconds at the beginning of the clip. Can be used for masks too, where the initial color must be a number between 0 and 1. For cross-fading (progressive appearance or disappearance of a clip over another clip, see `CrossFadeIn` apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/FadeIn.html#FadeIn.apply) [#](#moviepy.video.fx.FadeIn.FadeIn.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.FadeIn.FadeIn.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.FadeIn.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.FadeIn.rst.txt) --- # moviepy.video.fx.FadeOut — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.FadeOut[#](#module-moviepy.video.fx.FadeOut "Permalink to this heading") ========================================================================================== _class_ moviepy.video.fx.FadeOut.FadeOut(_duration: float_, _final\_color: list \= None_)[\[source\]](../../_modules/moviepy/video/fx/FadeOut.html#FadeOut) [#](#moviepy.video.fx.FadeOut.FadeOut "Permalink to this definition") Makes the clip progressively fade to some color (black by default), over `duration` seconds at the end of the clip. Can be used for masks too, where the final color must be a number between 0 and 1. For cross-fading (progressive appearance or disappearance of a clip over another clip), see `CrossFadeOut` apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/FadeOut.html#FadeOut.apply) [#](#moviepy.video.fx.FadeOut.FadeOut.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.FadeOut.FadeOut.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.FadeOut.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.FadeOut.rst.txt) --- # moviepy.video.fx.FreezeRegion — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.FreezeRegion[#](#module-moviepy.video.fx.FreezeRegion "Permalink to this heading") ==================================================================================================== _class_ moviepy.video.fx.FreezeRegion.FreezeRegion(_t: float \= 0_, _region: tuple \= None_, _outside\_region: tuple \= None_, _mask: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") \= None_)[\[source\]](../../_modules/moviepy/video/fx/FreezeRegion.html#FreezeRegion) [#](#moviepy.video.fx.FreezeRegion.FreezeRegion "Permalink to this definition") Freezes one region of the clip while the rest remains animated. You can choose one of three methods by providing either region, outside\_region, or mask. Parameters: * **t** (_float_) – Time at which to freeze the freezed region. * **region** (_tuple_) – A tuple (x1, y1, x2, y2) defining the region of the screen (in pixels) which will be freezed. You can provide outside\_region or mask instead. * **outside\_region** (_tuple_) – A tuple (x1, y1, x2, y2) defining the region of the screen (in pixels) which will be the only non-freezed region. * **mask** ([_moviepy.Clip.Clip_](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") ) – If not None, will overlay a freezed version of the clip on the current clip, with the provided mask. In other words, the “visible” pixels in the mask indicate the freezed region in the final picture. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/FreezeRegion.html#FreezeRegion.apply) [#](#moviepy.video.fx.FreezeRegion.FreezeRegion.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.FreezeRegion.FreezeRegion.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.FreezeRegion.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.FreezeRegion.rst.txt) --- # moviepy.video.fx.Freeze — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.Freeze[#](#module-moviepy.video.fx.Freeze "Permalink to this heading") ======================================================================================== _class_ moviepy.video.fx.Freeze.Freeze(_t: float \= 0_, _freeze\_duration: float \= None_, _total\_duration: float \= None_, _padding\_end: float \= 0_, _update\_start\_end: bool \= True_)[\[source\]](../../_modules/moviepy/video/fx/Freeze.html#Freeze) [#](#moviepy.video.fx.Freeze.Freeze "Permalink to this definition") Momentarily freeze the clip at time t. Set t=’end’ to freeze the clip at the end (actually it will freeze on the frame at time clip.duration - padding\_end seconds - 1 / clip\_fps). With `duration` you can specify the duration of the freeze. With `total_duration` you can specify the total duration of the clip and the freeze (i.e. the duration of the freeze is automatically computed). One of them must be provided. With `update_start_end` you can define if the effect must preserve and/or update start and end properties of the original clip apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/Freeze.html#Freeze.apply) [#](#moviepy.video.fx.Freeze.Freeze.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.Freeze.Freeze.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.Freeze.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.Freeze.rst.txt) --- # moviepy.video.fx.HeadBlur — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.HeadBlur[#](#module-moviepy.video.fx.HeadBlur "Permalink to this heading") ============================================================================================ _class_ moviepy.video.fx.HeadBlur.HeadBlur(_fx: callable_, _fy: callable_, _radius: float_, _intensity: float \= None_)[\[source\]](../../_modules/moviepy/video/fx/HeadBlur.html#HeadBlur) [#](#moviepy.video.fx.HeadBlur.HeadBlur "Permalink to this definition") Returns a filter that will blur a moving part (a head ?) of the frames. The position of the blur at time t is defined by (fx(t), fy(t)), the radius of the blurring by `radius` and the intensity of the blurring by `intensity`. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/HeadBlur.html#HeadBlur.apply) [#](#moviepy.video.fx.HeadBlur.HeadBlur.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.HeadBlur.HeadBlur.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.HeadBlur.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.HeadBlur.rst.txt) --- # moviepy.video.fx.GammaCorrection — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.GammaCorrection[#](#module-moviepy.video.fx.GammaCorrection "Permalink to this heading") ========================================================================================================== _class_ moviepy.video.fx.GammaCorrection.GammaCorrection(_gamma: float_)[\[source\]](../../_modules/moviepy/video/fx/GammaCorrection.html#GammaCorrection) [#](#moviepy.video.fx.GammaCorrection.GammaCorrection "Permalink to this definition") Gamma-correction of a video clip. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/GammaCorrection.html#GammaCorrection.apply) [#](#moviepy.video.fx.GammaCorrection.GammaCorrection.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.GammaCorrection.GammaCorrection.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.GammaCorrection.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.GammaCorrection.rst.txt) --- # moviepy.video.fx.InvertColors — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.InvertColors[#](#module-moviepy.video.fx.InvertColors "Permalink to this heading") ==================================================================================================== _class_ moviepy.video.fx.InvertColors.InvertColors[\[source\]](../../_modules/moviepy/video/fx/InvertColors.html#InvertColors) [#](#moviepy.video.fx.InvertColors.InvertColors "Permalink to this definition") Returns the color-inversed clip. The values of all pixels are replaced with (255-v) or (1-v) for masks Black becomes white, green becomes purple, etc. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/InvertColors.html#InvertColors.apply) [#](#moviepy.video.fx.InvertColors.InvertColors.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.InvertColors.InvertColors.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.InvertColors.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.InvertColors.rst.txt) --- # moviepy.video.fx.Loop — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.Loop[#](#module-moviepy.video.fx.Loop "Permalink to this heading") ==================================================================================== _class_ moviepy.video.fx.Loop.Loop(_n: int \= None_, _duration: float \= None_)[\[source\]](../../_modules/moviepy/video/fx/Loop.html#Loop) [#](#moviepy.video.fx.Loop.Loop "Permalink to this definition") Returns a clip that plays the current clip in an infinite loop. Ideal for clips coming from GIFs. Parameters: * **n** (_int_) – Number of times the clip should be played. If None the the clip will loop indefinitely (i.e. with no set duration). * **duration** (_float_) – Total duration of the clip. Can be specified instead of n. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/Loop.html#Loop.apply) [#](#moviepy.video.fx.Loop.Loop.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.Loop.Loop.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.Loop.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.Loop.rst.txt) --- # moviepy.video.fx.LumContrast — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.LumContrast[#](#module-moviepy.video.fx.LumContrast "Permalink to this heading") ================================================================================================== _class_ moviepy.video.fx.LumContrast.LumContrast(_lum: float \= 0_, _contrast: float \= 0_, _contrast\_threshold: float \= 127_)[\[source\]](../../_modules/moviepy/video/fx/LumContrast.html#LumContrast) [#](#moviepy.video.fx.LumContrast.LumContrast "Permalink to this definition") Luminosity-contrast correction of a clip. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/LumContrast.html#LumContrast.apply) [#](#moviepy.video.fx.LumContrast.LumContrast.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.LumContrast.LumContrast.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.LumContrast.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.LumContrast.rst.txt) --- # moviepy.video.fx.MaskColor — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.MaskColor[#](#module-moviepy.video.fx.MaskColor "Permalink to this heading") ============================================================================================== _class_ moviepy.video.fx.MaskColor.MaskColor(_color: tuple \= (0, 0, 0)_, _threshold: float \= 0_, _stiffness: float \= 1_)[\[source\]](../../_modules/moviepy/video/fx/MaskColor.html#MaskColor) [#](#moviepy.video.fx.MaskColor.MaskColor "Permalink to this definition") Returns a new clip with a mask for transparency where the original clip is of the given color. You can also have a “progressive” mask by specifying a non-null distance threshold `threshold`. In this case, if the distance between a pixel and the given color is d, the transparency will be d\*\*stiffness / (threshold\*\*stiffness + d\*\*stiffness) which is 1 when d>>threshold and 0 for d<>> new\_clip \= clip.with\_mask().rotate(72) Parameters: * **clip** ([_VideoClip_](moviepy.video.VideoClip.VideoClip.html#moviepy.video.VideoClip.VideoClip "moviepy.video.VideoClip.VideoClip") ) – * **clip.** (_A video_) – * **angle** (_float_) – * **rotation.** (_Either a value_ _or_ _a function angle__(__t__)_ _representing the angle of_) – * **unit** (_str__,_ _optional_) – * **radians****)****.** (_Unit_ _of_ _parameter angle_ _(__either "deg" for degrees_ _or_ _"rad" for_) – * **resample** (_str__,_ _optional_) – * **"nearest"** (_An optional resampling filter. One of_) – * **"bilinear"** – * **"bicubic".** (_or_) – * **expand** (_bool__,_ _optional_) – * **true** (_If_) – * **the** (_expands the output image to make it large enough to hold_) – * **omitted** (_entire rotated image. If false or_) – * **same** (_make the output image the_) – * **image.** (_size as the input_) – * **translate** (_tuple__,_ _optional_) – * **2-tuple****)****.** (_An optional post-rotate translation_ _(__a_) – * **center** (_tuple__,_ _optional_) – * **corner.** (_Optional center_ _of_ _rotation_ _(__a 2-tuple__)__. Origin is the upper left_) – * **bg\_color** (_tuple__,_ _optional_) – * **if** (_An optional color for area outside the rotated image. Only has effect_) – * **true.** (_expand is_) – apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/Rotate.html#Rotate.apply) [#](#moviepy.video.fx.Rotate.Rotate.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.Rotate.Rotate.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.Rotate.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.Rotate.rst.txt) --- # moviepy.video.fx.Painting — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.Painting[#](#module-moviepy.video.fx.Painting "Permalink to this heading") ============================================================================================ _class_ moviepy.video.fx.Painting.Painting(_saturation: float \= 1.4_, _black: float \= 0.006_)[\[source\]](../../_modules/moviepy/video/fx/Painting.html#Painting) [#](#moviepy.video.fx.Painting.Painting "Permalink to this definition") Transforms any photo into some kind of painting. Transforms any photo into some kind of painting. Saturation tells at which point the colors of the result should be flashy. `black` gives the amount of black lines wanted. np\_image : a numpy image apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/Painting.html#Painting.apply) [#](#moviepy.video.fx.Painting.Painting.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.Painting.Painting.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. to\_painting(_np\_image_, _saturation\=1.4_, _black\=0.006_)[\[source\]](../../_modules/moviepy/video/fx/Painting.html#Painting.to_painting) [#](#moviepy.video.fx.Painting.Painting.to_painting "Permalink to this definition") Transforms any photo into some kind of painting. Transforms any photo into some kind of painting. Saturation tells at which point the colors of the result should be flashy. `black` gives the amount of black lines wanted. np\_image : a numpy image On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.Painting.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.Painting.rst.txt) --- # moviepy.video.fx.SlideIn — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.SlideIn[#](#module-moviepy.video.fx.SlideIn "Permalink to this heading") ========================================================================================== _class_ moviepy.video.fx.SlideIn.SlideIn(_duration: float_, _side: str_)[\[source\]](../../_modules/moviepy/video/fx/SlideIn.html#SlideIn) [#](#moviepy.video.fx.SlideIn.SlideIn "Permalink to this definition") Makes the clip arrive from one side of the screen. Only works when the clip is included in a CompositeVideoClip, and if the clip has the same size as the whole composition. Parameters: * **clip** ([_moviepy.Clip.Clip_](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") ) – A video clip. * **duration** (_float_) – Time taken for the clip to be fully visible * **side** (_str_) – Side of the screen where the clip comes from. One of ‘top’, ‘bottom’, ‘left’ or ‘right’. Examples from moviepy import \* clips \= \[... make a list of clips\] slided\_clips \= \[\ CompositeVideoClip(\[clip.with\_effects(\[vfx.SlideIn(1, "left")\])\])\ for clip in clips\ \] final\_clip \= concatenate\_videoclips(slided\_clips, padding\=-1) clip \= ColorClip( color\=(255, 0, 0), duration\=1, size\=(300, 300) ).with\_fps(60) final\_clip \= CompositeVideoClip(\[clip.with\_effects(\[vfx.SlideIn(1, "right")\])\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/SlideIn.html#SlideIn.apply) [#](#moviepy.video.fx.SlideIn.SlideIn.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.SlideIn.SlideIn.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.SlideIn.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.SlideIn.rst.txt) --- # moviepy.video.fx.SlideOut — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.SlideOut[#](#module-moviepy.video.fx.SlideOut "Permalink to this heading") ============================================================================================ _class_ moviepy.video.fx.SlideOut.SlideOut(_duration: float_, _side: str_)[\[source\]](../../_modules/moviepy/video/fx/SlideOut.html#SlideOut) [#](#moviepy.video.fx.SlideOut.SlideOut "Permalink to this definition") Makes the clip goes away by one side of the screen. Only works when the clip is included in a CompositeVideoClip, and if the clip has the same size as the whole composition. Parameters: * **clip** ([_moviepy.Clip.Clip_](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") ) – A video clip. * **duration** (_float_) – Time taken for the clip to be fully visible * **side** (_str_) – Side of the screen where the clip goes. One of ‘top’, ‘bottom’, ‘left’ or ‘right’. Examples from moviepy import \* clips \= \[... make a list of clips\] slided\_clips \= \[\ CompositeVideoClip(\[clip.with\_effects(\[vfx.SlideOut(1, "left")\])\])\ for clip in clips\ \] final\_clip \= concatenate\_videoclips(slided\_clips, padding\=-1) clip \= ColorClip( color\=(255, 0, 0), duration\=1, size\=(300, 300) ).with\_fps(60) final\_clip \= CompositeVideoClip(\[clip.with\_effects(\[vfx.SlideOut(1, "right")\])\]) apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/SlideOut.html#SlideOut.apply) [#](#moviepy.video.fx.SlideOut.SlideOut.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.SlideOut.SlideOut.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.SlideOut.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.SlideOut.rst.txt) --- # moviepy.video.io — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io[#](#module-moviepy.video.io "Permalink to this heading") ========================================================================== Classes and methods for reading, writing and previewing video files. Modules | | | | --- | --- | | [`moviepy.video.io.ImageSequenceClip`](moviepy.video.io.ImageSequenceClip.html#module-moviepy.video.io.ImageSequenceClip "moviepy.video.io.ImageSequenceClip") | Implements ImageSequenceClip, a class to create a video clip from a set of image files. | | [`moviepy.video.io.VideoFileClip`](moviepy.video.io.VideoFileClip.html#module-moviepy.video.io.VideoFileClip "moviepy.video.io.VideoFileClip") | Implements VideoFileClip, a class for video clips creation using video files. | | [`moviepy.video.io.display_in_notebook`](moviepy.video.io.display_in_notebook.html#module-moviepy.video.io.display_in_notebook "moviepy.video.io.display_in_notebook") | Implements `display_in_notebook`, a function to embed images/videos/audio in the Jupyter Notebook. | | [`moviepy.video.io.ffmpeg_reader`](moviepy.video.io.ffmpeg_reader.html#module-moviepy.video.io.ffmpeg_reader "moviepy.video.io.ffmpeg_reader") | Implements all the functions to read a video or a picture using ffmpeg. | | [`moviepy.video.io.ffmpeg_tools`](moviepy.video.io.ffmpeg_tools.html#module-moviepy.video.io.ffmpeg_tools "moviepy.video.io.ffmpeg_tools") | Miscellaneous bindings to ffmpeg. | | [`moviepy.video.io.ffmpeg_writer`](moviepy.video.io.ffmpeg_writer.html#module-moviepy.video.io.ffmpeg_writer "moviepy.video.io.ffmpeg_writer") | On the long term this will implement several methods to make videos out of VideoClips | | [`moviepy.video.io.ffplay_previewer`](moviepy.video.io.ffplay_previewer.html#module-moviepy.video.io.ffplay_previewer "moviepy.video.io.ffplay_previewer") | On the long term this will implement several methods to make videos out of VideoClips | | [`moviepy.video.io.gif_writers`](moviepy.video.io.gif_writers.html#module-moviepy.video.io.gif_writers "moviepy.video.io.gif_writers") | MoviePy video GIFs writing. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.rst.txt) --- # moviepy.video.fx.SuperSample — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.SuperSample[#](#module-moviepy.video.fx.SuperSample "Permalink to this heading") ================================================================================================== _class_ moviepy.video.fx.SuperSample.SuperSample(_d: float_, _n\_frames: int_)[\[source\]](../../_modules/moviepy/video/fx/SuperSample.html#SuperSample) [#](#moviepy.video.fx.SuperSample.SuperSample "Permalink to this definition") Replaces each frame at time t by the mean of n\_frames equally spaced frames taken in the interval \[t-d, t+d\]. This results in motion blur. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/SuperSample.html#SuperSample.apply) [#](#moviepy.video.fx.SuperSample.SuperSample.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.SuperSample.SuperSample.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.SuperSample.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.SuperSample.rst.txt) --- # moviepy.video.fx.TimeSymmetrize — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.TimeSymmetrize[#](#module-moviepy.video.fx.TimeSymmetrize "Permalink to this heading") ======================================================================================================== _class_ moviepy.video.fx.TimeSymmetrize.TimeSymmetrize[\[source\]](../../_modules/moviepy/video/fx/TimeSymmetrize.html#TimeSymmetrize) [#](#moviepy.video.fx.TimeSymmetrize.TimeSymmetrize "Permalink to this definition") Returns a clip that plays the current clip once forwards and then once backwards. This is very practival to make video that loop well, e.g. to create animated GIFs. This effect is automatically applied to the clip’s mask and audio if they exist. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/TimeSymmetrize.html#TimeSymmetrize.apply) [#](#moviepy.video.fx.TimeSymmetrize.TimeSymmetrize.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.TimeSymmetrize.TimeSymmetrize.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.TimeSymmetrize.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.TimeSymmetrize.rst.txt) --- # moviepy.video.fx.TimeMirror — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.fx.TimeMirror[#](#module-moviepy.video.fx.TimeMirror "Permalink to this heading") ================================================================================================ _class_ moviepy.video.fx.TimeMirror.TimeMirror[\[source\]](../../_modules/moviepy/video/fx/TimeMirror.html#TimeMirror) [#](#moviepy.video.fx.TimeMirror.TimeMirror "Permalink to this definition") 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. apply(_clip: [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") _) → [Clip](moviepy.Clip.Clip.html#moviepy.Clip.Clip "moviepy.Clip.Clip") [\[source\]](../../_modules/moviepy/video/fx/TimeMirror.html#TimeMirror.apply) [#](#moviepy.video.fx.TimeMirror.TimeMirror.apply "Permalink to this definition") Apply the effect to the clip. copy()[#](#moviepy.video.fx.TimeMirror.TimeMirror.copy "Permalink to this definition") Return a shallow copy of an Effect. 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 could lead to different properties, and different results for equivalent clips. By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result. In a way, copy makes the effect himself being kind of idempotent. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.fx.TimeMirror.rst) [Show Source](../../_sources/reference/reference/moviepy.video.fx.TimeMirror.rst.txt) --- # moviepy.video.io.ImageSequenceClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.ImageSequenceClip[#](#module-moviepy.video.io.ImageSequenceClip "Permalink to this heading") ============================================================================================================== Implements ImageSequenceClip, a class to create a video clip from a set of image files. Classes | | | | --- | --- | | [`ImageSequenceClip`](moviepy.video.io.ImageSequenceClip.ImageSequenceClip.html#moviepy.video.io.ImageSequenceClip.ImageSequenceClip "moviepy.video.io.ImageSequenceClip.ImageSequenceClip")
(sequence\[, fps, ...\]) | A VideoClip made from a series of images. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.ImageSequenceClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.ImageSequenceClip.rst.txt) --- # moviepy.video.io.VideoFileClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.VideoFileClip[#](#module-moviepy.video.io.VideoFileClip "Permalink to this heading") ====================================================================================================== Implements VideoFileClip, a class for video clips creation using video files. Classes | | | | --- | --- | | [`VideoFileClip`](moviepy.video.io.VideoFileClip.VideoFileClip.html#moviepy.video.io.VideoFileClip.VideoFileClip "moviepy.video.io.VideoFileClip.VideoFileClip")
(filename\[, decode\_file, ...\]) | A video clip originating from a movie file. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.VideoFileClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.VideoFileClip.rst.txt) --- # moviepy.video.io.display_in_notebook — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.display\_in\_notebook[#](#module-moviepy.video.io.display_in_notebook "Permalink to this heading") ==================================================================================================================== Implements `display_in_notebook`, a function to embed images/videos/audio in the Jupyter Notebook. Functions | | | | --- | --- | | [`HTML2`](moviepy.video.io.display_in_notebook.HTML2.html#moviepy.video.io.display_in_notebook.HTML2 "moviepy.video.io.display_in_notebook.HTML2")
(content) | | | [`display_in_notebook`](moviepy.video.io.display_in_notebook.display_in_notebook.html#moviepy.video.io.display_in_notebook.display_in_notebook "moviepy.video.io.display_in_notebook.display_in_notebook")
(clip\[, filetype, ...\]) | Displays clip content in an Jupyter Notebook. | | [`html_embed`](moviepy.video.io.display_in_notebook.html_embed.html#moviepy.video.io.display_in_notebook.html_embed "moviepy.video.io.display_in_notebook.html_embed")
(clip\[, filetype, maxduration, ...\]) | Returns HTML5 code embedding the clip. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.display_in_notebook.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.display_in_notebook.rst.txt) --- # moviepy.video.io.ffmpeg_reader — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.ffmpeg\_reader[#](#module-moviepy.video.io.ffmpeg_reader "Permalink to this heading") ======================================================================================================= Implements all the functions to read a video or a picture using ffmpeg. Classes | | | | --- | --- | | [`FFMPEG_VideoReader`](moviepy.video.io.ffmpeg_reader.FFMPEG_VideoReader.html#moviepy.video.io.ffmpeg_reader.FFMPEG_VideoReader "moviepy.video.io.ffmpeg_reader.FFMPEG_VideoReader")
(filename\[, decode\_file, ...\]) | Class for video byte-level reading with ffmpeg. | | [`FFmpegInfosParser`](moviepy.video.io.ffmpeg_reader.FFmpegInfosParser.html#moviepy.video.io.ffmpeg_reader.FFmpegInfosParser "moviepy.video.io.ffmpeg_reader.FFmpegInfosParser")
(infos, filename\[, ...\]) | Finite state ffmpeg \-i command option file information parser. | Functions | | | | --- | --- | | [`ffmpeg_parse_infos`](moviepy.video.io.ffmpeg_reader.ffmpeg_parse_infos.html#moviepy.video.io.ffmpeg_reader.ffmpeg_parse_infos "moviepy.video.io.ffmpeg_reader.ffmpeg_parse_infos")
(filename\[, ...\]) | Get the information of a file using ffmpeg. | | [`ffmpeg_read_image`](moviepy.video.io.ffmpeg_reader.ffmpeg_read_image.html#moviepy.video.io.ffmpeg_reader.ffmpeg_read_image "moviepy.video.io.ffmpeg_reader.ffmpeg_read_image")
(filename\[, with\_mask, ...\]) | Read an image file (PNG, BMP, JPEG...). | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.ffmpeg_reader.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.ffmpeg_reader.rst.txt) --- # moviepy.video.io.ffmpeg_tools — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.ffmpeg\_tools[#](#module-moviepy.video.io.ffmpeg_tools "Permalink to this heading") ===================================================================================================== Miscellaneous bindings to ffmpeg. Functions | | | | --- | --- | | [`ffmpeg_extract_audio`](moviepy.video.io.ffmpeg_tools.ffmpeg_extract_audio.html#moviepy.video.io.ffmpeg_tools.ffmpeg_extract_audio "moviepy.video.io.ffmpeg_tools.ffmpeg_extract_audio")
(inputfile, outputfile) | Extract the sound from a video file and save it in `outputfile`. | | [`ffmpeg_extract_subclip`](moviepy.video.io.ffmpeg_tools.ffmpeg_extract_subclip.html#moviepy.video.io.ffmpeg_tools.ffmpeg_extract_subclip "moviepy.video.io.ffmpeg_tools.ffmpeg_extract_subclip")
(inputfile, ...\[, ...\]) | Makes a new video file playing video file between two times. | | [`ffmpeg_merge_video_audio`](moviepy.video.io.ffmpeg_tools.ffmpeg_merge_video_audio.html#moviepy.video.io.ffmpeg_tools.ffmpeg_merge_video_audio "moviepy.video.io.ffmpeg_tools.ffmpeg_merge_video_audio")
(videofile, ...\[, ...\]) | Merges video file and audio file into one movie file. | | [`ffmpeg_resize`](moviepy.video.io.ffmpeg_tools.ffmpeg_resize.html#moviepy.video.io.ffmpeg_tools.ffmpeg_resize "moviepy.video.io.ffmpeg_tools.ffmpeg_resize")
(inputfile, outputfile, size\[, ...\]) | Resizes a file to new size and write the result in another. | | [`ffmpeg_stabilize_video`](moviepy.video.io.ffmpeg_tools.ffmpeg_stabilize_video.html#moviepy.video.io.ffmpeg_tools.ffmpeg_stabilize_video "moviepy.video.io.ffmpeg_tools.ffmpeg_stabilize_video")
(inputfile\[, ...\]) | Stabilizes `filename` and write the result to `output`. | | [`ffmpeg_version`](moviepy.video.io.ffmpeg_tools.ffmpeg_version.html#moviepy.video.io.ffmpeg_tools.ffmpeg_version "moviepy.video.io.ffmpeg_tools.ffmpeg_version")
() | Retrieve the FFmpeg version. | | [`ffplay_version`](moviepy.video.io.ffmpeg_tools.ffplay_version.html#moviepy.video.io.ffmpeg_tools.ffplay_version "moviepy.video.io.ffmpeg_tools.ffplay_version")
() | Retrieve the FFplay version. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.ffmpeg_tools.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.ffmpeg_tools.rst.txt) --- # moviepy.video.io.ffmpeg_writer — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.ffmpeg\_writer[#](#module-moviepy.video.io.ffmpeg_writer "Permalink to this heading") ======================================================================================================= On the long term this will implement several methods to make videos out of VideoClips Classes | | | | --- | --- | | [`FFMPEG_VideoWriter`](moviepy.video.io.ffmpeg_writer.FFMPEG_VideoWriter.html#moviepy.video.io.ffmpeg_writer.FFMPEG_VideoWriter "moviepy.video.io.ffmpeg_writer.FFMPEG_VideoWriter")
(filename, size, fps\[, ...\]) | A class for FFMPEG-based video writing. | Functions | | | | --- | --- | | [`ffmpeg_write_image`](moviepy.video.io.ffmpeg_writer.ffmpeg_write_image.html#moviepy.video.io.ffmpeg_writer.ffmpeg_write_image "moviepy.video.io.ffmpeg_writer.ffmpeg_write_image")
(filename, image\[, ...\]) | Writes an image (HxWx3 or HxWx4 numpy array) to a file, using ffmpeg. | | [`ffmpeg_write_video`](moviepy.video.io.ffmpeg_writer.ffmpeg_write_video.html#moviepy.video.io.ffmpeg_writer.ffmpeg_write_video "moviepy.video.io.ffmpeg_writer.ffmpeg_write_video")
(clip, filename, fps\[, ...\]) | Write the clip to a videofile. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.ffmpeg_writer.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.ffmpeg_writer.rst.txt) --- # moviepy.video.io.ffplay_previewer — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.ffplay\_previewer[#](#module-moviepy.video.io.ffplay_previewer "Permalink to this heading") ============================================================================================================= On the long term this will implement several methods to make videos out of VideoClips Classes | | | | --- | --- | | [`FFPLAY_VideoPreviewer`](moviepy.video.io.ffplay_previewer.FFPLAY_VideoPreviewer.html#moviepy.video.io.ffplay_previewer.FFPLAY_VideoPreviewer "moviepy.video.io.ffplay_previewer.FFPLAY_VideoPreviewer")
(size, fps, pixel\_format) | A class for FFPLAY-based video preview. | Functions | | | | --- | --- | | [`ffplay_preview_video`](moviepy.video.io.ffplay_previewer.ffplay_preview_video.html#moviepy.video.io.ffplay_previewer.ffplay_preview_video "moviepy.video.io.ffplay_previewer.ffplay_preview_video")
(clip, fps\[, ...\]) | Preview the clip using ffplay. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.ffplay_previewer.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.ffplay_previewer.rst.txt) --- # moviepy.video.io.gif_writers — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.gif\_writers[#](#module-moviepy.video.io.gif_writers "Permalink to this heading") =================================================================================================== MoviePy video GIFs writing. Functions | | | | --- | --- | | [`write_gif_with_imageio`](moviepy.video.io.gif_writers.write_gif_with_imageio.html#moviepy.video.io.gif_writers.write_gif_with_imageio "moviepy.video.io.gif_writers.write_gif_with_imageio")
(clip, filename\[, ...\]) | Writes the gif with the Python library ImageIO (calls FreeImage). | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.gif_writers.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.gif_writers.rst.txt) --- # moviepy.video.tools — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools[#](#module-moviepy.video.tools "Permalink to this heading") ================================================================================ Modules | | | | --- | --- | | [`moviepy.video.tools.credits`](moviepy.video.tools.credits.html#module-moviepy.video.tools.credits "moviepy.video.tools.credits") | Contains different functions to make end and opening credits, even though it is difficult to fill everyone needs in this matter. | | [`moviepy.video.tools.cuts`](moviepy.video.tools.cuts.html#module-moviepy.video.tools.cuts "moviepy.video.tools.cuts") | Contains everything that can help automate the cuts in MoviePy. | | [`moviepy.video.tools.drawing`](moviepy.video.tools.drawing.html#module-moviepy.video.tools.drawing "moviepy.video.tools.drawing") | Deals with making images (np arrays). | | [`moviepy.video.tools.interpolators`](moviepy.video.tools.interpolators.html#module-moviepy.video.tools.interpolators "moviepy.video.tools.interpolators") | Classes for easy interpolation of trajectories and curves. | | [`moviepy.video.tools.subtitles`](moviepy.video.tools.subtitles.html#module-moviepy.video.tools.subtitles "moviepy.video.tools.subtitles") | Experimental module for subtitles support. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.rst.txt) --- # moviepy.video.tools.credits — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.credits[#](#module-moviepy.video.tools.credits "Permalink to this heading") ================================================================================================ Contains different functions to make end and opening credits, even though it is difficult to fill everyone needs in this matter. Classes | | | | --- | --- | | [`CreditsClip`](moviepy.video.tools.credits.CreditsClip.html#moviepy.video.tools.credits.CreditsClip "moviepy.video.tools.credits.CreditsClip")
(creditfile, width\[, color, ...\]) | Credits clip. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.credits.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.credits.rst.txt) --- # moviepy.video.tools.cuts — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.cuts[#](#module-moviepy.video.tools.cuts "Permalink to this heading") ========================================================================================== Contains everything that can help automate the cuts in MoviePy. Classes | | | | --- | --- | | [`FramesMatch`](moviepy.video.tools.cuts.FramesMatch.html#moviepy.video.tools.cuts.FramesMatch "moviepy.video.tools.cuts.FramesMatch")
(start\_time, end\_time, ...) | Frames match inside a set of frames. | | [`FramesMatches`](moviepy.video.tools.cuts.FramesMatches.html#moviepy.video.tools.cuts.FramesMatches "moviepy.video.tools.cuts.FramesMatches")
(lst) | Frames matches inside a set of frames. | Functions | | | | --- | --- | | [`detect_scenes`](moviepy.video.tools.cuts.detect_scenes.html#moviepy.video.tools.cuts.detect_scenes "moviepy.video.tools.cuts.detect_scenes")
(\[clip, luminosities, ...\]) | Detects scenes of a clip based on luminosity changes. | | [`find_video_period`](moviepy.video.tools.cuts.find_video_period.html#moviepy.video.tools.cuts.find_video_period "moviepy.video.tools.cuts.find_video_period")
(clip\[, fps, start\_time\]) | Find the period of a video based on frames correlation. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.cuts.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.cuts.rst.txt) --- # moviepy.video.tools.drawing — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.drawing[#](#module-moviepy.video.tools.drawing "Permalink to this heading") ================================================================================================ Deals with making images (np arrays). It provides drawing methods that are difficult to do with the existing Python libraries. Functions | | | | --- | --- | | [`circle`](moviepy.video.tools.drawing.circle.html#moviepy.video.tools.drawing.circle "moviepy.video.tools.drawing.circle")
(screensize, center, radius\[, color, ...\]) | Draw an image with a circle. | | [`color_gradient`](moviepy.video.tools.drawing.color_gradient.html#moviepy.video.tools.drawing.color_gradient "moviepy.video.tools.drawing.color_gradient")
(size, p1\[, p2, vector, ...\]) | Draw a linear, bilinear, or radial gradient. | | [`color_split`](moviepy.video.tools.drawing.color_split.html#moviepy.video.tools.drawing.color_split "moviepy.video.tools.drawing.color_split")
(size\[, x, y, p1, p2, vector, ...\]) | Make an image split in 2 colored regions. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.drawing.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.drawing.rst.txt) --- # moviepy.video.tools.interpolators — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.interpolators[#](#module-moviepy.video.tools.interpolators "Permalink to this heading") ============================================================================================================ Classes for easy interpolation of trajectories and curves. Classes | | | | --- | --- | | [`Interpolator`](moviepy.video.tools.interpolators.Interpolator.html#moviepy.video.tools.interpolators.Interpolator "moviepy.video.tools.interpolators.Interpolator")
(\[tt, ss, ttss, left, right\]) | Poorman's linear interpolator. | | [`Trajectory`](moviepy.video.tools.interpolators.Trajectory.html#moviepy.video.tools.interpolators.Trajectory "moviepy.video.tools.interpolators.Trajectory")
(tt, xx, yy) | Trajectory compound by time frames and (x, y) pixels. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.interpolators.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.interpolators.rst.txt) --- # moviepy.video.tools.subtitles — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.subtitles[#](#module-moviepy.video.tools.subtitles "Permalink to this heading") ==================================================================================================== Experimental module for subtitles support. Classes | | | | --- | --- | | [`SubtitlesClip`](moviepy.video.tools.subtitles.SubtitlesClip.html#moviepy.video.tools.subtitles.SubtitlesClip "moviepy.video.tools.subtitles.SubtitlesClip")
(subtitles\[, font, ...\]) | A Clip that serves as "subtitle track" in videos. | Functions | | | | --- | --- | | [`file_to_subtitles`](moviepy.video.tools.subtitles.file_to_subtitles.html#moviepy.video.tools.subtitles.file_to_subtitles "moviepy.video.tools.subtitles.file_to_subtitles")
(filename\[, encoding\]) | Converts a srt file into subtitles. | [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.subtitles.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.subtitles.rst.txt) --- # Unknown .. \_reference\_manual: Api Reference ================ This is the definitive place to find all the details on MoviePy API documentation. For a more beginner introduction, please see :ref:\`getting\_started\`, for a more detailed explanations of the different concepts in MoviePy, see :ref:\`user\_guide\`. .. autosummary:: :toctree: reference :recursive: :template: custom\_autosummary/module.rst moviepy --- # Unknown .. \_loading: Loading resources as clips =================================== The first step for making a video with MoviePy is to load the resources you wish to include in the final video. In this section we present the different sorts of clips and how to load them. For information on modifying a clip, see :ref:\`modifying\`. For how to put clips together see :ref:\`compositing\`. And for how to see/save theme, see :ref:\`rendering\` (we will usually save them in example, but we wont explain here). There's a lot of different resources you can use with MoviePy, and you will load different resources with different subtypes of :py:class:\`~moviepy.Clip.Clip\`, and more precisely of :py:class:\`~moviepy.audio.AudioClip.AudioClip\` for any audio element, or :py:class:\`~moviepy.video.VideoClip.VideoClip\` for any visual element. The following code summarizes the base clips that you can create with moviepy: .. literalinclude:: /\_static/code/user\_guide/loading/loading.py :language: python The best to understand all these clips more thoroughly is to read the full documentation for each in the :ref:\`reference\_manual\`. Releasing resources by closing a clip --------------------------------------- When you create some types of clip instances - e.g. \`\`VideoFileClip\`\` or \`\`AudioFileClip\`\` - MoviePy creates a subprocess and locks the file. In order to release these resources when you are finished you should call the \`\`close()\`\` method. This is more important for more complex applications and is particularly important when running on Windows. While Python's garbage collector should eventually clean up the resources for you, closing them makes them available earlier. However, if you close a clip too early, methods on the clip (and any clips derived from it) become unsafe. So, the rules of thumb are: \* Call \`\`close()\`\` on any clip that you \*\*construct\*\* once you have finished using it and have also finished using any clip that was derived from it. \* Even if you close a :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\` instance, you still need to close the clips it was created from. \* Otherwise, if you have a clip that was created by deriving it from from another clip (e.g. by calling \`\`with\_mask()\`\`), then generally you shouldn't close it. Closing the original clip will also close the copy. Clips act as \`context managers \`\_. This means you can use them with a \`\`with\`\` statement, and they will automatically be closed at the end of the block, even if there is an exception. .. literalinclude:: /\_static/code/user\_guide/loading/closing.py :language: python Categories of video clips -------------------------- Video clips are the building blocks of longer videos. Technically, they are clips with a \`\`clip.get\_frame(t)\`\` method which outputs a \`\`HxWx3\`\` numpy array representing the frame of the clip at time \`\`t\`\`. There are two main type of video clips: \* animated clips (made with :py:class:\`~moviepy.video.VideoClip.VideoFileClip\`, :py:class:\`~moviepy.video.VideoClip.VideoClip\` and :py:class:\`~moviepy.video.io.ImageSequenceClip.ImageSequenceClip\`), which will always have duration. \* unanimated clips (made with :py:class:\`~moviepy.video.VideoClip.ImageClip\`, :py:class:\`~moviepy.video.VideoClip\`TextClip\` and :py:class:\`~moviepy.video.VideoClip.ColorClip\`), which show the same picture for an a-priori infinite duration. There are also special video clips called masks, which belong to the categories above but output greyscale frames indicating which parts of another clip are visible or not. A video clip can carry around an audio clip (:py:class:\`~moviepy.audio.AudioClip.AudioClip\`) in :py:attr:\`~moviepy.video.VideoClip.VideoClip.audio\` which is its \*soundtrack\*, and a mask clip in :py:attr:\`~moviepy.video.VideoClip.VideoClip.mask\`. Animated clips ~~~~~~~~~~~~~~~ These are clips whose image will change over time, and which have a duration and a number of Frames Per Second. VideoClip """""""""" :py:class:\`~moviepy.video.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 \`\`frame\_function(t)\`\` which returns a \`HxWx3\` numpy array (of 8-bits integers) representing the frame at time \`\`t\`\`. Here is an example where we will create a pulsating red circle with graphical library \`pillow \`\_. .. literalinclude:: /\_static/code/user\_guide/loading/VideoClip.py :language: python Resulting in this. .. image:: /\_static/medias/user\_guide/circle.gif :width: 128 px :align: center :alt: A pulsating red circle on black background. .. note:: Clips that are made with a \`\`frame\_function\`\` do not have an explicit frame rate nor duration by default, so you must provide duration at clip creation and a frame rate (\`\`fps\`\`, frames per second) for :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_gif\` and :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_videofile\`, and more generally for any methods that requires iterating through the frames. For more, see :py:class:\`~moviepy.video.VideoClip.VideoClip\`. VideoFileClip """"""""""""""" A :py:class:\`~moviepy.video.io.VideoFileClip.VideoFileClip\` is a clip read from a video file (most formats are supported) or a GIF file. This is probably one of the most used object ! You load the video as follows: .. literalinclude:: /\_static/code/user\_guide/loading/VideoFileClip.py :language: python .. note:: These clips will have an \`\`fps\`\` (frame per second) and \`\`duration\`\` attributes, which will be transmitted if you do small modifications of the clip, and will be used by default in :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_gif\`, :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_videofile\`, etc. For more, see :py:class:\`~moviepy.video.io.VideoFileClip.VideoFileClip\`. ImageSequenceClip """""""""""""""""" This :py:class:\`~moviepy.video.io.ImageSequenceClip.ImageSequenceClip\` is a clip made from a series of images : .. literalinclude:: /\_static/code/user\_guide/loading/ImageSequenceClip.py :language: python When creating an image sequence, \`\`sequence\`\` can be either a list of image names (that will be \*played\* in the provided order), a folder name (played in alphanumerical order), or a list of frames (Numpy arrays), obtained for instance from other clips. .. warning:: All the images in list/folder/frames must be of the same size, or an exception will be raised For more, see :py:class:\`~moviepy.video.io.ImageSequenceClip.ImageSequenceClip\`. DataVideoClip """""""""""""""""" :py:class:\`~moviepy.video.io.VideoClip.DataVideoClip\` is a video clip who take a list of datasets, a callback function, and make each frame by iterating over dataset and invoking the callback function with the current data as first argument. You will probably never use this. But if you do, think of it like a :py:class:\`~moviepy.video.VideoClip.VideoClip\`, where you make frames not based on time, but based on each entry of a data list. .. literalinclude:: /\_static/code/user\_guide/loading/DataVideoClip.py :language: python For more, see For more, see :py:class:\`~moviepy.video.io.VideoClip.DataVideoClip\`. UpdatedVideoClip """""""""""""""""" .. warning:: This is really advanced usage, you will probably never need it, if you do, please go read the code. :py:class:\`~moviepy.video.io.VideoClip.UpdatedVideoClip\` is a video whose frame\_function requires some objects to be updated before we can compute it. This is particularly practical in science where some algorithm needs to make some steps before a new frame can be generated, or maybe when trying to make a video based on a live exterior context. When you use this, you pass a world object to it. A world object is an object who respect these 3 rules: #. It has a \`\`clip\_t\`\` property, indicating the current world time. #. It has an \`\`update()\`\` method, that will update the world state and is responsible for increasing \`\`clip\_t\`\` when a new frame can be drown. #. It has a \`\`to\_frame()\`\` method, that will render a frame based on world current state. On :py:meth:\`~moviepy.video.io.VideoClip.UpdatedVideoClip.get\_frame\` call, your :py:class:\`~moviepy.video.io.VideoClip.UpdatedVideoClip\` will try to update the world until \`\`world.clip\_t\`\` is superior or equal to frame time, then it will call \`\`world.to\_frame()\`\`. .. literalinclude:: /\_static/code/user\_guide/loading/UpdatedVideoClip.py :language: python Unanimated clips ~~~~~~~~~~~~~~~~ These are clips whose image will, at least before modifications, stay the same. By default they have no duration nor FPS, meaning you will need to define them before doing operations needing such information (for example, rendering). ImageClip """""""""" :py:class:\`~moviepy.video.VideoClip.ImageClip\` is the base class for all unanimated clips, it's a video clip that always displays the same image. Along with :py:class:\`~moviepy.video.io.VideoFileClip.VideoFileClip\` it's one of the most used kind of clip. You can create one as follows: .. literalinclude:: /\_static/code/user\_guide/loading/ImageClip.py :language: python For more, see :py:class:\`~moviepy.video.VideoClip.ImageClip\`. TextClip """"""""""""""" A :py:class:\`~moviepy.video.VideoClip.TextClip\` is a clip that will turn a text string into an image clip. :py:class:\`~moviepy.video.VideoClip.TextClip\` accept many parameters, letting you configure the appearance of the text, such as font and font size, color, interlining, text alignment, etc. The font you want to use must be an \`OpenType font \`\_, and you will set it by passing the path to the font file. Here are a few example of using :py:class:\`~moviepy.video.VideoClip.TextClip\` : .. literalinclude:: /\_static/code/user\_guide/loading/TextClip.py :language: python .. note:: The parameter \`\`method\`\` let you define if text should be written and overflow if too long (\`\`label\`\`) or be automatically broken over multiple lines (\`\`caption\`\`). For a more detailed explanation of all the parameters, see :py:class:\`~moviepy.video.VideoClip.TextClip\`. ColorClip """"""""""""""" A :py:class:\`~moviepy.video.VideoClip.ColorClip\` is a clip that will return an image of only one color. It is sometimes useful when doing compositing (see :ref:\`compositing\`). .. literalinclude:: /\_static/code/user\_guide/loading/ColorClip.py :language: python For more, see :py:class:\`~moviepy.video.VideoClip.ColorClip\`. .. \_loading#masks: Mask clips ~~~~~~~~~~~~~~ Masks are a special kind of :py:class:\`~moviepy.video.VideoClip.VideoClip\` with the property \`\`is\_mask\`\` set to \`\`True\`\`. They can be attached to any other kind of :py:class:\`~moviepy.video.VideoClip.VideoClip\` through method :py:meth:\`~moviepy.video.VideoClip.VideoClip.with\_mask\`. When a clip as a mask attached to it, this mask will indicate which pixels will be visible when the clip is composed with other clips (see :ref:\`compositing\`). Masks are also used to define transparency when you export the clip as GIF file or as a PNG. The fundamental difference between masks and standard clips is that standard clips output frames with 3 components (R-G-B) per pixel, comprised between 0 and 255, while a mask has just one component per pixel, between 0 and 1 (1 indicating a fully visible pixel and 0 a transparent pixel). Seen otherwise, a mask is always in greyscale. When you create or load a clip that you will use as a mask you need to declare it. You can then attach it to a clip with the same dimensions : .. literalinclude:: /\_static/code/user\_guide/loading/masks.py :language: python .. note:: In the case of video and image files, if these are not already black and white they will be converted automatically. Also, when you load an image with an \*alpha layer\*, like a PNG, MoviePy will use this layer as a mask unless you pass \`\`transparent=False\`\`. Any video clip can be turned into a mask with :py:meth:\`~moviepy.video.VideoClip.VideoClip.to\_mask\`, and a mask can be turned to a standard RGB video clip with :py:meth:\`~moviepy.video.VideoClip.VideoClip.to\_RGB()\`. Masks are treated differently by many methods (because their frames are different) but at the core, they are :py:class:\`~moviepy.video.VideoClip.VideoClip\`, so you can do with theme everything you can do with a video clip: modify, cut, apply effects, save, etc. Using audio elements with audio clips -------------------------------------- In addition to :py:class:\`~moviepy.video.VideoClip.VideoClip\` for visual, you can use audio elements, like an audio file, using the :py:class:\`~moviepy.audio.AudioClip.AudioClip\` class. Both are quite similar, except :py:class:\`~moviepy.audio.AudioClip.AudioClip\` method :py:meth:\`~moviepy.audio.AudioClip.AudioClip.get\_frame\` return a numpy array of size \`\`Nx1\`\` for mono, and size \`\`Nx2\`\` for stereo. AudioClip ~~~~~~~~~~ :py:class:\`~moviepy.audio.AudioClip.AudioClip\` is the base class for all audio clips. If all you want is to edit audio files, you will never need it. All you need is to define a function \`\`frame\_function(t)\`\` which returns a \`\`Nx1\`\` or \`\`Nx2\`\` numpy array representing the sound at time \`\`t\`\`. .. literalinclude:: /\_static/code/user\_guide/loading/AudioClip.py :language: python For more, see :py:class:\`~moviepy.audio.AudioClip.AudioClip\`. AudioFileClip ~~~~~~~~~~~~~~~~~~~~ :py:class:\`~moviepy.audio.io.AudioFileClip.AudioFileClip\` is used to load an audio file. This is probably the only kind of audio clip you will use. You simply pass it the file you want to load : .. literalinclude:: /\_static/code/user\_guide/loading/AudioFileClip.py :language: python For more, see :py:class:\`~moviepy.audio.io.AudioFileClip.AudioFileClip\`. AudioArrayClip ~~~~~~~~~~~~~~~~~~~~ :py:class:\`~moviepy.audio.AudioClip.AudioArrayClip\` is used to turn an array representing a sound into an audio clip. You will probably never use it, unless you need to use the result of some third library without using a temporary file. You need to provide a numpy array representing the sound (of size \`\`Nx1\`\` for mono, \`\`Nx2\`\` for stereo), and the number of fps, indicating the speed at which the sound is supposed to be played. .. literalinclude:: /\_static/code/user\_guide/loading/AudioArrayClip.py :language: python For more, see :py:class:\`~moviepy.audio.AudioClip.AudioArrayClip\`. --- # Unknown .. \_create\_effects: Creating your own effects ======================================================== In addition to the existing effects already offered by MoviePy, we can create our own effects to modify a clip however we want. Why creating your own effects? ------------------------------------ For simple enough tasks, we've seen that we can :ref:\`modifying#filters\`. Though it might be enough for simple tasks, filters are kind of limited: - They can only access frame and/or timepoint - We cannot pass arguments to them - They are hard to maintain and re-use To allow for more complex and reusable clip modifications, we can create our own custom effects, that we will later apply with :py:func:\`~moviepy.Clip.Clip.with\_effects\`. For example, imagine we want to add a progress bar to a clip, to do so we will not only need the time and image of the current frame, but also the total duration of the clip. We will also probably want to be able to pass parameters to define the appearance of the progress bar, such as color or height. This is a perfect task for an effect! Creating an effect -------------------- In MoviePy, effects are objects of type :py:class:\`moviepy.Effect.Effect\`, which is the base \`\`abstract class\`\` for all effects (kind of the same as :py:class:\`~moviepy.Clip.Clip\` is the base for all :py:class:\`~moviepy.video.VideoClip.VideoClip\` and :py:class:\`~moviepy.audio.AudioClip.AudioClip\`). So, to create an effect, we will need to inherit the :py:class:\`~moviepy.Effect.Effect\` class, and do two things: - Create an \`\`\_\_init\_\_\`\` method to be able to received the parameters of our effect. - Implement the inherited :py:meth:\`~moviepy.Effect.Effect.apply\` method, which must take as an argument the clip we want to modify, and return the modified version. In the end, your effect will probably use :py:func:\`~moviepy.Clip.Clip.time\_transform\`, :py:func:\`~moviepy.Clip.Clip.image\_transform\`, or :py:func:\`~moviepy.Clip.Clip.transform\` to really apply your modifications on the clip, The main difference is, because your filter will be a method or an anonymous function inside your effect class, you will be able to access all properties of your object from it! So, lets see how we could create our progress bar effect: .. literalinclude:: /\_static/code/user\_guide/effects/custom\_effect.py :language: python .. note:: When creating an effect, you frequently have to write boilerplate code for assigning properties on object initialization, \`\`dataclasses\`\` is a nice way to limit that. If you want to create your own effects, in addition of this documentation we strongly encourage you to go and take a look at the existing ones (see :py:mod:\`moviepy.video.fx\` and :py:mod:\`moviepy.audio.fx\`) to see how they works and take inspiration. --- # Unknown .. \_developers\_install: Installation for MoviePy developers ====================================== .. warning:: This part is only destined to people who want to build the MoviePy documentation by themselves, or to contribute to MoviePy. Normal users don't need it. In addition to MoviePy main libraries, MoviePy developers will also need to install additional libraries to be able to run MoviePy tests and build the MoviePy documentation. Libraries for documentation ----------------------------- You can install the libraries required to build documentation with: .. code:: bash $ (sudo) pip install moviepy\[doc\] Once libraries installed you can build the documentation with: .. code:: bash $ python setup.py build\_docs Libraries for testing and linting ------------------------------------- You can install the libraries required for testing and linting with: .. code:: bash $ (sudo) pip install moviepy\[test\] $ (sudo) pip install moviepy\[lint\] Once libraries installed you can test with: .. code:: bash $ python -m pytest And you can lint with: .. code:: bash $ python -m black . and .. code:: bash $ python3 -m flake8 -v --show-source --max-line-length=92 moviepy docs/conf.py examples tests --- # Unknown MoviePy Docker =============== Prerequisites ------------- Docker installed: \`Docker Engine for Linux \`\_ or \`Docker Desktop for Windows/Mac/Linux \`\_. Build the docker ----------------- 1. Move into the moviepy root dir 2. Build the Dockerfile :: docker build -t moviepy -f Dockerfile . How to run the unittests from docker ------------------------------------------------ Run pytest inside the container with the following command :: docker run -w /moviepy -it moviepy python -m pytest Running your own moviepy script from docker -------------------------------------------- Change directory to where your script is located If moviepy docker container is already running, you can connect by: :: docker exec -it moviepy python myscript.py If the container isn't running already :: docker run -it moviepy bash python myscript.py You can also start a container and run a script in one command: :: docker run -it -v \`pwd\`:/code moviepy python myscript.py --- # Unknown .. \_quick\_presentation: Quick presentation =================== This section explains when MoviePy can be used and how it works. Do I need MoviePy? ~~~~~~~~~~~~~~~~~~~ Here are a few reasons why you may want to edit videos in Python: - You have many videos to process or to compose in a complicated way. - You want to automate the creation of videos or GIFs on a web server (Django, Flask, etc.) - You want to automate tedious tasks, like title insertions tracking objects, cutting scenes, making end credits, subtitles, etc... - You want to code your own video effects to do something no existing video editor can. - You want to create animations from images generated by another python library (Matplotlib, Mayavi, Gizeh, scikit-images...) And here are a few uses for which MoviePy is NOT the best solution: - You only need to do frame-by-frame video analysis (with face detection or other fancy stuff). This could be done with MoviePy in association with other libraries, but really, just use imageio\_, OpenCV\_ or SimpleCV, these are libraries that specialize in these tasks. - You only want to convert a video file, or turn a series of image files into a movie. In this case it is better to directly call \`\`ffmpeg\`\` (or \`\`avconv\`\` or \`\`mencoder\`\`...) as it will be faster and more memory-efficient than going through MoviePy. Advantages and limitations ~~~~~~~~~~~~~~~~~~~~~~~~~~~ MoviePy has been developed with the following goals in mind: - \*\*Simple and intuitive\*\*. Basic operations can be done in one line. The code is easy to learn and easy to understand for newcomers. - \*\*Flexible\*\*. You have total control over the frames of the video and audio, and creating your own effects is easy as Py. - \*\*Portable\*\*. The code uses very common software (Numpy and FFmpeg) and can run on (almost) any machine with (almost) any version of Python. Limitations: - MoviePy cannot stream videos (e.g. reading from a webcam, or rendering a video live on a distant machine). - MoviePy is not really designed for video processing involving many successive frames of a movie (e.g. video stabilization - there is other software better suited for that). - You can also have memory problems if you use many video, audio, and image sources at the same time (>100). Example code ~~~~~~~~~~~~~~ In 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, lower the volume, add a title in the center of the video for the first ten seconds, and write the result in a file: .. literalinclude:: /\_static/code/getting\_started/quick\_presentation/basic\_example.py :language: python How MoviePy works ~~~~~~~~~~~~~~~~~~~ MoviePy uses the software \`\`ffmpeg\`\` to read and to export video and audio files. It also (optionally) uses \`\`ffplay\`\` to allow for video previewing. Internally, the representation and manipulation of the different media is done using Python's fast numerical library Numpy. Advanced effects and enhancements also use \`\`pillow\`\` library. .. image:: /\_static/medias/getting\_started/explanations.jpeg :width: 570px :align: center The central concept, the clips ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The central object of MoviePy is the the :py:class:\`Clip \`, with either :py:class:\`~moviepy.audio.AudioClip.AudioClip\` for any audio element, or :py:class:\`~moviepy.video.VideoClip.VideoClip\` for any visual element. Clips really are the base unit of MoviePy, everything you do is with and on them. Clips can be created from more than just videos or audios though. They can also be created from an image, a text, a custom animation, a folder of images, and even a simple lambda function! To create your final video, what you will do is essentially: #. Load different resources as clips (see :ref:\`loading\`) #. Modify them (see :ref:\`modifying\`) #. Mixing them into one final clip (see :ref:\`compositing\`) #. Render them into a file (see :ref:\`rendering\`) Of course, MoviePy offer multiple handy solution and tools to facilitate all these steps, and lets you add new ones by writing your own effects (see :ref:\`create\_effects\`)! .. \_imageio: https://imageio.github.io/ .. \_OpenCV: http://opencv.org/ --- # Unknown .. \_modifying: Modifying clips and apply effects =================================== Of course, once you will have loaded a :py:class:\`~moviepy.Clip.Clip\` the next step of action will be to modify it to be able to integrate it in your final video. To modify a clip, there is three main courses of actions : \* The built-in methods of :py:class:\`~moviepy.video.VideoClip.VideoClip\` or :py:class:\`~moviepy.audio.AudioClip.AudioClip\` modifying the properties of the object. \* The already-implemented effects of MoviePy you can apply on clips, usually affecting the clip by applying filters on each frame of the clip at rendering time. \* The transformation filters that you can apply using :py:func:\`~moviepy.Clip.Clip.transform\` and :py:func:\`~moviepy.Clip.Clip.time\_transform\`. How modifications are applied to a clip ? ------------------------------------------------------- Clip copy during modification ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The first thing you must know is that when modifying a clip, MoviePy \*\*will never modify that clip directly\*\*. Instead it will return \*\*a modified copy of the original\*\* and let the original untouched. This is known as out-place instead of in-place behavior. To illustrate: .. literalinclude:: /\_static/code/user\_guide/effects/modify\_copy\_example.py :language: python This is an important point to understand, because it is one of the most recurrent source of bug for newcomers. Memory consumption of effect and modifications ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When applying an effect or modification, it does not immediately apply the effect to all the frames of the clip, but only to the first frame: all the other frames will only be modified when required (that is, when you will write the whole clip to a file or when you will preview it). It means that creating a new clip is neither time nor memory hungry, all the computation happen during the final rendering. Time representations in MoviePy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Many methods that we will see accept duration or timepoint as arguments. For instance :py:meth:\`clip.subclipped(t\_start, t\_end) \` which cuts the clip between two timepoints. MoviePy usually accept duration and timepoint as either: \* a number of seconds as a \`\`float\`\`. \* a \`\`tuple\`\` with \`\`(minutes, seconds)\`\` or \`\`(hours, minutes, seconds)\`\`. \* a \`\`string\`\` such as \`\`'00:03:50.54'\`\`. Also, you can usually provide negative times, indicating a time from the end of the clip. For example, \`\`clip.subclipped(-20, -10)\`\` cuts the clip between 20s before the end and 10s before the end. Modify a clip using the \`\`with\_\*\`\` methods ------------------------------------------------------- The first way to modify a clip is by modifying internal properties of your object, thus modifying his behavior. These methods usually start with the prefix \`\`with\_\`\` or \`\`without\_\`\`, indicating that they will return a copy of the clip with the properties modified. So, you may write something like: .. literalinclude:: /\_static/code/user\_guide/effects/using\_with\_methods.py :language: python In addition to the \`\`with\_\*\`\` methods, a handful of very common methods are also accessible under shorter names: - :py:meth:\`~moviepy.video.VideoClip.VideoClip.resized\` - :py:meth:\`~moviepy.video.VideoClip.VideoClip.crop\` - :py:meth:\`~moviepy.video.VideoClip.VideoClip.rotate\` For a list of all those methods, see :py:class:\`~moviepy.Clip.Clip\` and :py:class:\`~moviepy.video.VideoClip.VideoClip\`. .. \_modifying#effects: Modify a clip using effects --------------------------------- The second way to modify a clip is by using effects that will modify the frames of the clip (which internally are no more than \`numpy arrays \`\_) by applying some sort of functions on them. MoviePy come with many effects implemented in :py:mod:\`moviepy.video.fx\` for visual effects and :py:mod:\`moviepy.audio.fx\` for audio effects. For practicality, these two modules are loaded in MoviePy as \`\`vfx\`\` and \`\`afx\`\`, letting you import them as \`\`from moviepy import vfx, afx\`\`. To use these effects, you simply need to instantiate them as object and apply them on your :py:class:\`~moviepy.Clip.Clip\` using method :py:meth:\`~moviepy.Clip.Clip.with\_effects\`, with a list of :py:class:\`~moviepy.Effect.Effect\` objects you want to apply. For convenience the effects are also dynamically added as method of :py:class:\`~moviepy.video.VideoClip.VideoClip\` and :py:class:\`~moviepy.video.AudioClip.AudioClip\` classes at runtime, letting you call them as simple method of your clip. So, you may write something like: .. literalinclude:: /\_static/code/user\_guide/effects/using\_effects.py :language: python .. note:: MoviePy effects are automatically applied to both the sound and the mask of the clip if it is relevant, so that you don't have to worry about modifying these. For a list of those effects, see :py:mod:\`moviepy.video.fx\` and :py:mod:\`moviepy.audio.fx\`. In addition to the effects already provided by MoviePy, you can obviously :ref:\`create\_effects\` and use them the same way. .. \_modifying#filters: Modify a clip appearance and timing using filters ---------------------------------------------------------- In addition to modifying a clip's properties and using effects, you can also modify the appearance or timing of a clip by using your own custom \*filters\* with :py:func:\`~moviepy.Clip.Clip.time\_transform\`, :py:func:\`~moviepy.Clip.Clip.image\_transform\`, and more generally with :py:func:\`~moviepy.Clip.Clip.transform\`. All these methods work by taking as first parameter a callback function that will receive either a clip frame, a timepoint, or both, and return a modified version of these. Modify only the timing of a Clip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can change the timeline of the clip with :py:meth:\`time\_transform(your\_filter) \`. Where \`\`your\_filter\`\` is a callback function taking clip time as a parameter and returning a new time: .. literalinclude:: /\_static/code/user\_guide/effects/time\_transform.py :language: python Now the clip \`\`modified\_clip1\`\` plays three times faster than \`\`my\_clip\`\`, while \`\`modified\_clip2\`\` will be oscillating between 00:00:00 to 00:00:02 of \`\`my\_clip\`\`. Note that in the last case you have created a clip of infinite duration (which is not a problem for the moment). .. note:: By default :py:func:\`~moviepy.Clip.Clip.time\_transform\` will only modify the clip main frame, without modifying clip audio or mask for :py:class:\`~moviepy.video.VideoClip.VideoClip\`. If you wish to also modify audio and/or mask you can provide the parameter \`\`apply\_to\`\` with either \`\`'audio'\`\`, \`\`'mask'\`\`, or \`\`\['audio', 'mask'\]\`\`. Modifying only the appearance of a Clip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For :py:class:\`~moviepy.video.VideoClip.VideoClip\`, you can change the appearance of the clip with :py:meth:\`image\_transform(your\_filter) \`. Where \`\`your\_filter\`\` is a callback function, taking clip frame (a numpy array) as a parameter and returning the transformed frame: .. literalinclude:: /\_static/code/user\_guide/effects/image\_transform.py :language: python Now the clip \`\`modified\_clip1\`\` will have his green and blue canals inverted. .. note:: You can define if transformation should be applied to audio and mask same as for :py:func:\`~moviepy.Clip.Clip.time\_transform\`. .. note:: Sometimes need to treat clip frames and mask frames in a different way. To distinguish between the two, you can always look at their shape, clips are \`\`H\*W\*3\`\`, and masks \`\`H\*W\`\`. Modifying both the appearance and the timing of a Clip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Finally, you may want to process the clip by taking into account both the time and the frame picture, for example to apply visual effects variating with time. This is possible with the method :py:meth:\`transform(your\_filter) \`. Where \`\`your\_filter\`\` is a callback function taking two parameters, and returning a new frame picture. Where first argument is a \`\`get\_frame\`\` method (i.e. a function \`\`get\_frame(time)\`\` which given a time returns the clip’s frame at that time), and the second argument is the time. .. literalinclude:: /\_static/code/user\_guide/effects/transform.py :language: python This will scroll down the clip, with a constant height of 360 pixels. .. note:: You can define if transformation should be applied to audio and mask same as for :py:func:\`~moviepy.Clip.Clip.time\_transform\`. .. note:: When programming a new effect, whenever it is possible, prefer using \`\`time\_transform\`\` and \`\`image\_transform\`\` instead of \`\`transform\`\` when implementing new effects. The reason is that, though they both internally rely on \`\`transform\`\` when these effects are applied to \`\`ImageClip\`\` objects, MoviePy will recognize they only need to be applied once instead of on each frame, resulting in faster renderings. To keep things simple, we have only addressed the case of :py:class:\`~moviepy.video.VideoClip.VideoClip\`, but know that the same principle applies to :py:class:\`~moviepy.audio.AudioClip.AudioClip\`, except that instead of a picture frame, you will have an audio frame, which is also a numpy array. --- # Unknown .. \_moviepy\_10\_minutes: MoviePy in 10 Minutes: Creating a Trailer from "Big Buck Bunny" =============================================================== .. note:: This tutorial aims to be a simple and short introduction for new users wishing to use MoviePy. For a more in-depth exploration of the concepts seen in this tutorial, see :ref:\`user\_guide\`. In this tutorial, you will learn the basics of how to use the MoviePy library in just 10 minutes. As an example project for this tutorial, we will create the following trailer for the movie \`"Big Buck Bunny." \`\_. .. raw:: html Your browser does not support HTML5 video in MP4 format. Prerequisites ------------- Before we start, make sure you have MoviePy installed. You can install it using pip: .. code-block:: shell pip install moviepy Also, we will need to gather a few resources such as the original movie, font files, images, etc. To make it easy, we have prepared a template project you can download directly: 1. Download :download:\`the project template \` and unzip it. 2. Take a look at the resources inside the folder to familiarize yourself. 3. Create a Python script file named \`\`trailer.py\`\` in the project directory. Now, you are ready to proceed to the next steps. Step 1: Import MoviePy and Load the Video ----------------------------------------- Let's start by importing the necessary modules and loading the "Big Buck Bunny" video into our Python program: .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 1-10 As you see, loading a video file is really easy, but MoviePy isn't limited to video. It can handle images, audio, texts, and even custom animations. No matter the kind of resources, ultimately any clip will be either a :py:class:\`~moviepy.video.VideoClip.VideoClip\` for any visual element, and an :py:class:\`~moviepy.audio.AudioClip.AudioClip\` for any audio element. In this tutorial, we will only see a few of those, but if you want to explore more, you can find an exhaustive list in the user guide about :ref:\`loading\`. Step 2: Extract the Best Scenes ------------------------------- To create our trailer, we will focus on presenting the main characters, so we need to extract parts of the movie. This is a very classic task, so let's turn our main clip into multiple subclips: .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 13-25 Here, we use the \`\`subclipped\`\` method to extract specific scenes from the main video. We provide the start and end times (in seconds or as text with the format \`\`HH:MM:SS.µS\`\`) for each scene. The extracted clips are stored in their respective variables (\`\`intro\_clip\`\`, \`\`bird\_clip\`\`, etc.). Step 3: Take a First Look with Preview -------------------------------------- When editing videos, it's often essential to preview the clips to ensure they meet our vision. This allows you to watch the segment you're working on and make any necessary adjustments for the perfect result. To do so using MoviePy, you can utilize the \`\`preview()\`\` function available for each clip (the complementary \`\`audio\_preview()\`\` is also available for :py:class:\`~moviepy.audio.AudioClip.AudioClip\`). .. note:: Note that you will need \`\`ffplay\`\` installed and accessible to MoviePy for preview to work. You can check if \`\`ffplay\`\` is available by running the command \`\`python3 -c "from moviepy.config import check;check()"\`\`. If not, please see :ref:\`install#binaries\`. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 28-38 By using the preview, you may have noticed that our clips not only contain video but also audio. This is because when loading a video, you not only load the image but also the audio tracks that are turned into :py:class:\`~moviepy.audio.AudioClip.AudioClip\` and added to your video clip. .. note:: When previewing, you may encounter video slowing or video/audio shifting. This is not a bug; it's due to the fact that your computer cannot render the preview in real-time. In such a case, the best course of action is to set the \`\`fps\`\` parameter for the \`\`preview()\`\` at a lower value to make things easier on your machine. Step 4: Modify a Clip by Cutting Out a Part of It -------------------------------------------------- After previewing the clips, we notice that the rodents' scene is a bit long. Let's modify the clip by removing a specific part. It would be nice to remove parts of the scene that we don't need. This is also quite a common task in video-editing. To do so, we are going to use the \`\`with\_section\_cut\_out\`\` method to remove a portion of the clip between \`\`00:06:00\`\` to \`\`00:10:00\`\`. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 41-54 In that particular case, we have used the \`\`with\_section\_cut\_out\`\`, but this is only one of the many clip manipulation methods starting with \`\`with\_\`\`. We will see a few others in this tutorial, but we will miss a lot more. If you want an exhaustive list, go see :ref:\`reference\_manual\`. .. note:: You may have noticed that we have reassigned the \`\`rodents\_clip\`\` variable instead of just calling a method on it. This is because in MoviePy, any function starting with \`\`with\_\`\` is out-of-place instead of in-place, meaning it does not modify the original data but instead copies it and modifies/returns the copy. So you need to store the result of the method and, if necessary, reassign the original variable to update your clip. Step 5: Creating Text/Logo Clips ------------------------------------ In addition to videos, we often need to work with images and texts. MoviePy offers some specialized kinds of :py:class:\`~moviepy.video.VideoClip.VideoClip\` specifically for that purpose: \`\`ImageClip\`\` and \`\`TextClip\`\`. In our case, we want to create text clips to add text overlays between the video clips. We'll define the font, text content, font size, and color for each text clip. We also want to create image clips for the "Big Buck Bunny" logo and the "Made with MoviePy" logo and resize them as needed. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 56-82 As you can see, \`\`ImageClip\`\` is quite simple, but \`\`TextClip\`\` is a rather complicated object. Don't hesitate to explore the arguments it accepts. .. note:: In our example, we have used the \`\`resized()\`\` method to resize our image clips. This method works just like any \`\`with\_\*\`\` method, but because resizing is such a common task, the name has been shortened to \`\`resized()\`\`. The same is true for \`\`cropped()\`\` and \`\`rotated()\`\`. Feel free to experiment with different effects and transitions to achieve the desired trailer effect. Step 6: Timing the clips -------------------------- We have all the clips we need, but if we were to combine all the clips into a single one using composition (we will see that in the next step), all our clips would start at the same time and play on top of each other, which is obviously not what we want. Also, some video clips, like images and texts, have no endpoint/duration at creation (unless you have provided a duration parameter), which means trying to render them will throw an error as it would result in an infinite video. To fix that, we need to specify when a clip should start and stop in the final clip. So, let's start by indicating when each clip must start and end using the appropriate with\_\* methods. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 85-111 .. note:: By default, all clips have a start point at \`\`0\`\`. If a clip has no \`\`duration\`\` but you set the \`\`end\_time\`\`, then the \`\`duration\`\` will be calculated for you. The reciprocity is also true. So in our case, we either use \`\`duration\`\` or \`\`end\_time\`\`, depending on what is more practical for each specific case. Step 7: Seeing how all clips combine -------------------------------------- Now that all our clips are timed, let's get a first idea of how our final clip will look. In video editing, the act of assembling multiple videos into a single one is known as composition. So, MoviePy offers a special kind of :py:class:\`~moviepy.video.VideoClip.VideoClip\` dedicated to the act of combining multiple clips into one, the :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\`. :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\` takes an array of clips as input and will play them on top of each other at render time, starting and stopping each clip at its start and end points. .. note:: If possible, :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\` will extract endpoint and size from the biggest/last ending clip. If a clip in the list has no duration, then you will have to manually set the duration of :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\` before rendering. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 114-136 Step 8: Positioning our clips ------------------------------ By looking at this first preview, we see that our clips are pretty well timed, but that the positions of our texts and logo are not satisfying. This is because, for now, we have only specified when our clips should appear, and not the position at which they should appear. By default, all clips are positioned from the top left of the video, at \`\`(0, 0)\`\`. All our clips do not have the same sizes (the texts and images are smaller than the videos), and the :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\` takes the size of the biggest clip (so in our case, the size of the videos), so the texts and images are all in the top left portion of the clip. To fix this, we simply have to define the position of our clips in the composition with the method \`\`with\_position\`\`. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 139-174 .. note:: The position is a tuple with horizontal and vertical position. You can give them as pixels, as strings (\`\`top\`\`, \`\`left\`\`, \`\`right\`\`, \`\`bottom\`\`, \`\`center\`\`), and even as a percentage by providing a float and passing the argument \`\`relative=True\`\`. Now, all our clips are in the right place and timed as expected. Step 9: Adding transitions and effects -------------------------------------------- So, our clips are timed and placed, but for now, the result is quite raw. It would be nice to have smoother transitions between the clips. In MoviePy, this is achieved through the use of effects. Effects play a crucial role in enhancing the visual and auditory appeal of your video clips. Effects are applied to clips to create transitions, transformations, or modifications, resulting in better-looking videos. Whether you want to add smooth transitions between clips, alter visual appearance, or manipulate audio properties, MoviePy comes with many existing effects to help you bring your creative vision to life with ease. You can find these effects under the namespace \`\`vfx\`\` for video effects and \`\`afx\`\` for audio effects. .. note:: You can use audio effects on both audio and video clips because when applying audio effects to a video clip, the effect will actually be applied to the video clip's embedded audio clip instead. Using an effect is very simple. You just have to call the method \`\`with\_effects\`\` on your clip and pass an array of effect objects to apply. In our case, we will add simple fade-in/out and cross-fade-in/out transitions between our clips, as well as slow down the \`\`rambo\_clip\`\`. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 177-239 Well, this looks a lot nicer! For this tutorial, we want to keep things simple, so we mostly used transitions. However, you can find many different effects and even create your own. For a more in-depth presentation, see :py:mod:\`moviepy.video.fx\`, :py:mod:\`moviepy.audio.fx\`, and :ref:\`create\_effects\`. .. note:: Looking at the result, you may notice that cross-fading makes clips go from transparent to opaque, and reciprocally, and wonder how it works. We won't get into details, but know that in MoviePy, you can declare some sections of a video clip to be transparent by using masks. Masks are nothing more than special kinds of video clips that are made of values ranging from \`\`0\`\` for a transparent pixel to \`\`1\`\` for a fully opaque one. For more info, see :ref:\`loading#masks\`. Step 10: Modifying the appearance of a clip using filters -------------------------------------------------------------- Finally, to make it more epic, we will apply a custom filter to our Rambo clip to make the image sepia. MoviePy does not come with a sepia effect out of the box, and creating a full custom effect is beyond the scope of this tutorial. However, we will see how we can apply a simple filter to our clip using the :py:meth:\`~moviepy.video.VideoClip.VideoClip.image\_transform\` method. To understand how filters work, you first need to understand that in MoviePy, a clip frame is nothing more than a numpy \`\`ndarray\`\` of shape \`\`HxWx3\`\`. This means we can modify how a frame looks like by applying simple math operations. Doing that on all the frames allows us to apply a filter to our clip! The "apply to all frames" part is done by the \`\`image\_transform\`\` method. This method takes a callback function as an argument, and at render time, it will trigger the callback for each frame of the clip, passing the current frame. .. warning:: This is a bit of an advanced usage, and the example involves matrix multiplication. If this is too much for you, you can simply ignore it until you really need to make custom filters, then go look for a more detailed explanation on how to do filtering (:ref:\`modifying#filters\`) and create custom effects (:ref:\`create\_effects\`) in the user guide. What you need to remember is just that we can apply filters on images. Here we do it mathematically, but you could very well use a library such as Pillow (provided it can understand numpy images) to do the maths for you! .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 242-283 Step 11: Rendering the final clip to a file -------------------------------------------- So, our final clip is ready, and we have made all the cutting and modifications we want. We are now ready to save the final result into a file. In video editing, this operation is known as rendering. Again, we will keep things simple and just do video rendering without much tweaking. In most cases, MoviePy and FFmpeg will automatically find the best settings. Take a look at :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_videofile\` for more info. .. literalinclude:: /\_static/code/getting\_started/moviepy\_10\_minutes/trailer.py :language: python :lines: 286-307 Conclusion ---------- Congratulations! You have successfully created a trailer for the movie "Big Buck Bunny" using the MoviePy library. This tutorial covered the basics of MoviePy, including loading videos, trimming scenes, adding effects and transitions, overlaying text, and even a little bit of filtering. If you want to dig deeper into MoviePy, we encourage you to try and experiment with this base example by using different effects, transitions, and audio elements to make your trailer truly captivating. We also encourage you to go and read the :ref:\`user\_guide\`, as well as looking directly at the :ref:\`reference\_manual\`. --- # Unknown .. \_contribution\_guidelines: MoviePy's Contribution Guidelines ================================= Communication on GitHub ----------------------- - Keep messages on GitHub issues and pull requests on-topic and to the point. Be aware that each comment triggers a notification which gets sent out to a number of people. - Opinions are OK. - For longer or more in-depth discussions, use the \`MoviePy Gitter \`\_. If these discussions lead to a decision, like a merge/reject, please leave a message on the relevant MoviePy issue to document the outcome of the discussion/the reason for the decision. - Do not push any commit that changes the API without prior discussion. Preparing for development ------------------------- - Fork the official MoviePy repository to your own GitHub account: Use the "Fork" button in the top right corner of the GitHub interface while viewing \`the official MoviePy \`\_ repository. - Use your fork as the basis for cloning the repository to your local machine: \`\`$ git clone URL\_TO\_YOUR\_FORK\`\` You can get the appropriate URL (SSH- or HTTPS-based) by using the green "Code" button located at the top right of the repository view while looking at your fork. By default, Git refers to any remote you clone from – i.e. in this case your fork on GitHub – as \`\`origin\`\`. - Enter your local clone and add the official MoviePy repository as a second remote, with alias \`\`upstream\`\`: \`\`$ git remote add upstream git@github.com:Zulko/moviepy.git\`\` (using SSL) \_or\_ \`\`$ git remote add upstream https://github.com/Zulko/moviepy.git\`\` (using HTTPS). - Install the library inside a \`virtual environment \`\_ with all dependencies included using \`\`$ pip install -e ".\[optional,doc,test,lint\]"\`\` - Configure pre-commit hooks running \`\`$ pre-commit install\`\` Coding conventions, code quality -------------------------------- - Respect \`PEP8 \`\_ conventions. - Add just the "right" amount of comments. Try to write auto-documented code with very explicit variable names. - If you introduce new functionality or fix a bug, document it in the docstring or with code comments. - MoviePy's team adopted \`pre-commit \`\_ to run code checks using black, flake8 and isort, so make sure that you've configured the pre-commit hooks with \`\`pre-commit install\`\`. Standard contribution workflow ------------------------------ Local development ~~~~~~~~~~~~~~~~~ - Keep your local \`\`master\`\` branch up-to-date with the official repo's master by periodically fetching/pulling it: \`\`$ git pull upstream master\`\` - Never make changes on \`\`master\`\` directly, but branch off into separate develop branches: \`\`$ git checkout --branch YOUR\_DEVELOP\_BRANCH\`\` Ideally, these are given names which function as keywords for what you are working on, and are prefixed with \`\`fix\_\`\` (for bug fixes), \`\`feature\_\`\` or something similarly appropriate and descriptive. - Base any changes you submit on the most recent \`\`master\`\`. More detailed explanation of the last point: It is likely that the official repo's \`\`master\`\` branch will move on (get updated, have other PRs merged into it) while you are working on your changes. Before creating a pull request, you will have to make sure your changes are not based on outdated code. For this reason, it makes sense to avoid falling "too much behind" while developing by rebasing your local \`\`master\`\` branch at intervals. Make sure your \`\`master\`\` branch is in sync with the official \`\`master\`\` branch (as per the first point), then, while checked into your develop branch, run: \`\`$ git rebase master\`\` If you \*\*haven't rebased before\*\*, make sure to \*\*familiarise yourself\*\* with the concept. Submitting Pull Requests ~~~~~~~~~~~~~~~~~~~~~~~~ You do not have to have finished your feature or bug fix before submitting a PR; just mention that it still is a work in progress. Before submitting PRs: - run the test suite over your code to expose any problems: \`\`$ pytest\`\` - push your local develop branch to your GitHub fork \`\`$ git push origin YOUR\_DEVELOP\_BRANCH\`\` When you now look at your forked repo on your GitHub account, you will see GitHub suggest branches for sending pull requests to the official \`\`Zulko/moviepy\`\` repository. Once you open a PR, you will be presented with a template which you are asked to fill out. You are encouraged to add any additional information which helps provide further context to your changes, and to link to any issues or PRs which your pull request references or is informed by. On submitting your PR, an automated test suite runs over your submission, which might take a few minutes to complete. In a next step, a MoviePy maintainer will review your code and, if necessary, help you to get it merge-ready. --- # Unknown .. \_compositing: Compositing multiple clips ========================================= Video composition, also known as non-linear editing, is the fact of mixing and playing several clips together in a new clip. This video is a good example of what compositing you can do with MoviePy: .. raw:: html .. note:: Before starting, note that video clips generally carry an audio track and a mask, which are also clips. When you compose these clips together, the soundtrack and mask of the final clip are automatically generated by putting together the soundtracks and masks of the clips. So most of the time you don't need to worry about mixing the audio and masks. Juxtaposing and concatenating clips ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Two simple ways of putting clips together is to concatenate them (to play them one after the other in a single long clip) or to juxtapose them (to put them side by side in a single larger clip). Concatenating multiple clips """"""""""""""""""""""""""""""""" Concatenation can be done very easily with the function :py:func:\`~moviepy.video.compositing.CompositeVideoClip.concatenate\_videoclips\`. .. literalinclude:: /\_static/code/user\_guide/compositing/concatenate.py :language: python The \`\`final\_clip\`\` is a clip that plays the clips 1, 2, and 3 one after the other. .. note:: The clips do not need to be the same size. If they aren't, they will all appear centered in a clip large enough to contain the biggest of them, with optionally a color of your choosing to fill the background. For more info, see :py:func:\`~moviepy.video.compositing.CompositeVideoClip.concatenate\_videoclips\`. Juxtaposing multiple clips """""""""""""""""""""""""""""" Putting multiple clip side by side is done with :py:func:\`~moviepy.video.compositing.CompositeVideoClip.clip\_array\`: .. literalinclude:: /\_static/code/user\_guide/compositing/juxtaposing.py :language: python You obtain a clip which looks like this: .. figure:: /\_static/medias/user\_guide/stacked.jpeg :align: center For more info, see :py:func:\`~moviepy.video.compositing.CompositeVideoClip.clip\_array\`. More complex video compositing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\` class is the base of all video compositing. For example, internally, both :py:func:\`~moviepy.video.compositing.CompositeVideoClip.concatenate\_videoclips\` and :py:func:\`~moviepy.video.compositing.CompositeVideoClip.clip\_array\` create a :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\`. It provides a very flexible way to compose clips, by playing multiple clip \*on top of\* of each other, in the order they have been passed to :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\`, here's an example : .. literalinclude:: /\_static/code/user\_guide/compositing/CompositeVideoClip.py :language: python Now \`\`final\_clip\`\` plays all clips at the same time, with \`\`clip3\`\` over \`\`clip2\`\` over \`\`clip1\`\`. It means that, if all clips have the same size, then only \`\`clip3\`\`, which is on top, will be visible in the video... Unless \`\`clip3\`\` and/or \`\`clip2\`\` have masks which hide parts of them. .. note:: Note that by default the composition has the size of its first clip (as it is generally a \*background\*). But sometimes you will want to make your clips \*float\* in a bigger composition. To do so, just pass the size of the final composition as \`\`size\`\` parameter of :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\`. For now we have stacked multiple clip on top of each others, but this is obviously not enough for doing real video compositing. For that, we will need to change when some clip starts and stops playing, as well as define the x:y, position of these clips in the final video. For more info, see :py:class:\`~moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip\`. Changing starting and stopping times of clips """""""""""""""""""""""""""""""""""""""""""""""" In a CompositionClip, each clip start to play at a time that is specified by his \`\`clip.start\`\` attribute, and will play until \`\`clip.end\`\`. So, considering that you would want to play \`\`clip1\`\` for the first 6 seconds, \`\`clip2\`\` 5 seconds after the start of the video, and finally \`\`clip3\`\` at the end of \`\`clip2\`\`, you would do as follows: .. literalinclude:: /\_static/code/user\_guide/compositing/with\_start.py :language: python .. note:: When working with timing of your clip, you will frequently want to keep only parts of the original clip. To do so, you should take a look at :py:meth:\`~moviepy.Clip.Clip.subclipped\` and :py:meth:\`~moviepy.Clip.Clip.with\_section\_cut\_out\`. Positioning clips """""""""""""""""" Frequently, you will want a smaller clip to appear on top of a larger one, and decide where it will appear in the composition by setting their position. You can do so by using the :py:meth:\`~moviepy.video.VideoClip.VideoClip.with\_position\` method. The position is always defined from the top left corner, but you can define it in many ways : .. literalinclude:: /\_static/code/user\_guide/compositing/with\_position.py :language: python When indicating the position keep in mind that the \`\`y\`\` coordinate has its zero at the top of the picture: .. figure:: /\_static/medias/user\_guide/videoWH.jpeg Adding transitions effects """""""""""""""""""""""""" The last part of composition is adding transition effects. For example, when a clip start while another is still playing, it would be nice to make the new one fade-in instead of showing abruptly. To do so, we can use the transitions offered by MoviePy in :py:mod:\`~moviepy.video.compositing.transitions\`, like :py:func:\`~moviepy.video.compositing.transitions.crossfadein\` : .. literalinclude:: /\_static/code/user\_guide/compositing/crossfadein.py :language: python MoviePy offer only few transitions in :py:mod:\`~moviepy.video.compositing.transitions\`. But technically, transitions are mostly effects applied to the mask of a clip! That means you can actually use any of the already existing effects, and use them as transitions by applying them on the mask of your clip (see . For more info, see :py:mod:\`~moviepy.video.compositing.transitions\` and :py:mod:\`moviepy.video.fx\`. Compositing audio clips ------------------------- When you mix video clips together, MoviePy will automatically compose their respective audio tracks to form the audio track of the final clip, so you don't need to worry about compositing these tracks yourself. If you want to make a custom audio track from several audio sources, audio clips can be mixed together like video clips, with :py:class:\`~moviepy.audio.AudioClip.CompositeAudioClip\` and :py:func:\`~moviepy.audio.AudioClip.concatenate\_audioclips\`: .. literalinclude:: /\_static/code/user\_guide/compositing/CompositeAudioClip.py :language: python --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy ======= .. automodule:: moviepy .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.Clip moviepy.Effect moviepy.audio moviepy.config moviepy.decorators moviepy.tools moviepy.video --- # Unknown .. \_maintainers\_publish: Publishing a New Version of MoviePy =================================== This section is for maintainers responsible for publishing new versions of MoviePy. Follow these steps to ensure the process is smooth and consistent: \*\*Pre-requisites\*\* ------------------ - Ensure you have proper permissions to push changes and create releases in the MoviePy repository. Steps to Publish a New Version ------------------------------ 1. \*\*Update the \`CHANGELOG.md\`\*\* - Add a new section for the upcoming version, respecting the format used in previous entries. - Summarize all changes, fixes, and new features. 2. \*\*Update the version in \`pyproject.toml\`\*\* - Open the \`pyproject.toml\` file. - Update the \`version\` field to the new version, following \`Semantic Versioning \`\_. 3. \*\*Commit and Push\*\* - Stage your changes:: git add CHANGELOG.md pyproject.toml - Commit your changes:: git commit -m "Release vX.Y.Z" - Push your changes:: git push 4. \*\*Create a New Tag\*\* - Create a tag for the new version (replace \`\`vX.Y.Z\`\` with the actual version number):: git tag -a vX.Y.Z -m "Release vX.Y.Z" - Push the tag to the remote repository:: git push origin vX.Y.Z 5. \*\*Create a New Release\*\* - Go to the repository's page on GitHub (or the relevant hosting platform). - Navigate to the "Releases" section and create a new release. - Use the new tag (\`\`vX.Y.Z\`\`) and provide a description for the release. - Copy the changelog for this version into the release description. - Publish the release. GitHub actions will automatically build and publish the new release on PyPi. By following these steps, you ensure that each MoviePy release is well-documented, correctly versioned, and accessible to users. --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.Clip ============ .. automodule:: moviepy.Clip .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst Clip --- # Unknown .. \_rendering: Previewing and saving video clips ==================================== Once you are down working with your clips, the last step will be to export the result into a video/image file, or sometimes to simply preview it in order to verify everything is working as expected. Previewing a clip """"""""""""""""""""" When you are working with a clip, you will frequently need to have a peak at what your clip looks like, either to verify that everything is working as intended, or to check how things looks. To do so you could render your entire clip into a file, but that's a pretty long task, and you only need a quick look, so a better solution exists: previewing. Preview a clip as a video ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. warning:: You must have \`\`ffplay\`\` installed and accessible to MoviePy to be able to use :py:func:\`~moviepy.video.io.preview.preview\`. If you'r not sure, take a look :ref:\`install#binaries\` The first thing you can do is to preview your clip as a video, by calling method :py:func:\`~moviepy.video.io.preview.preview\` on your clip: .. literalinclude:: /\_static/code/user\_guide/rendering/preview.py :language: python You will probably frequently want to preview only a small portion of your clip, though \`\`preview\`\` do not offer such capabilities, you can easily emulate such behavior by using :py:meth:\`~moviepy.Clip.Clip.subclipped\`. .. note:: It is quite frequent for a clip preview to be out of sync, or to play slower than it should. It means that your computer is not powerful enough to render the clip in real time. Don't hesitate to play with the options of preview: for instance, lower the fps of the sound (11000 Hz is still fine) and the video. Also, downsizing your video with resize can help. For more info, see :py:func:\`~moviepy.video.io.preview.preview\`. .. note:: A quite similar function is also available for :py:func:\`~moviepy.audio.AudioClip.AudioClip\`, see :py:func:\`~moviepy.audio.io.ffplay\_audiopreviewer.ffplay\_audiopreview\`. Preview just one frame of a clip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In a lot of situation, you don't really need to preview your all clip, seeing only one frame is enough to see how it looks like and to make sure everything goes as expected. To do so, you can use the method :py:func:\`~moviepy.video.io.preview.show\` on your clip, passing the frame time as an argument: .. literalinclude:: /\_static/code/user\_guide/rendering/show.py :language: python Contrary to video previewing, show does not require \`\`ffplay\`\`, but use \`\`pillow\`\` \`\`Image.show\`\` function. For more info, see :py:func:\`~moviepy.video.io.preview.show\`. Showing a clip in Jupyter Notebook ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you work with a \`Jupyter Notebook \`\_, it can be very practical to display your clip the notebook. To do so, you can use the method :py:func:\`~moviepy.video.io.display\_in\_notebook.display\_in\_notebook\` on your clip. .. image:: /\_static/medias/user\_guide/demo\_preview.jpeg :width: 500px :align: center With :py:func:\`~moviepy.video.io.display\_in\_notebook.display\_in\_notebook\` you can embed videos, images and sounds, either from a file or directly from a clip: .. literalinclude:: /\_static/code/user\_guide/rendering/display\_in\_notebook.py :language: python .. warning:: Know that :py:func:\`~moviepy.video.io.display\_in\_notebook.display\_in\_notebook\` will only work if it is on the last line a the notebook cell. Also, note that :py:func:\`~moviepy.video.io.display\_in\_notebook.display\_in\_notebook\` actually embeds the clips physically in your notebook. The advantage is that you can move the notebook or put it online and the videos will work. The drawback is that the file size of the notebook can become very large. Depending on your browser, re-computing and displaying at video many times can take some place in the cache and the RAM (it will only be a problem for intensive uses). Restarting your browser solves the problem. For more info, see :py:func:\`~moviepy.video.io.display\_in\_notebook.display\_in\_notebook\`. Save your clip into a file """""""""""""""""""""""""""""""""""""""" Once you are satisfied with how your clip looks, you can save it into a file, a step known in video edition as rendering. MoviePy offer various way to save your clip. Video files (.mp4, .webm, .ogv...) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The obvious first choice will be to write your clip to a video file, which you can do with :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_videofile\`: .. literalinclude:: /\_static/code/user\_guide/rendering/write\_videofile.py :language: python MoviePy can find the a default codec name for the most common file extensions. If you want to use exotic formats or if you are not happy with the defaults you can provide the codec with \`\`codec='mpeg4'\`\` for instance. There are many many options when you are writing a video (bitrate, parameters of the audio writing, file size optimization, number of processors to use, etc.), and we will not go in details into each. So, for more info, see :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_videofile\`. .. note:: Though you are encouraged to play with settings of \`\`write\_videofile\`\`, know that lowering the optimization preset or increasing the number of threads will not necessarily improve the rendering time, as the bottleneck may be on MoviePy computation of each frame and not in ffmpeg encoding. Also, know that it is possible to pass additional parameters to ffmpeg command line invoked by MoviePy by using the \`\`ffmpeg\_params\`\` argument. Sometimes it is impossible for MoviePy to guess the \`\`duration\`\` attribute of the clip (keep in mind that some clips, like ImageClips displaying a picture, have \*a priori\* an infinite duration). Then, the \`\`duration\`\` must be set manually with :py:meth:\`~moviepy.Clip.Clip.with\_duration\`: .. literalinclude:: /\_static/code/user\_guide/rendering/write\_videofile\_duration.py :language: python .. note:: A quite similar function is also available for :py:func:\`~moviepy.audio.AudioClip.AudioClip\`, see :py:func:\`~moviepy.audio.io.AudioClip.write\_audiofile\`. Export a single frame of the clip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As for previewing, sometimes you will need to export only one frame of a clip, for example to create the preview image of a video. You can do so with :py:meth:\`~moviepy.video.VideoClip.VideoClip.save\_frame\`: .. literalinclude:: /\_static/code/user\_guide/rendering/save\_frame.py :language: python For more info, see :py:func:\`~moviepy.video.VideoClip.VideoClip.save\_frame\`. Animated GIFs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In addition to writing video files, MoviePy also let you write GIF file with :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_gif\`: .. literalinclude:: /\_static/code/user\_guide/rendering/write\_gif.py :language: python For more info, see :py:func:\`~moviepy.video.VideoClip.VideoClip.write\_gif\`. Export all the clip as images in a directory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lastly, you may wish to export an entire clip as an image sequence (multiple images in one directory, one image per frame). You can do so with the function :py:meth:\`~moviepy.video.VideoClip.VideoClip.write\_images\_sequence\`: .. literalinclude:: /\_static/code/user\_guide/rendering/write\_images\_sequence.py :language: python For more info, see :py:func:\`~moviepy.video.VideoClip.VideoClip.write\_images\_sequence\`. --- # Unknown FAQ and troubleshooting ========================= This section intend to answer the most common questions and errors. Common errors that are not bugs -------------------------------- These are very common errors which are not considered as bugs to be solved (but you can still ask for this to change). If these answers don't work for you, please open a bug report on Github\_, or on the dedicated Subreddit\_. MoviePy generated a video that cannot be read by my favorite player. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Known reason: one of the video's dimensions were not even, for instance 720x405, and you used a MPEG4 codec like libx264 (default in MoviePy). In this case the video generated uses a format that is readable only on some readers like VLC. I can't seem to read any video with MoviePy """""""""""""""""""""""""""""""""""""""""""""" Known reason: you have a deprecated version of FFmpeg, install a recent version from the website, not from your OS's repositories! (see :ref:\`install\`). Previewing videos make them slower than they are """"""""""""""""""""""""""""""""""""""""""""""""" It means that your computer is not good enough to render the clip in real time. Don't hesitate to play with the options of \`\`preview\`\`: for instance, lower the fps of the sound (11000 Hz is still fine) and the video. Also, downsizing your video with \`\`resize\`\` can help. .. \_Github: https://github.com/Zulko/moviepy .. \_Subreddit: https://www.reddit.com/r/moviepy/ --- # Unknown moviepy.video.tools.subtitles.file\\\_to\\\_subtitles ================================================= .. currentmodule:: moviepy.video.tools.subtitles .. autofunction:: file\_to\_subtitles --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.Clip.Clip ================= .. currentmodule:: moviepy.Clip .. autoclass:: Clip :members: --- # moviepy.video.tools.subtitles.SubtitlesClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.tools.subtitles.SubtitlesClip[#](#moviepy-video-tools-subtitles-subtitlesclip "Permalink to this heading") ========================================================================================================================= _class_ moviepy.video.tools.subtitles.SubtitlesClip(_subtitles_, _font\=None_, _make\_textclip\=None_, _encoding\=None_)[\[source\]](../../_modules/moviepy/video/tools/subtitles.html#SubtitlesClip) [#](#moviepy.video.tools.subtitles.SubtitlesClip "Permalink to this definition") A Clip that serves as “subtitle track” in videos. One particularity of this class is that the images of the subtitle texts are not generated beforehand, but only if needed. Parameters: * **subtitles** – Either the name of a file as a string or path-like object, or a list * **font** – Path to a font file to be used. Optional if make\_textclip is provided. * **make\_textclip** – A custom function to use for text clip generation. If None, a TextClip will be generated. The function must take a text as argument and return a VideoClip to be used as caption * **encoding** – Optional, specifies srt file encoding. Any standard Python encoding is allowed (listed at [https://docs.python.org/3.8/library/codecs.html#standard-encodings](https://docs.python.org/3.8/library/codecs.html#standard-encodings) ) Examples from moviepy.video.tools.subtitles import SubtitlesClip from moviepy.video.io.VideoFileClip import VideoFileClip generator \= lambda text: TextClip(text, font\='./path/to/font.ttf', font\_size\=24, color\='white') sub \= SubtitlesClip("subtitles.srt", make\_textclip\=generator, encoding\='utf-8') myvideo \= VideoFileClip("myvideo.avi") final \= CompositeVideoClip(\[clip, subtitles\]) final.write\_videofile("final.mp4", fps\=myvideo.fps) in\_subclip(_start\_time\=None_, _end\_time\=None_)[\[source\]](../../_modules/moviepy/video/tools/subtitles.html#SubtitlesClip.in_subclip) [#](#moviepy.video.tools.subtitles.SubtitlesClip.in_subclip "Permalink to this definition") Returns a sequence of \[(t1,t2), text\] covering all the given subclip from start\_time to end\_time. The first and last times will be cropped so as to be exactly start\_time and end\_time if possible. match\_expr(_expr_)[\[source\]](../../_modules/moviepy/video/tools/subtitles.html#SubtitlesClip.match_expr) [#](#moviepy.video.tools.subtitles.SubtitlesClip.match_expr "Permalink to this definition") Matches a regular expression against the subtitles of the clip. write\_srt(_filename_)[\[source\]](../../_modules/moviepy/video/tools/subtitles.html#SubtitlesClip.write_srt) [#](#moviepy.video.tools.subtitles.SubtitlesClip.write_srt "Permalink to this definition") Writes an `.srt` file with the content of the clip. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.tools.subtitles.SubtitlesClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.tools.subtitles.SubtitlesClip.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.Effect ============== .. automodule:: moviepy.Effect :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio ============= .. automodule:: moviepy.audio .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.audio.AudioClip moviepy.audio.fx moviepy.audio.io moviepy.audio.tools --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.Crop ===================== .. automodule:: moviepy.video.fx.Crop :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.CrossFadeIn ============================ .. automodule:: moviepy.video.fx.CrossFadeIn :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.EvenSize ========================= .. automodule:: moviepy.video.fx.EvenSize :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.FadeIn ======================= .. automodule:: moviepy.video.fx.FadeIn :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.AccelDecel =========================== .. automodule:: moviepy.video.fx.AccelDecel :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.BlackAndWhite ============================== .. automodule:: moviepy.video.fx.BlackAndWhite :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.Blink ====================== .. automodule:: moviepy.video.fx.Blink :inherited-members: --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.UpdatedVideoClip ======================================== .. currentmodule:: moviepy.video.VideoClip .. autoclass:: UpdatedVideoClip :members: --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.ColorClip ================================= .. currentmodule:: moviepy.video.VideoClip .. autoclass:: ColorClip :members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.compositing ========================= .. automodule:: moviepy.video.compositing .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.video.compositing.CompositeVideoClip --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.BitmapClip ================================== .. currentmodule:: moviepy.video.VideoClip .. autoclass:: BitmapClip :members: --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.TextClip ================================ .. currentmodule:: moviepy.video.VideoClip .. autoclass:: TextClip :members: --- # Unknown moviepy.tools.no\\\_display\\\_available ==================================== .. currentmodule:: moviepy.tools .. autofunction:: no\_display\_available --- # Unknown moviepy.tools.subprocess\\\_call ============================== .. currentmodule:: moviepy.tools .. autofunction:: subprocess\_call --- # Unknown moviepy.tools.deprecated\\\_version\\\_of ===================================== .. currentmodule:: moviepy.tools .. autofunction:: deprecated\_version\_of --- # Unknown moviepy.tools.compute\\\_position =============================== .. currentmodule:: moviepy.tools .. autofunction:: compute\_position --- # Unknown moviepy.tools.close\\\_all\\\_clips =============================== .. currentmodule:: moviepy.tools .. autofunction:: close\_all\_clips --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.io.VideoFileClip ============================== .. automodule:: moviepy.video.io.VideoFileClip .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst VideoFileClip --- # moviepy.video.io.VideoFileClip.VideoFileClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.VideoFileClip.VideoFileClip[#](#moviepy-video-io-videofileclip-videofileclip "Permalink to this heading") =========================================================================================================================== _class_ moviepy.video.io.VideoFileClip.VideoFileClip(_filename_, _decode\_file\=False_, _has\_mask\=False_, _audio\=True_, _audio\_buffersize\=200000_, _target\_resolution\=None_, _resize\_algorithm\='bicubic'_, _audio\_fps\=44100_, _audio\_nbytes\=2_, _fps\_source\='fps'_, _pixel\_format\=None_, _is\_mask\=False_)[\[source\]](../../_modules/moviepy/video/io/VideoFileClip.html#VideoFileClip) [#](#moviepy.video.io.VideoFileClip.VideoFileClip "Permalink to this definition") A video clip originating from a movie file. For instance: clip \= VideoFileClip("myHolidays.mp4") clip.close() with VideoFileClip("myMaskVideo.avi") as clip2: pass \# Implicit close called by context manager. Parameters: * **filename** – The name of the video file, as a string or a path-like object. It can have any extension supported by ffmpeg: .ogv, .mp4, .mpeg, .avi, .mov etc. * **has\_mask** – Set this to ‘True’ if there is a mask included in the videofile. Video files rarely contain masks, but some video codecs enable that. For instance if you have a MoviePy VideoClip with a mask you can save it to a videofile with a mask. (see also `VideoClip.write_videofile` for more details). * **audio** – Set to False if the clip doesn’t have any audio or if you do not wish to read the audio. * **target\_resolution** – Set to (desired\_width, desired\_height) to have ffmpeg resize the frames before returning them. This is much faster than streaming in high-res and then resizing. If either dimension is None, the frames are resized by keeping the existing aspect ratio. * **resize\_algorithm** – The algorithm used for resizing. Default: “bicubic”, other popular options include “bilinear” and “fast\_bilinear”. For more information, see [https://ffmpeg.org/ffmpeg-scaler.html](https://ffmpeg.org/ffmpeg-scaler.html) * **fps\_source** – The fps value to collect from the metadata. Set by default to ‘fps’, but can be set to ‘tbr’, which may be helpful if you are finding that it is reading the incorrect fps from the file. * **pixel\_format** – Optional: Pixel format for the video to read. If is not specified ‘rgb24’ will be used as the default format unless `has_mask` is set as `True`, then ‘rgba’ will be used. * **is\_mask** – True if the clip is going to be used as a mask. filename[#](#moviepy.video.io.VideoFileClip.VideoFileClip.filename "Permalink to this definition") Name of the original video file. fps[#](#moviepy.video.io.VideoFileClip.VideoFileClip.fps "Permalink to this definition") Frames per second in the original file. Read docs for Clip() and VideoClip() for other, more generic, attributes. Lifetime[#](#lifetime "Permalink to this heading") --------------------------------------------------- Note that this creates subprocesses and locks files. If you construct one of these instances, you must call close() afterwards, or the subresources will not be cleaned up until the process ends. If copies are made, and close() is called on one, it may cause methods on the other copies to fail. close()[\[source\]](../../_modules/moviepy/video/io/VideoFileClip.html#VideoFileClip.close) [#](#moviepy.video.io.VideoFileClip.VideoFileClip.close "Permalink to this definition") Close the internal reader. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.VideoFileClip.VideoFileClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.VideoFileClip.VideoFileClip.rst.txt) --- # Unknown moviepy.decorators.use\\\_clip\\\_fps\\\_by\\\_default ============================================== .. currentmodule:: moviepy.decorators .. autofunction:: use\_clip\_fps\_by\_default --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.TimeSymmetrize =============================== .. automodule:: moviepy.video.fx.TimeSymmetrize :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.SlideOut ========================= .. automodule:: moviepy.video.fx.SlideOut :inherited-members: --- # moviepy.video.io.ImageSequenceClip.ImageSequenceClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.io.ImageSequenceClip.ImageSequenceClip[#](#moviepy-video-io-imagesequenceclip-imagesequenceclip "Permalink to this heading") =========================================================================================================================================== _class_ moviepy.video.io.ImageSequenceClip.ImageSequenceClip(_sequence_, _fps\=None_, _durations\=None_, _with\_mask\=True_, _is\_mask\=False_, _load\_images\=False_)[\[source\]](../../_modules/moviepy/video/io/ImageSequenceClip.html#ImageSequenceClip) [#](#moviepy.video.io.ImageSequenceClip.ImageSequenceClip "Permalink to this definition") A VideoClip made from a series of images. Parameters: * **sequence** – Can be one of these: * The name of a folder (containing only pictures). The pictures will be considered in alphanumerical order. * A list of names of image files. In this case you can choose to load the pictures in memory pictures * A list of Numpy arrays representing images. In this last case, masks are not supported currently. * **fps** – Number of picture frames to read per second. Instead, you can provide the duration of each image with durations (see below) * **durations** – List of the duration of each picture. * **with\_mask** – Should the alpha layer of PNG images be considered as a mask ? * **is\_mask** – Will this sequence of pictures be used as an animated mask. * **load\_images** – Specify that all images should be loaded into the RAM. This is only interesting if you have a small number of images that will be used more than once. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.io.ImageSequenceClip.ImageSequenceClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.io.ImageSequenceClip.ImageSequenceClip.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.SuperSample ============================ .. automodule:: moviepy.video.fx.SuperSample :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.Rotate ======================= .. automodule:: moviepy.video.fx.Rotate :inherited-members: --- # Unknown moviepy.decorators.requires\\\_duration ===================================== .. currentmodule:: moviepy.decorators .. autofunction:: requires\_duration --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.MultiplySpeed ============================== .. automodule:: moviepy.video.fx.MultiplySpeed :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.Painting ========================= .. automodule:: moviepy.video.fx.Painting :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.MasksOr ======================== .. automodule:: moviepy.video.fx.MasksOr :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.MirrorX ======================== .. automodule:: moviepy.video.fx.MirrorX :inherited-members: --- # Unknown moviepy.decorators.preprocess\\\_args =================================== .. currentmodule:: moviepy.decorators .. autofunction:: preprocess\_args --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.Loop ===================== .. automodule:: moviepy.video.fx.Loop :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.MakeLoopable ============================= .. automodule:: moviepy.video.fx.MakeLoopable :inherited-members: --- # Unknown moviepy.decorators.outplace =========================== .. currentmodule:: moviepy.decorators .. autofunction:: outplace --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.Margin ======================= .. automodule:: moviepy.video.fx.Margin :inherited-members: --- # Unknown moviepy.decorators.convert\\\_parameter\\\_to\\\_seconds ================================================== .. currentmodule:: moviepy.decorators .. autofunction:: convert\_parameter\_to\_seconds --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.FadeOut ======================== .. automodule:: moviepy.video.fx.FadeOut :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.FreezeRegion ============================= .. automodule:: moviepy.video.fx.FreezeRegion :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.GammaCorrection ================================ .. automodule:: moviepy.video.fx.GammaCorrection :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx ================ .. automodule:: moviepy.video.fx .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.video.fx.AccelDecel moviepy.video.fx.BlackAndWhite moviepy.video.fx.Blink moviepy.video.fx.Crop moviepy.video.fx.CrossFadeIn moviepy.video.fx.CrossFadeOut moviepy.video.fx.EvenSize moviepy.video.fx.FadeIn moviepy.video.fx.FadeOut moviepy.video.fx.Freeze moviepy.video.fx.FreezeRegion moviepy.video.fx.GammaCorrection moviepy.video.fx.HeadBlur moviepy.video.fx.InvertColors moviepy.video.fx.Loop moviepy.video.fx.LumContrast moviepy.video.fx.MakeLoopable moviepy.video.fx.Margin moviepy.video.fx.MaskColor moviepy.video.fx.MasksAnd moviepy.video.fx.MasksOr moviepy.video.fx.MirrorX moviepy.video.fx.MirrorY moviepy.video.fx.MultiplyColor moviepy.video.fx.MultiplySpeed moviepy.video.fx.Painting moviepy.video.fx.Resize moviepy.video.fx.Rotate moviepy.video.fx.Scroll moviepy.video.fx.SlideIn moviepy.video.fx.SlideOut moviepy.video.fx.SuperSample moviepy.video.fx.TimeMirror moviepy.video.fx.TimeSymmetrize --- # Unknown moviepy.decorators.apply\\\_to\\\_mask ================================== .. currentmodule:: moviepy.decorators .. autofunction:: apply\_to\_mask --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.fx.CrossFadeOut ============================= .. automodule:: moviepy.video.fx.CrossFadeOut :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.compositing.CompositeVideoClip ============================================ .. automodule:: moviepy.video.compositing.CompositeVideoClip .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst CompositeVideoClip .. rubric:: Functions .. autosummary:: :toctree: clips\_array concatenate\_videoclips --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.VideoClip ================================= .. currentmodule:: moviepy.video.VideoClip .. autoclass:: VideoClip :members: --- # moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.compositing.CompositeVideoClip.concatenate\_videoclips[#](#moviepy-video-compositing-compositevideoclip-concatenate-videoclips "Permalink to this heading") ========================================================================================================================================================================== moviepy.video.compositing.CompositeVideoClip.concatenate\_videoclips(_clips_, _method\='chain'_, _transition\=None_, _bg\_color\=None_, _is\_mask\=False_, _padding\=0_)[\[source\]](../../_modules/moviepy/video/compositing/CompositeVideoClip.html#concatenate_videoclips) [#](#moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips "Permalink to this definition") Concatenates several video clips. Returns a video clip made by clip by concatenating several video clips. (Concatenated means that they will be played one after another). There are two methods: * method=”chain”: will produce a clip that simply outputs the frames of the successive clips, without any correction if they are not of the same size of anything. If none of the clips have masks the resulting clip has no mask, else the mask is a concatenation of masks (using completely opaque for clips that don’t have masks, obviously). If you have clips of different size and you want to write directly the result of the concatenation to a file, use the method “compose” instead. * method=”compose”, if the clips do not have the same resolution, the final resolution will be such that no clip has to be resized. As a consequence the final clip has the height of the highest clip and the width of the widest clip of the list. All the clips with smaller dimensions will appear centered. The border will be transparent if mask=True, else it will be of the color specified by `bg_color`. The clip with the highest FPS will be the FPS of the result clip. Parameters: * **clips** – A list of video clips which must all have their `duration` attributes set. * **method** – “chain” or “compose”: see above. * **transition** – A clip that will be played between each two clips of the list. * **bg\_color** – Only for method=’compose’. Color of the background. Set to None for a transparent clip * **padding** – Only for method=’compose’. Duration during two consecutive clips. Note that for negative padding, a clip will partly play at the same time as the clip it follows (negative padding is cool for clips who fade in on one another). A non-null padding automatically sets the method to compose. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips.rst) [Show Source](../../_sources/reference/reference/moviepy.video.compositing.CompositeVideoClip.concatenate_videoclips.rst.txt) --- # moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip[#](#moviepy-video-compositing-compositevideoclip-compositevideoclip "Permalink to this heading") ================================================================================================================================================================= _class_ moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip(_clips_, _size\=None_, _bg\_color\=None_, _use\_bgclip\=False_, _is\_mask\=False_)[\[source\]](../../_modules/moviepy/video/compositing/CompositeVideoClip.html#CompositeVideoClip) [#](#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip "Permalink to this definition") A VideoClip made of other videoclips displayed together. This is the base class for most compositions. Parameters: * **size** – The size (width, height) of the final clip. * **clips** – A list of videoclips. Clips with a higher `layer` attribute will be displayed on top of other clips in a lower layer. If two or more clips share the same `layer`, then the one appearing latest in `clips` will be displayed on top (i.e. it has the higher layer). For each clip: * The attribute `pos` determines where the clip is placed. See `VideoClip.set_pos` * The mask of the clip determines which parts are visible. Finally, if all the clips in the list have their `duration` attribute set, then the duration of the composite video clip is computed automatically * **bg\_color** – Color for the unmasked and unfilled regions. Set to None for these regions to be transparent (will be slower). * **use\_bgclip** – Set to True if the first clip in the list should be used as the ‘background’ on which all other clips are blitted. That first clip must have the same size as the final clip. If it has no transparency, the final clip will have no mask. * **clip.** (_The clip with the highest FPS will be the FPS_ _of_ _the composite_) – close()[\[source\]](../../_modules/moviepy/video/compositing/CompositeVideoClip.html#CompositeVideoClip.close) [#](#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.close "Permalink to this definition") Closes the instance, releasing all the resources. frame\_function(_t_)[\[source\]](../../_modules/moviepy/video/compositing/CompositeVideoClip.html#CompositeVideoClip.frame_function) [#](#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.frame_function "Permalink to this definition") The clips playing at time t are blitted over one another. playing\_clips(_t\=0_)[\[source\]](../../_modules/moviepy/video/compositing/CompositeVideoClip.html#CompositeVideoClip.playing_clips) [#](#moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.playing_clips "Permalink to this definition") Returns a list of the clips in the composite clips that are actually playing at the given time t. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.rst) [Show Source](../../_sources/reference/reference/moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip.rst.txt) --- # Unknown moviepy.decorators.add\\\_mask\\\_if\\\_none ====================================== .. currentmodule:: moviepy.decorators .. autofunction:: add\_mask\_if\_none --- # Unknown moviepy.config.try\\\_cmd ======================= .. currentmodule:: moviepy.config .. autofunction:: try\_cmd --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.DataVideoClip ===================================== .. currentmodule:: moviepy.video.VideoClip .. autoclass:: DataVideoClip :members: --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip.ImageClip ================================= .. currentmodule:: moviepy.video.VideoClip .. autoclass:: ImageClip :members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video.VideoClip ======================= .. automodule:: moviepy.video.VideoClip .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst BitmapClip ColorClip DataVideoClip ImageClip TextClip UpdatedVideoClip VideoClip --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.video ============= .. automodule:: moviepy.video .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.video.VideoClip moviepy.video.compositing moviepy.video.fx moviepy.video.io moviepy.video.tools --- # Unknown moviepy.tools.find\\\_extension ============================= .. currentmodule:: moviepy.tools .. autofunction:: find\_extension --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.tools =================== .. automodule:: moviepy.audio.tools .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.audio.tools.cuts --- # Unknown moviepy.tools.convert\\\_to\\\_seconds ================================== .. currentmodule:: moviepy.tools .. autofunction:: convert\_to\_seconds --- # Unknown moviepy.tools.ffmpeg\\\_escape\\\_filename ====================================== .. currentmodule:: moviepy.tools .. autofunction:: ffmpeg\_escape\_filename --- # Unknown moviepy.tools.cross\\\_platform\\\_popen\\\_params ============================================ .. currentmodule:: moviepy.tools .. autofunction:: cross\_platform\_popen\_params --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.config ============== .. automodule:: moviepy.config .. rubric:: Functions .. autosummary:: :toctree: check try\_cmd --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.io.readers ======================== .. automodule:: moviepy.audio.io.readers .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst FFMPEG\_AudioReader --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.tools ============= .. automodule:: moviepy.tools .. rubric:: Functions .. autosummary:: :toctree: close\_all\_clips compute\_position convert\_to\_seconds cross\_platform\_popen\_params deprecated\_version\_of ffmpeg\_escape\_filename find\_extension no\_display\_available subprocess\_call --- # Unknown moviepy.decorators.convert\\\_path\\\_to\\\_string ============================================ .. currentmodule:: moviepy.decorators .. autofunction:: convert\_path\_to\_string --- # moviepy.audio.io.readers.FFMPEG_AudioReader — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.readers.FFMPEG\_AudioReader[#](#moviepy-audio-io-readers-ffmpeg-audioreader "Permalink to this heading") ========================================================================================================================== _class_ moviepy.audio.io.readers.FFMPEG\_AudioReader(_filename_, _buffersize_, _decode\_file\=False_, _print\_infos\=False_, _fps\=44100_, _nbytes\=2_, _nchannels\=2_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader "Permalink to this definition") A class to read the audio in either video files or audio files using ffmpeg. ffmpeg will read any audio and transform them into raw data. Parameters: * **filename** – Name of any video or audio file, like `video.mp4` or `sound.wav` etc. * **buffersize** – The size of the buffer to use. Should be bigger than the buffer used by `write_audiofile` * **print\_infos** – Print the ffmpeg infos on the file being read (for debugging) * **fps** – Desired frames per second in the decoded signal that will be received from ffmpeg * **nbytes** – Desired number of bytes (1,2,4) in the signal that will be received from ffmpeg buffer\_around(_frame\_number_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.buffer_around) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.buffer_around "Permalink to this definition") Fill the buffer with frames, centered on frame\_number if possible. close()[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.close) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.close "Permalink to this definition") Closes the reader, terminating the subprocess if is still alive. get\_frame(_tt_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.get_frame) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.get_frame "Permalink to this definition") Retrieve the audio frame(s) corresponding to the given timestamp(s). Parameters: **numpy.ndarray****)** (_tt_ _(__float or_) – The timestamp(s) at which to retrieve the audio frame(s). If tt is a single float value, the frame corresponding to that timestamp is returned. If tt is a NumPy array of timestamps, an array of frames corresponding to each timestamp is returned. initialize(_start\_time\=0_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.initialize) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.initialize "Permalink to this definition") Opens the file, creates the pipe. read\_chunk(_chunksize_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.read_chunk) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.read_chunk "Permalink to this definition") Read a chunk of audio data from the audio stream. This method reads a chunk of audio data from the audio stream. The specified number of frames, given by chunksize, is read from the proc stdout. The audio data is returned as a NumPy array, where each row corresponds to a frame and each column corresponds to a channel. If there is not enough audio left to read, the remaining portion is padded with zeros, ensuring that the returned array has the desired length. The pos attribute is updated accordingly. Parameters: **(****float****)** (_chunksize_) – The desired number of audio frames to read. seek(_pos_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.seek) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.seek "Permalink to this definition") Read a frame at time t. Note for coders: getting an arbitrary frame in the video with ffmpeg can be painfully slow if some decoding has to be done. This function tries to avoid fectching arbitrary frames whenever possible, by moving between adjacent frames. skip\_chunk(_chunksize_)[\[source\]](../../_modules/moviepy/audio/io/readers.html#FFMPEG_AudioReader.skip_chunk) [#](#moviepy.audio.io.readers.FFMPEG_AudioReader.skip_chunk "Permalink to this definition") Skip a chunk of audio data by reading and discarding the specified number of frames from the audio stream. The audio stream is read from the proc stdout. After skipping the chunk, the pos attribute is updated accordingly. Parameters: **(****int****)** (_chunksize_) – The number of audio frames to skip. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.readers.FFMPEG_AudioReader.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.readers.FFMPEG_AudioReader.rst.txt) --- # Unknown moviepy.decorators.requires\\\_fps ================================ .. currentmodule:: moviepy.decorators .. autofunction:: requires\_fps --- # Unknown moviepy.audio.AudioClip.concatenate\\\_audioclips =============================================== .. currentmodule:: moviepy.audio.AudioClip .. autofunction:: concatenate\_audioclips --- # moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.ffplay\_audiopreviewer.ffplay\_audiopreview[#](#moviepy-audio-io-ffplay-audiopreviewer-ffplay-audiopreview "Permalink to this heading") ========================================================================================================================================================= moviepy.audio.io.ffplay\_audiopreviewer.ffplay\_audiopreview(_clip_, _fps\=None_, _buffersize\=2000_, _nbytes\=2_, _audio\_flag\=None_, _video\_flag\=None_)[\[source\]](../../_modules/moviepy/audio/io/ffplay_audiopreviewer.html#ffplay_audiopreview) [#](#moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview "Permalink to this definition") A function that wraps the FFPLAY\_AudioPreviewer to preview an AudioClip Parameters: * **fps** – Frame rate of the sound. 44100 gives top quality, but may cause problems if your computer is not fast enough and your clip is complicated. If the sound jumps during the preview, lower it (11025 is still fine, 5000 is tolerable). * **buffersize** – The sound is not generated all at once, but rather made by bunches of frames (chunks). `buffersize` is the size of such a chunk. Try varying it if you meet audio problems (but you shouldn’t have to). * **nbytes** – Number of bytes to encode the sound: 1 for 8bit sound, 2 for 16bit, 4 for 32bit sound. 2 bytes is fine. * **audio\_flag** – Instances of class threading events that are used to synchronize video and audio during `VideoClip.preview()`. * **video\_flag** – Instances of class threading events that are used to synchronize video and audio during `VideoClip.preview()`. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.ffplay_audiopreviewer.ffplay_audiopreview.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.io.ffmpeg\\\_audiowriter ==================================== .. automodule:: moviepy.audio.io.ffmpeg\_audiowriter .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst FFMPEG\_AudioWriter .. rubric:: Functions .. autosummary:: :toctree: ffmpeg\_audiowrite --- # Unknown moviepy.decorators.apply\\\_to\\\_audio =================================== .. currentmodule:: moviepy.decorators .. autofunction:: apply\_to\_audio --- # Unknown moviepy.decorators.audio\\\_video\\\_effect ======================================= .. currentmodule:: moviepy.decorators .. autofunction:: audio\_video\_effect --- # moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.ffmpeg\_audiowriter.FFMPEG\_AudioWriter[#](#moviepy-audio-io-ffmpeg-audiowriter-ffmpeg-audiowriter "Permalink to this heading") ================================================================================================================================================= _class_ moviepy.audio.io.ffmpeg\_audiowriter.FFMPEG\_AudioWriter(_filename_, _fps\_input_, _nbytes\=2_, _nchannels\=2_, _codec\='libfdk\_aac'_, _bitrate\=None_, _input\_video\=None_, _logfile\=None_, _ffmpeg\_params\=None_)[\[source\]](../../_modules/moviepy/audio/io/ffmpeg_audiowriter.html#FFMPEG_AudioWriter) [#](#moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter "Permalink to this definition") A class to write an AudioClip into an audio file. Parameters: * **filename** – Name of any video or audio file, like `video.mp4` or `sound.wav` etc. * **size** – Size (width,height) in pixels of the output video. * **fps\_input** – Frames per second of the input audio (given by the AudioClip being written down). * **nbytes** (_int__,_ _optional_) – Number of bytes per sample. Default is 2 (16-bit audio). * **nchannels** (_int__,_ _optional_) – Number of audio channels. Default is 2 (stereo). * **codec** (_str__,_ _optional_) – The codec to use for the output. Default is `libfdk_aac`. * **bitrate** – A string indicating the bitrate of the final video. Only relevant for codecs which accept a bitrate. * **input\_video** (_str__,_ _optional_) – Path to an input video file. If provided, the audio will be muxed with this video. If not provided, the output will be audio-only. * **logfile** (_file-like object_ _or_ _None__,_ _optional_) – A file object where FFMPEG logs will be written. If None, logs are suppressed. * **ffmpeg\_params** (_list_ _of_ _str__,_ _optional_) – Additional FFMPEG command-line parameters to customize the output. close()[\[source\]](../../_modules/moviepy/audio/io/ffmpeg_audiowriter.html#FFMPEG_AudioWriter.close) [#](#moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter.close "Permalink to this definition") Closes the writer, terminating the subprocess if is still alive. write\_frames(_frames\_array_)[\[source\]](../../_modules/moviepy/audio/io/ffmpeg_audiowriter.html#FFMPEG_AudioWriter.write_frames) [#](#moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter.write_frames "Permalink to this definition") Send the audio frame (a chunck of `AudioClip`) to ffmpeg for writting On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.ffmpeg_audiowriter.FFMPEG_AudioWriter.rst.txt) --- # Unknown moviepy.decorators.convert\\\_masks\\\_to\\\_RGB ========================================== .. currentmodule:: moviepy.decorators .. autofunction:: convert\_masks\_to\_RGB --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.decorators ================== .. automodule:: moviepy.decorators .. rubric:: Functions .. autosummary:: :toctree: add\_mask\_if\_none apply\_to\_audio apply\_to\_mask audio\_video\_effect convert\_masks\_to\_RGB convert\_parameter\_to\_seconds convert\_path\_to\_string outplace preprocess\_args requires\_duration requires\_fps use\_clip\_fps\_by\_default --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.io ================ .. automodule:: moviepy.audio.io .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.audio.io.AudioFileClip moviepy.audio.io.ffmpeg\_audiowriter moviepy.audio.io.ffplay\_audiopreviewer moviepy.audio.io.readers --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.MultiplyStereoVolume ===================================== .. automodule:: moviepy.audio.fx.MultiplyStereoVolume :inherited-members: --- # Unknown moviepy.config.check ==================== .. currentmodule:: moviepy.config .. autofunction:: check --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.tools.cuts ======================== .. automodule:: moviepy.audio.tools.cuts .. rubric:: Functions .. autosummary:: :toctree: find\_audio\_period --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.AudioClip ======================= .. automodule:: moviepy.audio.AudioClip .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst AudioArrayClip AudioClip CompositeAudioClip .. rubric:: Functions .. autosummary:: :toctree: concatenate\_audioclips --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.io.ffplay\\\_audiopreviewer ======================================= .. automodule:: moviepy.audio.io.ffplay\_audiopreviewer .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst FFPLAY\_AudioPreviewer .. rubric:: Functions .. autosummary:: :toctree: ffplay\_audiopreview --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.AudioLoop ========================== .. automodule:: moviepy.audio.fx.AudioLoop :inherited-members: --- # moviepy.audio.tools.cuts.find_audio_period — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.tools.cuts.find\_audio\_period[#](#moviepy-audio-tools-cuts-find-audio-period "Permalink to this heading") ========================================================================================================================= moviepy.audio.tools.cuts.find\_audio\_period(_clip_, _min\_time\=0.1_, _max\_time\=2_, _time\_resolution\=0.01_)[\[source\]](../../_modules/moviepy/audio/tools/cuts.html#find_audio_period) [#](#moviepy.audio.tools.cuts.find_audio_period "Permalink to this definition") Finds the period, in seconds of an audioclip. Parameters: * **min\_time** (_float__,_ _optional_) – Minimum bound for the returned value. * **max\_time** (_float__,_ _optional_) – Maximum bound for the returned value. * **time\_resolution** (_float__,_ _optional_) – Numerical precision. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.tools.cuts.find_audio_period.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.tools.cuts.find_audio_period.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.io.AudioFileClip ============================== .. automodule:: moviepy.audio.io.AudioFileClip .. rubric:: Classes .. autosummary:: :toctree: :template: custom\_autosummary/class.rst AudioFileClip --- # moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.ffmpeg\_audiowriter.ffmpeg\_audiowrite[#](#moviepy-audio-io-ffmpeg-audiowriter-ffmpeg-audiowrite "Permalink to this heading") =============================================================================================================================================== moviepy.audio.io.ffmpeg\_audiowriter.ffmpeg\_audiowrite(_clip_, _filename_, _fps_, _nbytes_, _buffersize_, _codec\='libvorbis'_, _bitrate\=None_, _write\_logfile\=False_, _ffmpeg\_params\=None_, _logger\='bar'_)[\[source\]](../../_modules/moviepy/audio/io/ffmpeg_audiowriter.html#ffmpeg_audiowrite) [#](#moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite "Permalink to this definition") A function that wraps the FFMPEG\_AudioWriter to write an AudioClip to a file. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.ffmpeg_audiowriter.ffmpeg_audiowrite.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.MultiplyVolume =============================== .. automodule:: moviepy.audio.fx.MultiplyVolume :inherited-members: --- # moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.ffplay\_audiopreviewer.FFPLAY\_AudioPreviewer[#](#moviepy-audio-io-ffplay-audiopreviewer-ffplay-audiopreviewer "Permalink to this heading") ============================================================================================================================================================= _class_ moviepy.audio.io.ffplay\_audiopreviewer.FFPLAY\_AudioPreviewer(_fps\_input_, _nbytes\=2_, _nchannels\=2_)[\[source\]](../../_modules/moviepy/audio/io/ffplay_audiopreviewer.html#FFPLAY_AudioPreviewer) [#](#moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer "Permalink to this definition") A class to preview an AudioClip. Parameters: * **fps\_input** – Frames per second of the input audio (given by the AudioClip being written down). * **nbytes** – Number of bytes to encode the sound: 1 for 8bit sound, 2 for 16bit, 4 for 32bit sound. Default is 2 bytes, it’s fine. * **nchannels** – Number of audio channels in the clip. Default to 2 channels. close()[\[source\]](../../_modules/moviepy/audio/io/ffplay_audiopreviewer.html#FFPLAY_AudioPreviewer.close) [#](#moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer.close "Permalink to this definition") Closes the writer, terminating the subprocess if is still alive. write\_frames(_frames\_array_)[\[source\]](../../_modules/moviepy/audio/io/ffplay_audiopreviewer.html#FFPLAY_AudioPreviewer.write_frames) [#](#moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer.write_frames "Permalink to this definition") Send a raw audio frame (a chunck of audio) to ffplay to be played On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.ffplay_audiopreviewer.FFPLAY_AudioPreviewer.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.AudioFadeOut ============================= .. automodule:: moviepy.audio.fx.AudioFadeOut :inherited-members: --- # moviepy.audio.io.AudioFileClip.AudioFileClip — MoviePy documentation [Skip to main content](#main-content) Ctrl+K MoviePy v2.0 have introduced breaking changes, see [Updating from v1.X to v2.X](https://zulko.github.io/moviepy/getting_started/updating_to_v2.html) for more info. * [GitHub](https://github.com/Zulko/moviepy/ "GitHub") moviepy.audio.io.AudioFileClip.AudioFileClip[#](#moviepy-audio-io-audiofileclip-audiofileclip "Permalink to this heading") =========================================================================================================================== _class_ moviepy.audio.io.AudioFileClip.AudioFileClip(_filename_, _decode\_file\=False_, _buffersize\=200000_, _nbytes\=2_, _fps\=44100_)[\[source\]](../../_modules/moviepy/audio/io/AudioFileClip.html#AudioFileClip) [#](#moviepy.audio.io.AudioFileClip.AudioFileClip "Permalink to this definition") An audio clip read from a sound file, or an array. The whole file is not loaded in memory. Instead, only a portion is read and stored in memory. this portion includes frames before and after the last frames read, so that it is fast to read the sound backward and forward. Parameters: * **filename** – Either a soundfile name (of any extension supported by ffmpeg) as a string or a path-like object, or an array representing a sound. If the soundfile is not a .wav, it will be converted to .wav first, using the `fps` and `bitrate` arguments. * **buffersize** – Size to load in memory (in number of frames) nbytes[#](#moviepy.audio.io.AudioFileClip.AudioFileClip.nbytes "Permalink to this definition") Number of bits per frame of the original audio file. fps[#](#moviepy.audio.io.AudioFileClip.AudioFileClip.fps "Permalink to this definition") Number of frames per second in the audio file buffersize[#](#moviepy.audio.io.AudioFileClip.AudioFileClip.buffersize "Permalink to this definition") See Parameters. Lifetime[#](#moviepy.audio.io.AudioFileClip.AudioFileClip.Lifetime "Permalink to this definition") \-------- Note that this creates subprocesses and locks files. If you construct one of these instances, you must call close() afterwards, or the subresources will not be cleaned up until the process ends. Examples snd \= AudioFileClip("song.wav") snd.close() close()[\[source\]](../../_modules/moviepy/audio/io/AudioFileClip.html#AudioFileClip.close) [#](#moviepy.audio.io.AudioFileClip.AudioFileClip.close "Permalink to this definition") Close the internal reader. On this page [Edit on GitHub](https://github.com/Zulko/moviepy/edit/master/docs/reference/reference/moviepy.audio.io.AudioFileClip.AudioFileClip.rst) [Show Source](../../_sources/reference/reference/moviepy.audio.io.AudioFileClip.AudioFileClip.rst.txt) --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx ================ .. automodule:: moviepy.audio.fx .. rubric:: Modules .. autosummary:: :toctree: :template: custom\_autosummary/module.rst :recursive: moviepy.audio.fx.AudioDelay moviepy.audio.fx.AudioFadeIn moviepy.audio.fx.AudioFadeOut moviepy.audio.fx.AudioLoop moviepy.audio.fx.AudioNormalize moviepy.audio.fx.MultiplyStereoVolume moviepy.audio.fx.MultiplyVolume --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.AudioClip.CompositeAudioClip ========================================== .. currentmodule:: moviepy.audio.AudioClip .. autoclass:: CompositeAudioClip :members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.AudioNormalize =============================== .. automodule:: moviepy.audio.fx.AudioNormalize :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.AudioFadeIn ============================ .. automodule:: moviepy.audio.fx.AudioFadeIn :inherited-members: --- # Unknown .. custom module to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.fx.AudioDelay =========================== .. automodule:: moviepy.audio.fx.AudioDelay :inherited-members: --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.AudioClip.AudioArrayClip ====================================== .. currentmodule:: moviepy.audio.AudioClip .. autoclass:: AudioArrayClip :members: --- # Unknown .. custom class to enable complete documentation of every function see https://stackoverflow.com/a/62613202 moviepy.audio.AudioClip.AudioClip ================================= .. currentmodule:: moviepy.audio.AudioClip .. autoclass:: AudioClip :members: ---