---
title: 'Automated Video Editing with MoviePy in Python'
source: 'https://youtube.com/watch?v=Q2d1tYvTjRw'
video_id: 'Q2d1tYvTjRw'
date: 2026-07-28
duration_sec: 847
---

# Automated Video Editing with MoviePy in Python

> Source: [Automated Video Editing with MoviePy in Python](https://youtube.com/watch?v=Q2d1tYvTjRw)

## Summary

This tutorial demonstrates how to automate video editing in Python using the MoviePy library. It covers cutting, combining, adding effects and transitions, and incorporating audio. The video provides a hands-on example with sample clips.

### Key Points

- **Installing MoviePy** [0:26] — Install MoviePy via pip: 'pip install moviepy'.
- **Importing MoviePy** [0:41] — Import the editor submodule: 'from moviepy.editor import *'.
- **Creating a Subclip** [2:58] — Use VideoFileClip('file.mp4').subclip(start_second, end_second) to extract a portion.
- **Concatenating Clips** [4:46] — Use concatenate_videoclips([clip1, clip2, ...]) to join clips sequentially.
- **Writing the Final Video** [5:11] — Call combined.write_videofile('output.mp4') to export.
- **Adding Video Effects** [6:30] — Apply effects via clip.fx(vfx.effect_name, parameters). Example: vfx.colorx(1.5).
- **Adding Transitions** [9:00] — Use vfx.fadein(duration) and vfx.fadeout(duration) for fade transitions.
- **Adding Audio** [10:45] — Load audio with AudioFileClip or extract from video. Use composite_audio_clip to combine.
- **Audio Effects** [11:09] — Apply audio effects with afx.audio_fadein, afx.volumex, etc.

### Conclusion

MoviePy enables automated video editing in Python, allowing you to cut, combine, add effects, and manipulate audio programmatically. This is useful for repetitive tasks or generating compilations.

## Transcript

[Music]
what is going on guys welcome back in
today's video i'm going to show you how
you can automate video editing in python
using movie pie so let's get right into
it all right so what we're going to do
is we're going to edit videos we're
going to cut videos in python we're
going to add some effects and for this
we're going to use the library movie pi
which is an external library which means
that we need to install it using the
command line so we open up cmd on
windows or the terminal on linux and mac
and we type pip install
movie pi like that
once you've done that you will be able
to import it so we're going to say from
movie pi and we're going to use a sub
module editor so we're going to say from
movie pi dot editor because we can do
different things with
uh with movie pie so we're going to pick
the editor to edit videos and from the
editor we're going to import a bunch of
classes and functions and so on so
if you just want to play around you can
use a wildcard import but never use it
in code if you have to import many many
things in code you might want to use an
alias something like import
moviepie.editor s i don't know me or
something i think there might even be a
convention for that uh but don't just
import everything you can do that if you
just want to play around and if you want
to to experiment uh for today's video
we're just gonna import everything
manually and the first thing you want to
import here is the video file clip and
before we continue with the code let me
show you what the basic idea is of what
we're going to do today so i have here a
directory with
an intro mp4 which is a neural nine
intro and we have two videos which are
copyright free um so i got them from
pixabay
to to be able to show them in that video
here
and when we open one of these videos
here we're going to see they're quite
simple so just some smoke
um 59 seconds you can see some smoke
animation here
and the second one is also something
similar
as you can see here
um and then i have the neural nine intro
which i'm mainly going to use for the
music so we're not going to use the the
intro itself really as a video and the
basic idea is just to show you here how
you can add it how you can combine how
you can cut videos with movie pie and
python uh it is quite interesting
especially if you want to i don't know
do some compilation style video or you
want to do some random compilation or
you want to just automate your video
cutting process if it's always the same
you just need to enter the seconds or
something like that uh there are many
use cases for that so i'm going to give
you the very simple example of just
picking these videos that i showed you
taking parts out of them combining them
then adding some transitions then adding
some music and so on uh just to see how
this works
so the first thing we want to do is we
want to define clips we want to take for
example
the first video of the smoke animation
if we want to take
the part from second 10 to second 20.
how do we do that we can say something
like clip 1
equals and then i say video file clip
and here i enter the file name now so i
enter 1.mp4
which is the first video and then i can
apply
certain functions at the end of that
video file clip so i can say ok dot sub
clip and this is going to return again a
clip now if i'm not mistaken video file
clip
um
do we see that here
okay we don't see that but video file
clip returns a clip and when i then
apply sub clip it returns a clip and i
think that when i apply something else
it also returns a clip so it's a little
bit like a
builder as far as i know but the
important thing is we we do something
like mp4 and then
dot sub clip and here we specify
second 10 second 20. this means we take
the video uh at the location1.mp4 this
is the file name then we sub clip
meaning that we take uh the part of the
video from second 10 to second 20 and
then we can add some more stuff in the
end if we want to we're just going to
leave it like that for now then we can
say clip 2 equals video file clip 2.mp4
and we can do something something
similar here so for example
same time range and then we can say okay
clip three is going to be just
the
one mp4 again
dot sub clip 20 30 for example just to
mix it up a little bit
um
[Music]
yeah so this is without effect this is
without transitions this is just a basic
uh the basic clips here and now we can
go ahead and combine these into one full
video that we then save that we then
export to the hard drive and how we can
do that is we need to import another
function which is called concatenate
video clips
and as the name already says it
concatenates video clips so we're going
to say combined equals concatenate video
clips and here we basically just pass a
list of clips so clip 1
clip 2
clip 3 like that
and all we need to do now to produce to
produce the final video is combined dot
write video file and then combine dot
mp4 for example
so we run this and we're hopefully going
to see the progress here you can see
it's working
uh it may take a little bit longer if
you don't have a strong computer and
then it's done we can go ahead and open
it up in the explorer
and then just click on it and you can
see here that we have the first 10
seconds are the animation from video one
from the second 10 to second 20 and then
after 10 seconds we're going to switch
you're going to see here there you go it
switches and then
at around second 20 there you go it
switches back again so we just combined
three clips we took a video we took two
videos we got some clips out of that we
combined them in a certain order and
that's basically it so this is how you
basically just cut videos now you can
also add some animation you can add
transitions you can add effects uh so
let me show you a very simple one you
can go just ahead here and say clip four
and we're gonna take uh let's say again
10 20 so we basically take the same clip
but we're now gonna add some effects and
how do we add effects now i'm not sure
if we need to import that no we don't
need to import that but we need to
import uh something else so we can call
the dot fx function to add some effect
to add some filter basically and here
now we need to use vfx so we need to
import vfx and we're going to use vfx
for
um
for all sorts of filters for all sorts
of video transitions everything that's
related to video effects is in vfx
everything that's related to audio
effects is in afx so later on we're also
going to import afx now let me just see
if you can see all the imports yes you
can
um
and now what we can do here is we can
just say okay
let's say vfx dot color
x
and now i can just say 1.5
and this is going to change the color
color x value
i can also change the contrast now let
me just start a new line here how do we
do that in python again like that right
uh so
dot fx and then vfx dot
loom underscore contrast and we're gonna
say this is 0
50
128 or something
i hope these are acceptable values now
let me indent that a little bit here
and
now we can just add this clip here in
the end and this is going to take some
time probably because it has to do the
calculations so you're going to see that
when it works it's going to start quite
quickly and then in the end it's going
to take some more time i think there you
go
now now it uh it is a little bit slower
because it has to apply onto each frame
all these effects now those are just two
effects but if you have a lot of effects
on each frame this needs to be
calculated what it looks like and so on
uh and then it produces the final video
and now we're going to see that we have
an additional clip an additional 10
second clip
and if we open this up again
in the explorer
and we go to the end you're going to see
that we now have this thing here which
is essentially
uh the first
the first clip with these filters again
i didn't choose quite i didn't choose
any
interesting or meaningful filters i just
showed you something again if you want
to see all the functions like usual you
just go to documentation but this is the
general idea you call the fx function on
a clip and then you pass vfx for video
effects and then uh you you pick some
filter you pick some setting that you
want to change
now
another thing that we can do here is
transitions as i already said so what i
usually do in my videos you have
probably noticed is i have one clip at
least when i split the video up into
multiple clips i have one clip and then
in the end i have a one second
fade out or half a second fade out and
then fade in again
to switch between the individual clips
so we can do something similar here as
well we can just say fx and then vfx
dot fade in
and then specify the second so one
second fade in
and then also
fx vfx and now i think i'm starting to
block the code right
there you go so let me just move this
down here
um i can say vfx dot fade out
and
vfx fade out is gonna have also one
second and now i can just take this here
i can copy this and i can
paste this
and there you go
and that will then generate a simple
fade in fade out effect now before we
just do that i also want to add an audio
clip or actually let's first see what
what this looks like since we don't have
the effects now anymore this is not
going to take too long uh but then we're
also going to get uh we're we're going
to add the audio from my intro just to
have some audio again the result of this
is not going to be a fancy video it's
just showing you how to use everything
and then you can make your own fancy
video if you want to
but now we should be able to see a fade
in effect there you go we saw the fade
in effect now
at second
10 we see it fade out fade in and so on
and so forth so this is quite useful um
if you want to use python for video
editing i don't i use davinci resolve
but still you can use python for video
editing if you want to
now let's go ahead and
get the audio clip and for that we're
going to also import here the audio file
clip
and we're also going to import afx for
the audio effects
um and how do we do that essentially we
just say okay audio equals audio file
clip and we don't have to load an mp3 or
an audio file we can also get a video
file and get the audio from that video
file
and now we can add some some effects
here as well so we can say fx and then
for example af afx dot audio
underscore
fade in
to fade in the audio obviously and also
here we can specify a second
and then we're going to say fx
af afx and we can change the volume now
let's do it first without the volume
change i'm actually not sure if you're
going to hear something because i think
i have disabled the desktop sound
um
but
this is how you create your audio clip
and now to the final video clip you just
have to say combined dot
audio equals and then this is another
thing that we need to import here
composite audio clip
um
and we just say here composite audio
clip
audio like that
so we can run that and then it's going
to get the audio from the intro again i
don't think that you're going to hear it
maybe i can change something about the
settings here
so i now enable the desktop audio maybe
you're going to hear something if not
you can just run this on your own
computer and you're going to see
that the audio is there
and
again
[Music]
you want to do it on your own and um now
we can add a final filter here we can
just say fx
af x dot
uh what was the name volume x and this
basically means that we can
uh increase or decrease the volume so if
i say 0.1 we're not going to hear
anything now i don't know if you heard
anything
um
right now but if you have heard anything
right now now you would hear it way uh
way more silent
so the the volume is going to be
decreased and we can see the effect
hopefully you can also hear it in the
video again otherwise just try it on
your own
and there you go
so there is still audio but it's very
very
silent
i'm not sure if silent is the correct
word so this is how you can cut videos
how you can edit videos in python you
just have video clips you have audio
clips you can
cut them you can add effects you can add
transitions you can change the audio you
can fade in fade out and a ton of more
things that you can read about in a
documentation this was a very basic
introduction i hope you enjoyed it and
that's it
so that's it for today's video i hope
you enjoyed it and i hope you learned
something if so let me know by hitting
the like button and leaving a comment in
the comment section down below and of
course don't forget to subscribe to this
channel and hit the notification bell to
not miss a single future video for free
other than that thank you much for
watching see you next video and bye
[Music]
you
