MoviePy is a Python module for video editing, which can be used for basic operations (like cuts, concatenations, title insertions), video compositing (a.k.a. non-linear editing), video processing, or to create advanced effects. It can read and write the most common video formats, including GIF.
Installation
To install the Movie Editor Library, open terminal and write :
pip install moviepy
Note: This module automatically installs FFmpeg. However, you might prompt to install in some cases.
Even after installing MoviePy there will be some features that can’t be used unless ImageMagick is installed, features like adding text on the video or on GIFs.
Installation of ImageMagick
ImageMagick is not strictly required, only if user want to write texts. It can also be used as a back-end for GIFs although user can do GIFs with MoviePy without ImageMagick. Below is the link for downloading ImageMagick
https://imagemagick.org/script/download.php
Once it is installed, ImageMagick will be automatically detected by MoviePy, except on Windows. Windows users have to go into the moviepy/config_defaults.py file and provide the path to the ImageMagick binary called magick.
IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\magick.exe"
or for some older versions of ImageMagick it will be
IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\convert.exe"
To get video’s used when the article is improved – Click Here
Example 1
We will load the video, and we will cut a clip from the whole video then the video will be rotated upside down, in this example, there is no need for ImageMagick installation.
Below is the implementation
Python3
from moviepy.editor import *
clip = VideoFileClip( "dsa_geek.webm" )
clip = clip.subclip( 0 , 10 )
clip = clip.rotate( 180 )
clip = clip.volumex( 0.5 )
clip.ipython_display(width = 280 )
|
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4
Example 2:
We will load the video and we will cut a clip from the whole video then we will add text in the video, in this example we have to install ImageMagick otherwise it will not work.
Below is the implementation
Python3
from moviepy.editor import *
clip = VideoFileClip( "dsa_geek.webm" )
clip = clip.subclip( 0 , 10 )
clip = clip.volumex( 0.8 )
txt_clip = TextClip( "GeeksforGeeks" , fontsize = 70 , color = 'white' )
txt_clip = txt_clip.set_pos( 'center' ).set_duration( 10 )
video = CompositeVideoClip([clip, txt_clip])
video.ipython_display(width = 280 )
|
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4
Exporting Video files:
You need function write_videofile(arg1, arg2), If you do not, it won’t reflect on the hard-disk file as the file was loaded in RAM.
Python3
import moviepy.editor as me
SYNTAX:
obj = me.TextClip( "Text That you want" ,
color = '{as string}' ,
size = (as, tuple ),
bg_color = 'as string' ,
fontsize = int )
me.write_videofile( "Name you want" .mp4,endcoding)
print ( "Done" )
|
Output:

Merging Video files –
We can merge 2 video files to a single file in order of our requirement
Python3
import moviepy.editor
clip_1 = moviepy.editor.VideoFileClip( "Video_1.mp4" )
clip_2 = moviepy.editor.VideoFileClip( "Video_2.mp4" )
Mearged_video = moviepy.editor.concatenate_videoclips([clip_1,clip_2])
Mearged_video.write_videofile( "Output.mp4" ,codec = 'libx264' )
print ( "Done" )
|
Output:

To know the length of the video:
Python3
import moviepy.editor as me
vid = me.VideoFileClip( "Video_1.mp4" )
print ( str (vid.duration))
|
Output:
9.04
Advantages of MoviePy
- Simple: Basic operations can be done in one line, code is easy to learn and easy to understand for newcomers.
- Flexible: Users have total control over the frames of the video and audio, and creating their own effects is easy as Py.
- Portable: The code uses very common software such as Numpy and FFMPEG. And can run on almost any machine with almost any version of Python.
Disadvantages of MoviePy :
- MoviePy cannot yet stream videos (read from a webcam, or render a video live on a distant machine)
- It is not really designed for video processing involving many successive frames of a movie (like video stabilization, you’ll need another software for that)
- Memory problems can arise if the user use many video, audio, and image sources at the same time (>100)