Skip to main content

Video editing with Python

Project description


.. image::
:target: PyPI_
:alt: MoviePy page on the Python Package Index
.. image::
:target: Gitter_
:alt: Discuss MoviePy on Gitter
.. image::
:alt: Build status on travis-ci
.. image::
:alt: Code coverage from

MoviePy (full documentation_) is a Python library for video editing: cutting, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects. See the gallery_ for some examples of use.

MoviePy can read and write all the most common audio and video formats, including GIF, and runs on Windows/Mac/Linux, with Python 2.7+ and 3. Here it is in action in an IPython notebook:

.. image::
:alt: [logo]
:align: center


In this example we open a video file, select the subclip between t=50s and t=60s, add a title at the center of the screen, and write the result to a new file:

.. code:: python

from moviepy.editor import *

video = VideoFileClip("myHolidays.mp4").subclip(50,60)

# Make the text. Many more options are available.
txt_clip = ( TextClip("My Holidays 2013",fontsize=70,color='white')
.set_duration(10) )

result = CompositeVideoClip([video, txt_clip]) # Overlay text on video
result.write_videofile("myHolidays_edited.webm",fps=25) # Many options...


MoviePy depends on the Python modules Numpy_, imageio_, Decorator_, and tqdm_, which will be automatically installed during MoviePy's installation. The software FFMPEG should be automatically downloaded/installed (by imageio) during your first use of MoviePy (installation will take a few seconds). If you want to use a specific version of FFMPEG, follow the instructions in ````. In case of trouble, provide feedback.

**Installation by hand:** download the sources, either from PyPI_ or, if you want the development version, from GitHub_, unzip everything into one folder, open a terminal and type:

.. code:: bash

$ (sudo) python install

**Installation with pip:** if you have ``pip`` installed, just type this in a terminal:

.. code:: bash

$ (sudo) pip install moviepy

If you have neither ``setuptools`` nor ``ez_setup`` installed, the command above will fail. In this case type this before installing:

.. code:: bash

$ (sudo) pip install ez_setup

Optional but useful dependencies

You can install ``moviepy`` with all dependencies via:

.. code:: bash

$ (sudo) pip install moviepy[optional]

ImageMagick_ is not strictly required, but needed if you want to incorporate texts. It can also be used as a backend for GIFs, though you can also create GIFs with MoviePy without ImageMagick.

Once you have installed ImageMagick, it will be automatically detected by MoviePy, **except on Windows!** Windows users, before installing MoviePy by hand, need to edit ``moviepy/`` to provide the path to the ImageMagick binary, which is called `convert`. It should look like this:

.. code:: python

IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\convert.exe"

PyGame_ is needed for video and sound previews (not relevant if you intend to work with MoviePy on a server but essential for advanced video editing by hand).

For advanced image processing, you will need one or several of the following packages:

- The Python Imaging Library (PIL) or, even better, its branch Pillow_.
- Scipy_ (for tracking, segmenting, etc.) can be used to resize video clips if PIL and OpenCV are not installed.
- `Scikit Image`_ may be needed for some advanced image manipulation.
- `OpenCV 2.4.6`_ or a more recent version (one that provides the package ``cv2``) may be needed for some advanced image manipulation.
- `Matplotlib`_

Once you have installed it, ImageMagick will be automatically detected by MoviePy, (except for windows users and Ubuntu 16.04LTS users).

For Windows users, before installing MoviePy by hand, go into the ``moviepy/`` file and provide the path to the ImageMagick binary called ``magick``. It should look like this:

.. code:: python

IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\magick.exe"

If you are using an older version of ImageMagick, keep in mind the name of the executable is not ``magick.exe`` but ``convert.exe``. In that case, the IMAGEMAGICK_BINARY property should be ``C:\\Program Files\\ImageMagick_VERSION\\convert.exe``

For Ubuntu 16.04LTS users, after installing MoviePy on the terminal, IMAGEMAGICK will not be detected by moviepy. This bug can be fixed. Modify the file in this directory: /etc/ImageMagick-6/policy.xml, comment out the statement <!-- <policy domain="path" rights="none" pattern="@*" /> -->.

PyGame_ is needed for video and sound previews (useless if you intend to work with MoviePy on a server but really essential for advanced video editing *by hand*).

For instance, using the method ``clip.resize`` requires that at least one of Scipy, PIL, Pillow or OpenCV is installed.


Running `build_docs` has additional dependencies that require installation.

.. code:: bash

$ (sudo) pip install moviepy[docs]

The documentation can be generated and viewed via:

.. code:: bash

$ python build_docs

You can pass additional arguments to the documentation build, such as clean build:

.. code:: bash

$ python build_docs -E

More information is available from the `Sphinx`_ documentation.

Running Tests

The testing suite can be executed via:

.. code:: bash

$ python test

Running the test suite in this manner will install the testing dependencies.
If you opt to run the test suite manually, you can install the dependencies via:

.. code:: bash

$ (sudo) pip install moviepy[test]


MoviePy is open-source software originally written by Zulko_ and released under the MIT licence. The project is hosted on GitHub_, where everyone is welcome to contribute, ask for help or simply give feedback. Please read our `Contributing Guidelines`_ for more information about how to contribute!

You can also discuss the project on Reddit_ or Gitter_. These are preferred over GitHub issues for usage questions and examples.

We have a list of labels used in our `Label Wiki`_. The 'Pull Requests' labels are well defined, and all PRs should fall under exactly one of these. The 'Issues' labels are less precise, and may not be a complete list.


- Zulko_ (owner)

- `@tburrows13`_
- `@earney`_
- Kay `@kerstin`_
- `@mbeacom`_

.. MoviePy links
.. _gallery:
.. _documentation:
.. _`download MoviePy`:
.. _`Label Wiki`:
.. _Contributing Guidelines:

.. Websites, Platforms
.. _Reddit:
.. _PyPI:
.. _GitHub:
.. _Gitter:

.. Software, Tools, Libraries
.. _Pillow:
.. _Scipy:
.. _`OpenCV 2.4.6`:
.. _Pygame:
.. _Numpy:
.. _imageio:
.. _`Scikit Image`:
.. _Decorator:
.. _tqdm:
.. _ffmpeg:
.. _ImageMagick:
.. _`Matplotlib`:
.. _`Sphinx`:

.. People
.. _Zulko:
.. _`@tburrows13`:
.. _`@earney`:
.. _`@kerstin`:
.. _`@mbeacom`:

Keywords: video editing audio compositing ffmpeg
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Multimedia
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Multimedia :: Video :: Capture
Classifier: Topic :: Multimedia :: Video :: Conversion
Provides-Extra: optional
Provides-Extra: doc
Provides-Extra: test

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moviepy_wumii- (395.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page