---
title: 'Video Editing in Python Using MoviePy - Part I'
source: 'https://youtube.com/watch?v=2t0I0URiS40'
video_id: '2t0I0URiS40'
date: 2026-06-15
duration_sec: 0
---

# Video Editing in Python Using MoviePy - Part I

> Source: [Video Editing in Python Using MoviePy - Part I](https://youtube.com/watch?v=2t0I0URiS40)

## Summary

This video introduces MoviePy, a Python package for video editing, covering installation, basic operations like loading, cropping, rotating, and overlaying text on videos. It demonstrates how to use MoviePy in Jupyter notebooks for video manipulation and saving.

### Key Points

- **MoviePy Overview** [00:50] — MoviePy is a powerful Python package for video and audio editing, including text overlays, cropping, special effects, and frame-by-frame processing (though OpenCV is recommended for the latter).
- **Installation** [03:06] — Install MoviePy via pip install moviepy. ImageMagick must be installed separately for text effects. Pygame is optional for video previews.
- **Importing and Loading Clips** [05:31] — Import from moviepy.editor. Use VideoFileClip to load a video file. Clips have properties like size, duration, and fps.
- **Displaying Clips in Jupyter** [08:51] — Use clip.ipython_display(width=...) to embed a video in a Jupyter notebook. Large videos may exceed memory limits; use subclips instead.
- **Subclips and Saving** [10:57] — Create subclips with clip.subclip(start_time, end_time) using (hours, minutes, seconds) format. Save clips with clip.write_videofile(path).
- **Rotating and Volume** [14:27] — Rotate clips with clip.rotate(angle). Adjust volume with clip.volumex(factor) where factor >1 amplifies, <1 reduces.
- **Text Overlay** [17:14] — Create a TextClip with text, fontsize, color. Set position (static or moving via lambda t). Set duration and composite with video using CompositeVideoClip.
- **Composite and Effects** [20:50] — CompositeVideoClip layers clips. Set start time and crossfade-in effects. The final clip can be displayed or saved.

### Conclusion

MoviePy provides a simple yet powerful API for video editing in Python, enabling tasks like cropping, rotating, volume adjustment, and text overlays with minimal code. It is ideal for beginners and intermediate users looking to automate video editing workflows.

## Transcript

[Music]
[Music]
[Music]
hello
and welcome to video editing in python
using moviepie
video series this is part one of this
video series
and in this particular part we are going
to discuss
what pie is what it can do how to
install it
and how to get started with it movie pie
basically
is a very very powerful package
for video editing not just video you can
you can actually work with audio you can
work with text you can overlay text
on the video you can change the video of
one clip to another you can actually
make your own tick tock
uh just by picking a video from
the video images from some other source
and
audio source audio clip from another
source and just mixing them
up um not only that you can crop videos
you can
you can just give special effects to the
videos you can
you can actually do frame by frame
processing uh
using movie pi although uh using frame
by frame processing
is not really recommended uh in movie pi
there are some better packages for frame
by frame processing like opencv
and some simple cv and some other
packages
but moviepie basically give you a very
powerful
api for working with working with videos
audios and text and
making custom animations uh combining
different clips together
um and and making another clip and stuff
like so
so um yeah in this particular part
we will be uh actually getting started
with uh
video editing uh basically
we'll be uh loading videos we'll be
playing videos in jupiter notebooks we
will also be saving
uh videos on hard disk uh we will be
cropping videos we will be
picking sub clips we will be actually
changing
um changing audio of
a video with audio of another video
um we will also be seeing how to display
overlay text over a video or how how to
actually make the text moving on on a
video
so everything basically is in this uh in
this part
uh in the next part however we will see
in the next part of this video series we
will be actually seeing
how to combine different clips together
uh
and make one video that actually
contains a lot of videos
um and in the third and final clip of
this video series we will be actually
seeing how to make custom animations
um using movie pie so let's dive in
uh first of all um how to install it um
just write pip install movie pie and
that's it
it will get installed um there are some
dependencies
that uh moviepie automatically installs
for you
um but one thing that um that is
worth mentioning is image magic tool
that you have to install
uh separately so it's always good to
install
first the image magic and then install
moviepie um
then there are some config defaults file
config defaults
config underscore defaults dot pi file
in movie pi in which you have to you
have to set the path of image magic
in my machine however i just installed
image magic i
reboot the system and everything works
automatically
but in certain cases you may have to
work with config defaults
maybe you also have to install pygame
that also has
some dependency with movie pie but most
of the stuff
is just done using this movie pie and
image magic
if you for example go to the owner's
page silko it's the owner of this
package uh there are these clear
instructions so
you can see the zulko github.io moviepie
slash
you can go to download and installation
and it actually guides each and
everything
how to install it uh what kind of
dependencies are there
uh how to change this config underscore
defaults if required
uh for dependencies you have to use this
image magic
how to change the path of the image
magic and stuff like so
and also you may need the spy game for
video and sound previews if you really
want to see the previews
um if you want to see the previews there
is a function clip dot show if you want
to use that you may need this buy game
uh installed so yeah and and that's a
good page by the way it
uh it actually contains a lot of
documentation a lot of example scripts
and a lot of stuff
um and it's uh to to learn movie pie in
detail
it's good to just go through this page
first
so yeah um uh
let's let's basically start um coding in
moviepie let me just set the
zoom level to a better level uh let me
uh yeah so first of all
um we have to from
we have to load most of the stuff is
done by movie pie dot
editor so movie pie dot
um editor from there
if you want to import certain modules
you can import certain modules
if you import if you want to import
everything although it's not recommended
because it makes things slow but
um here is we have imported each and
everything
um from this movie pi now next what we
do is
uh we read a video clip from from the
hard disk here i have some video clips
downloaded from youtube so let's read
2 dot mp4 and see its properties
so 2 or mp4 that's the path
and here we go back so let's say
clip equals
video file clip that is there
in moviepie dot editor video file clip
there are
there are basically three kinds of clips
video clips
uh audio clips and text clips so video
file clip
are that is for the raw
string and here you actually
read the clip so yeah the clip has been
read
there are several properties that we can
see about this clip for example the size
of this clip
so width and height is clip dot
size what is the size of this
clip so let's print width and height
and the size of this particular clip is
the width is 480
and the height basically is 360. so that
for this particular clip
that's the width and height there are
other
for example other properties of this
clip as well
so for example clip dot duration
what is that the duration of this clip
in seconds
is 283 seconds if we for example divide
this
by 60 we may get
the minutes which is four minutes and
roughly
the rest is again the seconds so around
four minutes four point some
uh minutes so 4.72 minutes so if we
multiply this point 72
with 60 we get exactly the number of
minutes that are there
further we can we can also see several
things
let's see for example clip dot fps
frames per second this video has been
recorded
in how many frames per second a frame is
an image in in videos normally in one
second
it actually saves a lot of images those
images are called frames
so this frames per second is a property
for high resolution images these
high resolution video images this fps
number is really large
which means for one second you are
saving a lot of details a lot of
frames so in this particular case for
this particular video the
frames per second property is really 30.
um we can have a sub clips
if we really want before before actually
going towards the sub clip and stuff
like so
let's actually display this clip uh in
in in the jupyter notebook so
clip dot ipython
display so clip dot ipython display and
here you can set the width uh
inside the notebook for example the
width
i'm setting the width like let's say
280 maybe maybe i can set the width
maybe the original width or maybe for
example
350 and it will automatically
uh actually it will automatically take
care of the aspect ratio and
will convert the height accordingly so
that will do
that will actually embed the clip in i
in this jupyter notebook so let's see
how it goes uh it will take some time
because it is rendering
so yeah it will take some time it's a
it's a long clip it will take some time
to render it
so yeah let's let's wait for it
rendering
and then we will be actually we will
actually be able to
uh see it's playing inside the
inside the notebook so let's see let's
wait for it
it is rendering um
yeah or maybe i can just
pause the video and once the rendering
is up then i then i get back to this
video against to
to save the time so let me
let me get this thing finished and then
we will see
if oh it's an error what kind of error
is this
not the embedding large videos may take
all the memory away so this video
basically is
oh this video is basically large and it
exceeds the maximum duration so it
cannot be embedded
uh inside the uh inside the notebook so
let let's just let's just get a sub clip
of this video and
and and show that so why not why not
just pick
the sub clip of that video so clip two
is clip dot sub clip
and um i actually
get the sub clip with the ending time
as as 0
0 30 that means
um pick the sub clip of the image
starting from the very beginning
but the end time is 30 seconds this the
first
argument is for hours the second
argument is it argument is for minutes
and the third argument is for seconds
so what i'm saying here is uh start from
the very beginning
and go till 30 seconds and crop and
and just and just get the sub clip and
copy that
into clip two uh you can set the dstart
property here tn property here
separately and
you can work with that as well so that's
clip two
now let's uh let's display this clip too
maybe it is faster clip two is
dot i python display
this is faster maybe because uh the
the duration of this clip is smaller
width is let's say
uh 280 maybe so
let's see uh if it is a little bit
quicker
let's see so yeah
so here it has actually rendered that
inside this
jupyter notebook and now you can see you
might be
uh hearing the the sound of the
the sound of the video as well
[Music]
so these are the 30 seconds of the video
[Music]
and not only that i mean you have you
have
found the sub clip no if you really want
this sub clip
or the part of the video to be saved on
the hard disk
you can actually go and write clip
to dot um
right video file
and there you have to give the path of
the video file where you really want to
save it
so for example um let me give the path
like this
and here we go
and here we say ok to clipped
and it will start actually writing that
onto the hard disk for you
there are certain extensions there are
certain extensions that are supported
uh i'm right now i'm working with mp4
there are a couple of others as well
so yeah it has done so let's go to hard
disk
and actually see this is too clipped so
let's open up it
in windows media player and here you're
seeing the 30 minutes clip
30 seconds clip yeah
yeah so
that's the very beginning of uh
this clip sub clip and stuff like so
let's play
uh with it a little bit more let's say
for example
clip three is clip
two dot rotate
uh with 180 degree so what it will do is
it will rotate the clip
uh with 180 degree and then if you
really
want to embed this if you really want to
see this
clip 3 dot
ipython display oh
the clip 3 is not created yet so this so
clip
3 dot python display
um and whatever the original length is
so i will i will go with that so that
will embed there
remember all the operations here in this
movie pi they
uh actually are not performed on the
whole video
until the video is rendered for either
display
or embedding in the notebook or or if it
is going to be
written on uh on in the in the hard disk
so at the very final time the video is
rendered and at that particular time it
takes some time so
uh let's see basically if i have rotated
the video
by 180 degree it actually flipped the
video upside down so
let's see how it goes yeah so
that has a larger size let me uh
let me do a little bit yeah so if you
now see
the video is just upside down
and there are a lot of effects that you
can go through with
um right now um i'm going to basically
um add um add a text
clip on the on on on this particular
video clip
so we will be having video clip two what
i'm going to do
is i'm going to uh overlay text
on this video clip too um you can you
can have
several other functions for example
clip 2 is clip 2
dot volume volume
x and that if for example i set the
value 0.7
that means reduce the volume of my clip
um by by i mean just keep the 70
of it and reduce it by 30 percent and
and you can give this number to be
larger than one and the volume become
increase
amplified so and and there are so many
other functions there are so many other
functions
you can just uh you can just check right
now i'm going to basically
um uh write a write a floating text
on on this video and the resultant video
will be saved
or displayed in the notebook or can be
saved in the hard disk either way
so we already have clip two let's make a
text clip
so let me write text clip
is text clip that is there
in movie by dot editor um
let's say the text clip contains the
text as
a i sciences i
ai sciences um and for this text clip
the font size
is let's say let's say the font size is
150
and the color let's say the color is you
can have different colors
uh let's say the color right now is
let's say
we have red color so that's our text
text clip uh next what we do is uh we
set the
set the position of this text clip so
text
clip is equal to
text
clip unlike other object-oriented
packages where
you write a dot and you call certain
functions and the properties are changed
inside um this moviepie actually returns
a copy and you have to save the copy
otherwise the changes are lost
so that's why i actually i'm saving i'm
doing i'm
going to change the properties of text
clip but the
properties they will not be reflected
inside this object but it returns an
object that you have to save somewhere
otherwise
they will not be saved exactly here
which is
uh which is something something
different than
the ordinary uh object oriented
programming where
we actually change the properties inside
the object
so position
so position and we can set several
positions we can we can for example i
can just set the position
um 20 and 20 that means for screen
size for the m for the clip size go to
2020 and just place that
text uh what what other thing that i can
do is i can change the position with
time using a function let's say lambda
t that t is the time
t basically is the time and we are going
to change this
the position time by time so let's say
10 historic t
then steric t so that means for every
time unit
go to this particular position and
display the text
further i have to set the duration
of the clip duration
let's say the duration duration of the
text
let's say the duration of the text is
the duration of or or let's say duration
of the
let's say duration of clip 2.
duration so that's um
our text clip ready and positions are
set
what next is we need to overlay this
text
onto the video so let's make a final
clip or video
final video and here we will be using
composite function composite class
composite video clip class
um we will see the composite video clip
class
in more detail in our next part of the
same series
right now i'm just using it clip 2
and then we have this text clip
and we can set the start of this clip
when should it start let's say it should
start right after
two seconds of the clip two video
and then we can have effects like a fade
in
effect so let's say cross
fade in how many seconds it should
fade in it should appear it should take
how many seconds to appear in the video
let's say let's say three seconds and
that's our video
um yeah video is ready now once
the video is ready now we can either
embed it
in ipad ipython notebook or we can save
it
so let's embed it in the notebook video
dot
ipython display and
let's display it in
with width let's say
280 let's say um
yeah so let's see how it goes
it will take a few seconds to render it
so yeah
almost done um not almost i mean
but getting closer and closer and this
uh text will appear in the floating form
on this uh video so let's see that
[Music]
yeah so you can see this oh the font
size is too big
the font size is too big for for this
video
so let's go back and let's go
back and reduce the font size the font
size is let's say
um let's say 20.
let's go back let's re-render it
because the font size was too big to
appear on this video
so let's see how it goes now with the
new font size
[Music]
oh you can see this a sciences
um yeah it is floating over the video
you can have special effects for this
you can have you can have
certain characters to appear one by one
and moves on
it will stay as long as the
the video continues because we set the
duration as the duration of the video
clip
so yeah that's cool we have done a lot
of stuff
just in just in a very small amount of
time
and that's the power of this package i
mean if you want to start video editing
um you want to play with audio you want
to play with
text uh this is the this is one
of the best packages to really start
with
um yeah uh i end this part here in the
next part i will be
actually going a little deeper and i
will be telling you how to
combine different uh video clips
together
to make a final video that has um that
has a combination of several clips
and we will be primarily using concave
we will be primarily concatenating
videos we will be actually arranging
them in a matrix form
or actually more precisely we will be
using this uh
composite video class uh composite video
clip
class um to to get special kind of
effects
um and in in the last part of this video
series part three
we will actually be making our custom
animations so hope to see you in the
next
part
[Music]
[Music]
[Music]
you
