---
title: 'Automate Video Editing with Python & MoviePy – Build Scripts That Work'
source: 'https://youtube.com/watch?v=6o181BEx04E'
video_id: '6o181BEx04E'
date: 2026-06-15
duration_sec: 0
---

# Automate Video Editing with Python & MoviePy – Build Scripts That Work

> Source: [Automate Video Editing with Python & MoviePy – Build Scripts That Work](https://youtube.com/watch?v=6o181BEx04E)

## Summary

This course teaches how to automate video editing using Python and the MoviePy library. You will learn to write scripts that can mass-process videos, including resizing, cropping, adding text, music, and transitions. The course uses a real-world project: automatically compiling the best moments from a video game into a polished, full-HD video ready for publishing.

### Key Points

- **Course Goal** [00:02] — Learn to use the MoviePy library to automate video editing with Python scripts for mass processing.
- **Real-World Project** [00:10] — Automatically compile best moments from a video game (Valorant) with edits, representative of real-world automation.
- **Tools Used** [01:28] — Visual Studio Code is used as the code editor; Python and VS Code installation is covered.
- **Python Installation** [02:39] — Download Python from official site, check 'Add Python to PATH', install, and optionally disable path length limit.
- **VS Code Installation** [04:29] — Download and install Visual Studio Code, then install Python and Code Runner extensions.
- **Testing Python** [06:50] — Create a Python file, write 'print("hello world")', save, and run using the Code Runner button.
- **Installing MoviePy** [07:58] — Open terminal and run 'pip install moviepy' to install the library.
- **Project Resources** [08:36] — Download a zip file containing clips, resources (intro, outro, music, transition, font), and an empty Python script.
- **Assembling Clips** [14:15] — Use glob to fetch all MP4 clips, convert each to VideoFileClip, resize to 1920x1080, and concatenate using concatenate_videoclips.
- **Exporting Video** [23:41] — Write the final video to an MP4 file with 60 fps using write_videofile.
- **Adding Background Music** [29:01] — Load an MP3 file with AudioFileClip, loop it to match video duration using audio_loop, and composite audio with CompositeAudioClip.
- **Adding Intro and Outro** [42:00] — Load intro and outro MP4 files, convert to VideoFileClip, and concatenate them with the main clips.
- **Adding Transitions** [54:03] — Load a transition MP4 file, convert to VideoFileClip, and insert it between each clip in the loop.
- **Adding Text (Author Names)** [65:40] — Extract author name from filename using os.path.basename and string methods, create a TextClip, and composite it over the video using CompositeVideoClip.
- **ImageMagick Installation** [66:39] — Install ImageMagick for text support, then configure moviepy's config_defaults.py with the path to magick.exe.

### Conclusion

By the end of this course, you can create a Python script that automatically assembles clips, adds music, intro/outro, transitions, and text, producing a professional full-HD video ready for publishing.

## Transcript

Hello everyone. Welcome to this course
dedicated to learning the movie PI
library for Python in order to automate
the editing of your videos. The goal of
this course is to teach you how to
develop Python scripts capable of mass
processing your videos. You will learn
how to write Python scripts to process
hundreds of videos at once. Whether
resizing, cropping, converting formats,
adding text, music or transitions, Movie
Pie greatly simplifies mass video
editing while producing a professional
quality videos ready for publishing on
online platforms. In this course, we
will work on a real world video editing
automation project. It will involve
automatically compiling the best moments
of a video game with a series of edits,
which is a representative real world
case that can be easily automated to
handle large amounts of video. The
Python script can then be reused for any
other type of compilation such as
compilations of sports highlights,
compilations of funny animal videos,
etc. And you don't need any prior
knowledge as the course explains
everything you need to know and provides
all the necessary resources. You can
complete the course at your own pace. So
without further ado, let's start this
course together to learn how to automate
your video editing with the Python and
Movie Pie.
During this training, I will be using
the code editor Visual Studio Code. It
is a widely used code editor that offers
many advantages. So if you also want to
work with it, I will show you in the
next video how to install it on your
computer and how to install Python with
it if it's not already done. However, if
you already have a code editor installed
on your computer that you prefer to use,
you can certainly continue using it
during this course. You can use any code
editor you prefer. And for those who
want to install Visual Studio Code as
well as Python if it's not already done,
we will see how to do all that in the
next video. In this video, we will see
how to easily install Python and Visual
Studio Code. You will see it only takes
a few steps and a few minutes, allowing
us to access to this very widely used
development environment. It is currently
the most popular development environment
in the world used for many languages
including Python. So to begin, we will
first install Python because we need the
programming language installed before we
can use it in Visual Studio Code. So
let's go to the official Python page.
Click on downloads. And here you should
see a yellow button offering to download
the latest version of Python for your
operating system. Since I'm on Windows,
it suggests downloading Python for
Windows. I can see that they are
proposing me the version 3.11 of Python,
but by the time you watch this video,
there may be a newer version like 3.12,
3.13. You can just download the version
displayed on your screen without any
issues. So, let's click on download
Python. Theex file starts downloading.
Let's wait for it to download. All
right, so it's done on my side. And once
it's downloaded, we can launch the
executable file. So we have this window
that is appearing here. It's very
important check the box add the
python.exit to path. So this is a small
option related to what we call
environment variables. I highly
recommend checking this box as it might
not work properly if you don't. Then
let's click on install now. Click yes
and wait for the installation. Once the
installation is complete, we get the
message setup was successful. So the
installation went correctly. We can
click on this option disable path length
limit because on some operating systems
particularly Windows there is a limit on
the length of path for accessing a file.
If your path exceeds 260 characters, it
might be impossible to navigate through
such a long path and retrieve a file at
the end. This situation rarely occurs
but to be safe we can click here then
click yes and it's done. We can click on
close and now Python is installed on
your computer. Next we will install
Visual Studio Code. Now that we have the
Python programming language on your
computer, we need a development
environment. Basically a software that
will allow us to easily write and
execute Python code. And for that we're
going to use Visual Studio Code. So
let's search for Visual Studio Code.
Click on the first link and then click
on download. You can select your
operating system. Again, since I'm on
Windows, I choose Windows. And then we
can see that it starts downloading.
Let's wait for it to download. All
right, it's done on my side for the
download of VS Code. Once it's done,
similarly, click on the X file. It will
launch. Then here we can click on I
accept the agreement then next. You can
change the installation folder if you
wish but I'll continue clicking next.
Leave it as default. Click next again
and it's installing.
Perfect. So the installation was very
quick.
It will launch and we land on this
window.
So you can close the welcome window if
you want.
You can change the theme to either a
white background with different colors
or a black background with higher
contrast. I recommend keeping the
default theme which is dark and modern
to avoid the eye strain. You can now
close this window.
Now before we start coding, let's
install two extensions to facilitate
programming in VS Code.
So click on the extension button here.
Then install the Python extension which
is the first one.
Click on install. It's very quick.
And once it's installed, we can install
another extension called code runner
which will add a button to easily
execute Python code. So click on
install. Again, it's very quick.
Once done, you can close these two
windows.
I recommend closing and reopening VS
Code to ensure all extensions load
correctly. Do this just once after
installing the extensions.
Now, let's test a Python code to see if
everything works correctly. So, we can
create a new Python file by going to the
top left. Let's click on new file and
select Python file. You can write here
anything. I will type print hello world.
the typical first code when learning a
new programming language.
Let's save the file by pressing Ctrl S.
Save it on the desktop. For example,
name it test and click save. Now the
file appears on the desktop as a test.
py. Now execute it by clicking on the
run code button and you should see the
text hello world in the console.
Perfect. So that was all for this video.
We saw how to install Python, Visual
Studio Code, and some extensions to make
writing Python code easier. During this
training, we will use the Movie Pi
library, which was developed for Python.
This library will allow us to do video
editing in Python and more importantly,
it will allow us to automate the editing
of videos massively. Note that this
library does not come with Python when
we install Python for the first time. So
you will need to install it separately.
To do this, it's very simple. Open your
terminal and then simply type pimp
install pie like this.
You can do this in a virtual environment
if you prefer. Once done, press enter.
The Movie Pi library will then be
installed. So I've already installed the
library on my side, so I don't need to
do it again. But you will see it will
install quickly and then we can start
developing. So that was all for this
video. Thank you everyone.
All right. So you will find in the
description of this video the resources
that we will use during this training.
It is a zip file that you can download
and it is approximately 160 mgabytes. So
it might seem a bit large but that's
normal because it contains videos that
we will use for the training. So these
are the videos that we will assemble
using movie pie and where we will do
editing. So I invite you to download the
zip file. You can place it somewhere on
your computer. You can create a brand
new folder that will contain the entire
project that we will do during this
training. So that's what I did. I
created a new folder called the Movie Pi
course. And in this folder, I placed the
zip file that you can download from the
description. So let's extract this file
to retrieve the files inside. I click on
extract all and then I click on the
extract button. Now we have this folder
that appears. Let's go inside right
away. Inside this folder we can see that
we have three other folders and a file
in in the Python format. We will go
through each of these elements one by
one. So we can see that we have a first
folder called the clips. If we go
inside, we can see that we have 10
videos in MP4 format. So these are
videos that are about 30 seconds long
and our clips from the video game
Valerant. So during this training, these
are the clips that we will use and we
will see how to assemble them, edit them
using Python and Movie Pie, add music,
transitions, an introduction, etc. The
idea is that we can then use this script
for many other clips to generate
automated videos whenever we have clips
like this. So in this video, we'll make
a compilation of the best moments from
the game Valerant. But you understand
that the script can work with any other
of video game clips or it can also be
clips for anything really. It could be
clips of the best moments in sports, in
football for example, etc. So that will
be our goal during this training.
assemble all these clips automatically,
edit them and finally obtain a full HD
video that we can then publish on the
video platforms. So here I have just
taken 10 clips. We could have added more
but it is sufficient for this training.
You can then go back to your folder. We
will see another folder called the
output which is empty for now. And this
is the folder we will use to store the
final videos generated by our Python
program. For now, it is empty because we
have not yet created the program and we
have not yet executed it to have the
final video created by the program.
Let's go back to our folder. And
finally, we have the resources folder
where inside we have a number of
resources that we will use for the
editing. We have a font that we will
use, an introductory video that we will
place at the very beginning of the video
before the clips play, a music track
that will play in the background, an
outro video. So, this one is the very
last video that will be shown at the end
of the video, and finally a transition
video file between each clip. You will
see we will integrate each of these
elements as the course progresses. Next,
we can return to the folder we have
created. And here we finally have a
Python file that is currently empty. So
I open it and we can see that inside
there is no code, nothing. I just
created it and placed it in this folder
to save some time for you. And it is in
this Python file that we will write all
of our code. All right. Also, if we
click on this little button here, the
explorer button, we can see that there
is no folder attached to Visual Studio
Code currently. So, what we will do is
click on the open folder button here.
You can also do it by clicking on the
file button, then open folder. So, I
click on it and then I have to find the
folder where the Python script is
located. So we have the movie pi course
resources folder and as soon as we enter
in this folder we arrive here where we
have our three folders clips outputs and
resources and this is the folder that we
will open. So I click on the select a
folder button my visual studio code
window refreshes and then we can see on
the left that I have the three folders
of my directory. So again we have the
clips folder which contains the 10 clips
we will work on, the output folder which
will contain the videos we will create
and the resources folder which contains
the various resources we will integrate
into the video. And of course we have
the Python file that I have just showed
you which is currently empty and on
which we will write all of our code. So
when you want to execute the code or
modify it, always remember to open the
folder where all these elements are
located. So they will be displayed here.
And this way the Python script will not
have any problems finding the different
resources because the Python code here
will need these resources to create the
video which you will see later in this
course. Again, the zip file to access
these resources is available in the
video description. So feel free to
download it and once that is done we
will meet in the next video to start the
development.
Now that you have put in place all the
necessary resources for automatic video
editing. We can start the development.
First if we open the clips folder
contained in the zip file we downloaded.
We can see the different videos we will
be looking to assemble and edit during
this course. Here we have taken the
example of 10 clips from the video game
Valerant. But of course they can be
clips of anything. You just need to have
a series of videos to assemble and the
code that we will write will work. So
let's open one of the clips together to
see what the video contains.
>> Nice.
Got him.
Spike down.
>> One enemy remaining.
>> So, as you can see, these are best
moments clips from Valerant featuring
some great actions on the video game.
So, we have 10 of them. And uh in this
first video of the course, we will
develop a method to assemble these 10
clips into a single MP4 video that
combines all of them. For that, we can
go back to Visual Studio Code and let's
create a video in MP4 format that
combines all of them. So here I'm in the
folder that we've obtained with the zip
file. You can just open the automatic
video editing Python file which is the
Python file we will use throughout this
training for our development. It is
currently empty and let's start writing
our code. So the first thing we will do
is retrieve all the clips in the clips
folder using the Python file. So here in
the directory we have our 10 clips and
we need to fetch them with the Python.
To do this, let's use a library called
the globe. So, this library is used to
search for files on your computer. Next,
we will create a variable containing the
path to access each of these clips.
Let's type a comment first. It's a
convention I recommend you to follow.
You should really add comments in your
code to explain what we do at each step.
So, here let's type collect all clips
and then let's create a new variable
called the clips. We can use the globe
function from the globe library. So we
need to type globe twice here. globe.g
globe. Let's open parenthesis and
specify the path to access the clips. So
we open parenthesis with quotes and type
the clips folder name. So if you wanted
to access the output folder, we will
type output. Let's type a slash and then
specify that we want to fetch all files.
So there are 10 of them. There are
several ways to do this. We can manually
specify the name of each clip or we can
use more efficient methods to specify
all files with the same extension. Here
we can see that each of our files is in
MP4 format. So we can put an
asterisk.mpp4
to retrieve all the MP4 files in this
folder allowing us to get all our clips.
We can see if Python correctly fetches
our different clips. To do this, you
just have to type print open parenthesis
clips. Remember to save your code by
pressing Ctrl S and then run the code.
So I executed the code and we can see in
the console the path to all our clips
appearing. Note that for the clip names,
we have the clip numbering first and the
player's name. So the player who
performed the action on the right. So at
this stage we have just retrieved the
path to treat them. Let's delete the
print statement. It's unnecessary right
now. And let's create a list to contain
all these clips. Right now the clips are
all separated. And our goal is to group
them into a single MP4 video. So let's
start by creating an empty list. Let's
type uh initialize a list to store all
processed clips. So this list will be
called all clips. I advise you to use a
clear variable names to understand their
purposes. So this list will store all
the videos. And to list the clips, uh
let's create a loop to fetch all these
clips, transform them into movie pie
objects for their processing. So here
let's type a comment process each game
clip and uh let's create a loop. We can
type for clip path in clips. So for each
clip you have fetched we will process
it. The first point that we have to do
is that each MP4 file that we have is in
a format that cannot be manipulated by
movie pie. When the movie pie library
edits the different videos we provide.
It cannot work directly with the MP4
files. It's a file format that we have
to adapt for movie pie to perform
operations on it. So to do this we first
need to import a function from the movie
pie library. So let's type from movie
pi.editor
import video file clip. Video file clip
is the function that will allow us to
convert these MP4 videos into a format
that movie pie can process. Let's type a
comment create a video file clip object
and resize it.
I will explain the resize port later. So
let's create a new variable called the
video_clipip and call the function we
just imported video file clip with clip
path. So this little piece of code will
convert the MP4 video into a format that
MoviePie can use for editing. But the
final video will be in MP4 format to
publish on any platform. So don't worry
about it. By the way, it can also be
under format. It's not limited to MP4.
It can be for example.
So next, an interesting feature that
comes with the function video file clip
is that we can also resize each clip.
Generally, we want our final videos in
full HD format. So in 1,920x
1,080 pixels, but some clips can come in
different formats, such as 1,280x
720 pixels or smaller or larger formats.
And if all the videos don't have the
same dimensions, the final video will
have some clips appearing too small or
too large, which won't look good. So, we
add a bit of code to ensure all clips
have the same dimensions. So, here we
will choose 1,920x
1,080 pixels, which is a full HD format
used by all video platforms. So here
let's type a comma and type
target_resolution
equals we can open parenthesis here and
then we type 1,80
comma 1,920.
So we put the height first and then the
width. And this code will ensure that
all the MP4 files will be in 1,920x
1080 format avoiding dimension issues.
If you want, you can test this by taking
some clips with different formats. By
the way, to know the video format, go to
the clips folder, pick a video, right
click, then click on properties, and in
the details tab, you'll see the video
dimensions. So, here we have 1,920x,80
pixels. So, this video doesn't need
modification since it's already in full
HD format. But if it were, for example,
in 1,280
by 720 pixel, which is a common format,
the program will then resize it to
1,920x
1,080 pixels. Perfect. So next, we will
add each processed video to the list we
created earlier to have all the videos
in one list to concatenate them later.
So let's type a comment add the
processed clips to the list and then we
can type the code all clipsapped
within parenthesis video clip. So this
line adds each video clip to the all
clips list. To summarize, in this loop,
we have fetched each clip from the clips
folder, convert it to the video file
clip format used by Movie Pie, resized
it, and add it to the all clips list to
have all videos in just one list.
Finally, we have to concatenate these
clips. So here, let's type a comment
concatenate all processed clips. We can
create a new variable called the final
video and import a new function called
uh concatenate video clips. This
function will allow us to combine all
the clips into one video. And here we
specify the list containing our clips
which is the um the variable all clips.
So now the last step is generating our
MP4 video. Let's type a comment. write
the final video to an MP4 file.
We can retype our variable final video
and then use the function write video
file. So this code will convert our
edited video back to MP4 format. We open
parenthesis and specify the folder to
save the video. So let's save it in the
output folder which has been created to
store our edited videos. So I'm typing
here output/ video.mpp4.
By the way, the video.mpp4
will be basically the name of your video
inside your computer. So you can replace
the video port with any name you want
actually. But here I'm keeping it
simple. I'm just typing video. It's
sufficient for the moment. And uh don't
forget to specify the format. So here I
have typed MP4. Lastly, we must specify
the number of FPS's we want in the
video. Usually, we use 60 FPSs for
smooth videos. So, I type FPS equals to
60. Basically, FPS's are the number of
frames per second in your video. The
more you have, the more your video will
be better. It will be more smooth, more
fluid. Next, uh let's save the script
here. I'm pressing the Ctrl S. And we
can run it to see if we got our final
edited video with all the clips
combined. But just before running the
code, remember that the more clips are
in the folder, the longer will be the
execution of the code. Here we work with
the MP4 videos, each about something
like 30 seconds long. So the execution
may take a while, but keep in mind that
this is normal. If you have used editing
software like Adob Premiere Pro or Final
Cut Pro, you know that rendering videos
takes time. Here we basically do the
same but with the Python. So save your
code and run it. And keep in mind that
it's normal if it takes time. So to run
the code in Visual Studio Code, click on
run a Python file rather than run code
to execute the code directly in the
terminal. This avoids display issues in
the output window. So here I clicked on
run Python file. We see a message from
movie pile confirming the video is being
edited with the audio editing first and
then video editing. Uh progress
percentage appears and at 100% our video
will be ready. And by the way, this
display in the terminal is why I
recommend clicking on run Python file as
the percentage display might be
incorrect in the terminal if we have
clicked on run code.
Perfect. So here we are at 100%. We see
a message from movie pie saying the
video is ready in the indicated path. So
let's check the output folder and here
we can find the video. I double click on
it. So the video last 3 minutes
containing all our clips. We can quickly
view it. So the first clip is displayed.
One enemy remaining.
>> Advancing, we see the second clip that
follows automatically.
>> Head shot.
One enemy remaining.
>> And this continues until the last clip.
Perfect. So now we have our video with
all the clips assembled. So to
summarize, in this video we saw how to
combine multiple MP4 files into one. We
concatenated all the clips and resized
them to 1,920
by 1,080 pixels to ensure uniform
dimensions. Without resizing, some clips
will appear smaller with black bars on
the sides, which will not look good.
With this code, we can assemble many
clips into a final HD video with the 60
fps. You can verify this by right
clicking on the output video, selecting
properties and checking the details tab.
So here we can see that the video is in
the full HD dimensions and with the
60fps. So at this stage we have a video
base for further editing. And during
this course, we will modify this video
to add an intro, an outro video, a
background music, some transitions
between clips, and text to credit the
authors of the clips. So, keep your code
as well. We will improve it in the
future videos. And I'll see you in the
next video.
Now that we have seen how to concatenate
a set of videos to generate a single
video in MP4 format, we will look to
improve this video a bit. So if I go
back to my directory in the outputs
folder, I have the video that we
generated in the previous tutorial. So
I'm opening it. And as a result, it's
simply the 10 clips that we have
assembled. But the editing of this video
is very basic. We only group the videos
together, resize them, and export them
with the 60fps. But for this type of
video, for this kind of compilation,
it's good to add other elements on top,
such as a background music. It is very
common to see a little background music
in this type of video, and that's what
we're going to do in this video. We will
ensure to add a background music that
lasts the entire duration of the video.
So, this video currently last 3 minutes
and 4 seconds, and we will make sure to
add a music that also stops at 3 minutes
and 4 seconds. And we will even modify
the code to ensure that if our music
only lasts two minutes, for example, and
the video with the assembled clips last
three minutes, we will make the music
loop so that it restarts and ends
precisely at 3 minutes and 4 seconds.
Perfect. So, let's close this window and
we can go in the resources folder. So in
the resources folder, there are several
elements that we will use during this
training, including the music element,
which is the music we will play in the
background. You can open this file to
listen to the music if you wish. So it
is an MP3 file. I open it. I let you
listen to the music if you wish.
So, it's a music that has a bit of a
video game feel and it is, by the way, a
royalty-free. It is a music by the
artist Kevin Mle, which is a
royalty-free and can be used as long as
you mention the author. So, thanks to
him. And it's also a music that fits
well with the theme of the video we are
editing. So, a compilation of best
moments in video games. Perfect. Let's
move to our Python code. Here I'm on my
Python code and the first thing we will
do is to retrieve the music as we did
for the clips. So if I go to resources,
we will retrieve the music.mpp3 file.
For that, let's modify the code a bit.
So let's keep a line here and type
define path for resources like this. And
let's create a variable called the music
path. So the path to access the music,
let's use a quotation marks as we did
for the clips. And this time we will not
use the globe function with an asterisk
MP4 since we are looking for only one
MP3 file and not all elements in the
resources folder. So I will type the
name of the folder first resources. So
this folder slash and here I will type
the name of my file. So music.mpp3 MP3
like this. So we have retrieved the path
to access our music and we will be able
to integrate it into our video. For that
we will need to import a new function
which is the audio file clip function.
So this function works exactly like the
video file clip function. So video file
clip allows us to convert a video to the
movie by format so that we can edit it.
And audio file clip is exactly the same
but for audio files. So we convert audio
files maybe MP3 files for example to a
format that can be edited by Movie Pie.
Very well. So let's modify our code. We
can skip a line here. And after using
the concatenate video clips function, we
will type a comment. It will be a bit
long because we will perform certain
operations. Let's type load a background
music and loop it to match the duration
of the clips. So first we will load the
background music and then we will loop
it to match the duration of the clips.
So if our music lasts only 2 minutes but
the total duration of our clips is 6
minutes then we will loop the music so
that it ends at the end of the 6
minutes. We will basically repeat the
music until the clips end. Very well. So
let's create a new variable called the
background music abbreviated as a bg
music. Let's type equal and here we use
the function we imported. So audio file
clip like this. I open parenthesis and
here I simply put the path to the music
we defined here. There. So we have
loaded the music and converted it to the
format used by Movie Pie. Then we need
to modify the duration of the music to
match the total duration of the clips.
For that we will create a new variable
called the loop to music and we will use
a new function that we will also import.
This time let's type from movie audio fx
all import audio loop. So it's a new
function that we import and we'll use
directly. So we type audio loop like
this. We open parenthesis and we specify
the music we want to shorten or
lengthen. So let's type the variable we
just created here background music. And
then we must specify the duration this
music should have. For that we type the
parameter duration like this. And to get
the duration it's very simple. We type
our concatenated video just here. So
final video I remind you that this line
of code allows us to concatenate all our
videos and so it contains our final
video and if I call this variable in the
duration parameter and then type the
method duration I will be able to
retrieve the total duration of the video
with all the clips grouped together and
that's what we want with this line of
code we have modified the duration of
the music to match the duration of all
the grouped clips. So, for example, if
all the grouped clips last 4 minutes and
15 seconds in total, then the music here
will also last 4 minutes and 15 seconds.
How does this work? Basically, the music
is replayed to match the duration of the
video. Now that we have modified the
duration of the music, we need to
integrate it into the video because
currently in the code we wrote, we have
only converted to music to the format
used by Movie Pie and modified its
duration. But we have not yet integrated
it into the video. For this, let's type
a new line of code here. First, I will
type a comment combine the audio of the
clips with the background music. And so
to do this, we must import again a new
function which is the composite audio
clip function. This function will allow
us to combine the background music with
the audio from the clips. So we will
basically merge the two audio tracks
into a single track. I will create a new
variable here called final video with
the music. In this variable I will call
the final video variable. So this is the
video that does not contain the music
only the assembled clips and I will use
the set audio method to define the audio
that will play in this video. Next let's
open parenthesis and use the function we
just imported composite audio file clip
and then open again some parentheses and
some brackets. Let's type firstly final
video.audio to define that we will have
the sound of the clips first. So this
sound from the clips of Valerant. And
then we must specify the background
music which we defined here as looped
music. And we also need to specify the
duration that must match the duration of
the clips. So I typed here set
duration open parenthesis and type final
video dot duration. Perfect. Then we
just need to modify the last line of
code because the video we will write at
the end is no longer the final video
variable but final video with the music.
And now we should be good. If I execute
this code, I should have the video we
obtained previously, the exact same
video but with added background music.
And by the way, we should pay attention
to the file name. Currently we have kept
the same name as the video that we
previously generated. If you leave the
same name, it will simply replace the
old video file. But if you want to keep
both versions for comparison, for
example, you can simply put a new name
here. For example, the video with music
and thus we will not replace the
previous video. You do as you wish. In
any case, it will not impact the result
of this video. So we can now execute the
script again. Let's go to run and click
on run Python file. You can also click
on run code directly but the display in
the terminal will not be the same. But
keep in mind that in any cases it will
not impact the video. So let's click on
run Python file. And now the script will
begin to execute. Perfect. So here the
music has been added and the video is
currently being processed. Again, the
more clips there are, and the longer
they are, the longer the editing will
take. If you want for your tests, you
can limit the number of clips. I have a
powerful enough computer, so I can
afford to include all the clips. That's
not a problem. But you, if your computer
is struggling a little bit, you can only
keep five or six clips and remove the
rest. And when we will finish this
project, you can use all the clips you
want. Perfect. So, let's wait for the
editing to finish. We wait to reach
100%. By the way, we can already see in
the output folder that we have the MP4
file of the video, but it is still being
processed. We also have a temporary file
that contains the music here, but this
temporary file will be automatically
deleted. And there we go. We have a
message that says the processing is
finished and that the video is ready in
the output folder. So we have our video
with the music.mpp4 file and we can also
see that the MP3 file that appeared here
for the editing has disappeared
automatically. Very well. So let's open
our folder. Let's go to the outputs
folder. And here we can see our few
videos with the new one that was created
and contains the music. So let's open it
and we will be able to hear the music.
Spike down. One enemy remaining.
>> Good.
I'll run through you every
>> very well. So of course if you wish to
use another music you can do so you
simply need to modify the music file
that is here and rename it to music.mpp3
or you can rename directly the name of
the variable here and it will work very
well. The script is adapted to work with
any music. And if you plan to publish
this video on video platforms and
monetize the videos, make sure to check
if you have the rights to use this
music. So for the music we use in this
training from the artistic Kevin Mle,
this music is royaltyree. We can use it
as long as we credit the author. Very
well. So that was all for this video. We
have seen how to put a background music
that loops during a video. So this is
something we see very regularly in
compilations whether it is a video game
compilations or sports games lot of
things there's very often a little music
that plays in the background and that
makes the video more pleasant to watch.
Perfect. So in the next videos we will
continue to improve this video. See you
everyone.
Before moving on to the next lesson
please take a moment to rate this course
and share your feedback. I will be
delighted to hear your thoughts on the
content and your overall experience.
So at this stage of the course, we have
seen how to retrieve all our clips in
the clips folder as well as the music.
And then we have seen how to transform
each clip into a format usable by Movie
Pie. We then modify the resolution of
each clip to be in 1,920x
1080 format, which is the full HD
format. We then combined all these clips
together to form a single video. We
added music that we modified to match
exactly the duration of the video with
the combined clips. And finally, we
exported everything in the MP4 format to
have a video ready to be published on
video platforms. Now, we will continue
to make modifications to this video. We
will see how to add an introduction
video and an outro video to the final
video that we edit. So, in this kind of
compilation that you can see on the
internet, there is often a little
introduction with the creator's name and
an outro video at the end where people
are usually asked to subscribe to the
channel. You have surely seen content
like this before. So, in this video, I
will show you how to add an intro at the
beginning of the video and an outro at
the end. For this, I have prepared some
intro and outro files in advance. So
these are the videos that we will add to
our compilation. Let's quickly view
them. So here I have the first file that
serves as the introduction. So I click
on it to open it and let's take a look
at it.
Very well. So this is the introduction.
The idea is to place this video at the
beginning of the video and we will do
the same at the end with the outro. So
for the outro, let's take a look at it.
Perfect. So these are two videos that I
have prepared beforehand before the
course. And by the way, again, you can
download all of these files if you
haven't downloaded everything already.
Oh, and by the way, if you have your own
introduction or your own outro video,
you can of course use them instead. But
for this course, I'm going to use the
two files that I've just showed you. Oh,
and by the way, you might have
recognized the background music. It's
again the music from Kevin Mloud. It's
the one that we have used in the
previous video. Perfect. So let's go
back to the code. So this was the code
from the previous video. And first let's
import the intro and the outro files. So
here I type intro path equals and inside
the resources folder. And this time I
type intro.mpp4.
And then we do exactly the same but for
the outro. So I copy and paste this line
of code. And here I put outro same I
modify here. And perfect. So we just
specified the path to access our intro
video and our outro video. Then we will
need to process these two videos the
same way we processed the clips. So
these videos are currently in MP4 format
which is not a format that movie pie can
handle. So as we did for the clips here
with the video file clip function, we
will do exactly the same but for these
two videos. But you will see it will be
very quick. Let's insert a line here and
we can type a comment create a video
file clip for intro. Here I will create
a list that I will call intro clips. So
I put clips in pl. You will understand
later why I use the pole. It's because
later in the training we will add other
things to this list. So here I open
brackets and I type the pass for the
intro. So intro pass. And as we did for
the clips, we can resize the videos. So
for the intro and the outro that we
already have in the resources, this
video are already in the full HD format.
So we don't actually need to specify the
target resolution again. But if you are
working on an intro that is not in this
format, then it is better to put the
code anyway. But if you are working on
an intro that is not in this format,
then it is better to put this code. So
for me, even if the intro and outro that
I'm using are already in the format
1,920x
1080, it doesn't hurt to specify the
target resolution again so that we are
sure that we have the full HD format.
Perfect. So next I will copy and paste
these two lines of code and do the same
for the outro. So here I type outro
clips and instead of using the intro
path I put out pass for the target
resolution we keep the same. And now
that we have defined the path to access
the intro and the outro and converted
them with the video file clip we will be
able to integrate them into the final
video. And you will see it's very easy
to do. We can go down to the bottom of
our code and before exporting the video
in MP4 format, let's make one last
modification. Let's use the concatenate
video clip function again. So I will
copy and paste this code here. And I'm
adding the comment uh combine the intro,
main clips, and outro into the final
video. In the parenthesis, let's add the
intro and the outro that we just
imported. So I type intro clips then I
type plus not a comma because in Python
when we want to combine lists we type
plus. So intro clips plus main clips
plus outro clips. There is a little
particularity since intro clips and
outro clips are lists with only one
element inside. We need to put brackets
in the second list which here contains
all our clips.
Perfect. So now if we execute this code,
we will get our video with the intro and
the outro. So before we execute the
code, let's rename some variables. For
instance, we can see that final video
appears multiple times. Let's modify it
here. In this line of code, we were just
assembling the clips together, but it's
not the final video. Let's rather name
it clips port like this, representing
the clips portion. And then let's modify
the other instances where we specify the
final video. So here we put clip sport
and we replace it here here as well. And
we do the same for this line. This way
we will only have one final video
variable which will be the actual final
video that includes the intro, the
clips, the outro and the music. Actually
even this variable here can be renamed
to clip sport as well.
Perfect. Next uh here let's remove the
with the music leaving just a final
video. And here we can type video with
intro and outro.
Perfect. I could have specified that it
also includes music as well, but I won't
do that to avoid making the title too
long. And that's it. So now we have our
code that gathers all the clips from the
clips folder, adds background music, and
includes an intro and an outro at the
end. So we can proceed to execute the
code. So remember to save your work
again. And now we can click on the run
Python file button. There we go. Let's
enlarge the terminal a bit to see the
results better. Oh, and we can see an
error appearing. Oh yes. Uh here in the
brackets I need to put clips port also
to use here the clips that have been
concatenated. Save your code. And now
let's reexecute it. Normally there
shouldn't be any errors now. So I click
on run Python file. And now the code is
executing. We will end up with our video
containing the intro, the outro, the
clips and the music. Let's wait for it
to finish. In the meantime, for those
who used to work with Python, you may
have noticed that for the intro and
outro variables, we created a list. Even
though there is only one element, it's
not logical to create a list for a
single element. But you will see in the
next video that we'll make some small
transformations where we will add
elements to this list, making it more
consistent to use lists. Here I prefer
to create the list directly to avoid
having to modify a lot of code later.
Perfect. So if we go to the output
folder, we should see the video being
created here and also the audio file
which is a temporary file created during
the editing process. And uh this file
will be automatically deleted afterward.
Perfect. So let's wait for the code to
finish executing.
And there we go. The code has finished
executing and the video have been saved
in the output folder. So let's go check
the results immediately. Here we can see
the video with a different thumbnail
from the previous videos because a new
element has been added. So I click on it
and theoretically we should start
directly with the intro then the clips
and finally the outro. So let's play the
video.
First we see the intro and then it
directly transitions to the clips.
>> One enemy remaining.
Let's quickly go through the other
clips.
And if I go towards the end, we should
see the outro.
Perfect. So, we can see that the code
worked very well. We start with the
intro, then move on directly to our
clips. And at the end after the last
clip, we transition directly to the
outro with a little video thanking
viewers for watching and reminding them
to subscribe. Perfect. So, we are
getting closer to the compilation videos
we can find on the internet. We
understand that this editing process can
be easily automated with the Python and
Movie Pie. As seen throughout this
course, we are gradually creating a very
polished video with an intro, an outro,
a music clips in full HD format, 60fps,
making it very close to our professional
video that could be easily published on
a video platform. Of course, we will
make a few more tweaks to improve this
video, which we will see in the upcoming
videos. So, that's all for this video.
Remember to save your code by pressing
Ctrl S. If you want to clean the
console, you can write the clear command
in the console and execute it. Perfect.
So that was all for this video. I see
you in the next one for more editing.
In this video, we will see how to add a
transition between each clip. So if we
go back to the video we have created in
the last video. So I'm going to my
output folder and it was this video.
Let's take a look at it. Here we are on
the intro and you will see that when we
move to the first clip, there is no
transition. It's a bit abrupt.
We moved directly to the first clip
without any transition or anything.
Personally, I don't find it very
pleasant to watch. And it's the same for
all other transitions between each clip.
For example, if I go to the end of this
first clip, you will see that we will
move to the next clip in the same abrupt
manner.
>> So, here we are on the second clip. And
I would like that between each clip
there is a little effect, a little
transition that makes the change from
one clip to another less abrupt. So if I
go back to my clips, I would like to be
a little transition between each video.
Something that makes the transition from
one clip to another more pleasant to
watch. And that's what we are going to
do in this video. For this, we will use
a video effect, another MP4 file that
will serve as a transition. It is a
video that lasts about a second, maybe
even less. And it has a visual snow
effect like on TV. So, I'm going to open
it and you will see it's a simple video
of not even a second with the visual
snow, which is the name given to this
small color of the dots, these black and
white dots. And I would like to apply
this transition between each clip. It's
a transition often seen in compilations
and it makes the transitions more
pleasant to watch. Therefore, our goal
in this video will be to integrate this
transition between each clip. So, let's
go back to Visual Studio Code, back to
the same code we wrote in the previous
video where we added the intro and the
outro. In the same way, we will be able
to add this transition effect. So, let's
add a variable containing the
transition. So I type transition path
like this. And like the previous
variables I will copy paste and instead
of putting outro I type transition to
get our transition file located in our
resources folder. We will then apply
this transition between each clip. For
this we need to modify this loop where
we take each video each clip from the
clip folder convert it with the video
file clip function and add each clip to
a list to group them all. So what we're
going to do is once we add a first clip
right after we will add the transition.
So there will be a transition between
each clip. Here let's type a comment add
a video transition clip to the list and
then I'm adding it to the new list. So
this new list will contain all clips. So
I type all clips.append
and then I call my transition. So I use
the video file clip function. Since the
transition is currently an MP4 video
format that needs to be converted to a
format Movie Pi can modify. So I'm using
video file clip. I define the variable
name to access the MP4 file. And then
like all the other video clips, I
modified the resolution to 1,920
by 1,080.
So first we specified the height and
then the width. So with this
modification we will have a transition
appearing between each clip. You will
see it when we will execute the code.
Before that remember to change the name
of the final video. If you want I will
name it video with the transition. But
even if you don't change the name, it
won't be a big deal. It will just
overwrite the old video. So let's
execute this code to see the result.
Let's click on run Python file and wait
for the code to execute again. If you
wish, you can remove a few clips from
the clips folder like the last four or
five to speed up the execution process.
You can reintegrate them at the end of
the course to have all the clips. For
now, since we are still in the testing
and development phase, you don't have to
include all clips, just a few so we can
see the different transitions between
each clip. So, let's wait for the code
to execute and we will see the results
at the end. So, now the execution is
complete and we can see that the video
has been created. Let's go watch it
right away. So, I go to my folder then
to my output folder and I click on the
newly created video. Let's fast forward
a bit to any clip and wait for it to end
and then you will see the transition we
added.
>> Perfect. So you saw the transition
between the clips. We can take another
example. Let's go further into the
video.
So, as you can see, there's a transition
between each clip, making it much more
pleasant to watch. However, there is one
little thing missing. Currently, there
is no transition between the intro and
the first clip. I will show you. If we
go back to the beginning and launch the
video, you will see there is no
transition between the intro and the
first clip.
There is however a transition for the
last clip and the outro which makes
sense because in the code we always add
the transition after each clip. So it's
normal that after the last clip there is
a transition added resulting in a
transition for the outro.
Thus, we are missing only the transition
between the intro and the first clip.
This is a small modification that we
will make right away. So, let's go back
to our code and make some changes to add
this transition right after the intro.
So, we're going to modify this line of
code, adding a new element with the
video file clip function. This is why I
used the plural here. Even though we
currently have only one element, now we
will have two. So to make the code
easier to read, let's add a line break
here, separating the elements we we will
add. Here I type a comma and call the
video file clip function again, placing
the transition immediately after the
intro. Then I set the target resolution
as usual to keep the full HD format.
Although the video in our resources is
already in this format, this code will
automatically resize any future
transitions that might not be in this
format. So we have now added this
transition. For consistency, we can do
the same with the outro, but we won't
add a transition here because there is
already one after the last clip as you
saw. However, we can format the code to
make it easier to read. Save the code.
And uh now we have to concatenate the
elements of this list. Currently we have
a list containing two videos the intro
and the transition. Now we need to group
them. So copy and paste this line of
code to concatenate the intro elements.
Here instead of clips I use the intro
part and instead of all clips I use
intro clips. This concatenates the intro
with the transition. We can do the same
with the outro making development
easier.
change the comments accordingly to
concatenate the intro clips and
concatenate the outro clips. Now let's
go down in the code and make a final
modification. So in the last concatenate
function, since we are now working with
lists containing multiple elements,
let's remove the square brackets,
replace the plus signs with the commas,
and place the brackets just after the
parenthesis. We have to make this
modification now that we are working
with lists that have multiple elements
which will avoid us execution errors. So
we have now made the necessary
modifications to have the transition
after the intro and the all the other
transitions that follow. So save the
code again and let's modify the comment
here. So here we typed intro and
transition clips. You can also add outro
here. And finally, execute the code by
clicking on the run pattern file button.
Before that, uh just clear the console
by typing clear to clean it up. Click on
run Python file and the code will
execute.
Oh, we can see that we have a small
error to correct here. Instead of
putting intro clips and outro clips, we
need to put intro part and outro part.
So we need to properly specify these
variables since they contain the
concatenation of the intro with the
transition. Finally, let's execute the
code. Beforehand, we can type clear to
clean the console and then click on run
Python file.
You will see first the audio processing,
then the video processing. So the video
is generated with the same name as the
previous one as I chose to overwrite the
old one without the intro transition. So
now that the execution is complete,
let's go watch the video. So I return to
my output folder and launch the video
with transition. So first we see the
intro and then we should see the
transition after the intro.
And there it is, the transition right
after the intro. And similarly, there's
a transition between each clip, making
the video much more pleasant to watch.
>> We can verify this at the end as well,
just before the outro.
Perfect. So, in this video, we saw how
to add a transition between each clip.
Something commonly seen in such videos.
You saw it. It's not complicated to
implement and can be done quite easily.
In the next videos, we will continue to
explore other ways to edit our videos
with Movie Pie. So, that was all for
this video and I'll see you in the next
one. In this video, we will continue to
make transformations on the video
generated by our program by adding a
text this time. So, if we go back to the
folder containing our clips, by looking
at the name of each clip, we can see
that at the end of the name of each
clip, there is the author of the player
who recorded the video. For example, for
the video number four, the author is
called the gravity. So, it's the name of
the player who made this clip. And it
would be nice to mention the author's
name in the video. We could for example
add a small text at the top left with
the author's name. So a small white text
for instance that we would put in a
thoroughly small font so that it doesn't
cover the entire video. And in this way
we can mention the author and that's
what we're going to do with our program.
We will modify it to add the author's
name at the top left each time. So this
is something that we can do. But to add
the text with the movie pie, we need
first to install another element,
another dependency, specifically the
image magic software. So here I am on
the official movie pie documentation and
it is clearly indicated here that image
magic is a dependency that can be useful
if you want to write text on our videos.
So it is a small dependency that we need
to install in addition to be able to
write text on our video with the Python
and Movie Pie. And by the way, once the
software is installed, if you are on
Windows, we will have to make a few
small configurations so that movie pie
can detect image magic. But if you are
on Mac or Linux, in theory, image magic
should be detected automatically. So in
this video I will show you how to
install image magic and ensure it is
detected by Windows if you are working
on a Windows machine of course. So to
install Image Magic it's very simple.
Let's open a new window here and let's
type image magic like this. Then you can
press enter. You can then click on the
first link. Perfect. So we land on this
page. So it is a free open-source
software. So of course there is nothing
to pay. Let's go to the download menu to
download the software. And here we just
have to choose the version of image
magic according to our operating system.
So if you are on Linux, you can download
the image magic for this operating
system. If you are using a Mac, you can
also uh install Image Magic for this
operating system. And finally, if you
are on Windows, you can download Image
Magic directly by clicking on the little
link here. Let's click on it. And we can
see that the software is downloading.
Okay. So the software has been
successfully downloaded to my computer.
And now we just have to install it. So I
went to my downloads and for the
installation there's nothing simpler.
You can click on the.exe file. And there
will be only a few buttons to press to
download image magic. It's very easy to
install. So here I press yes. You can
click on accept agreements. You can read
the license if you wish. Click on next.
You can leave the default settings
except maybe for create a desktop icon
to avoid creating a shortcut to access
image magic directly from your desktop.
Then click next. And now you just have
to click install. So for my port it is
already done. So I don't need to click
on install. I'm just going to close this
file. But for you you can click on
install to install the software if you
haven't already done. So once that is
done, we will need to modify a Python
file that is on our computer and that
was installed automatically when we
installed the Movie Pi library at the
very beginning of the course. So you
need to go to the folder where Python is
installed on your computer. A little
tip, if you are using Visual Studio
Code, in the terminal, you should have
the path to your Python.exe and you need
to go to that path. So here we can see
that my Python.exe Excel file is in my
app data folder. To get there in my
research bar here, I type percent ape
data percent. I then click on the folder
that appears. So here we are
automatically taken to the roaming
folder. Let's back up once to be in the
app data folder. Next, let's go inside
the local folder. Then you can click in
program as indicated in the path here.
So program then python then python 3.12.
So I'm just following the path indicated
here and then we need to go to the lib
folder. So this is no longer indicated
here. So now you have to follow the path
that I'm indicating. So next let's go to
the lib folder then to site packages.
And inside this folder we have almost
all the libraries that we download on
python. So here we just need to look for
the movie pi folder. So here it is.
Inside this folder we find most of the
files that were downloaded when we
installed the movie pi library. And here
we need to modify the config default.
py. You can open this file to edit it.
So it opens directly in visual studio
code for me. So in this file you need to
change this line. There is a variable
called the image magic binary with the
path to access the software we just
downloaded. So image magic the path is
not specified by default. I had already
made the modification. So me I have the
correct path to access Image magic but
you you will need to set the correct
path to access the software. So I've
installed it on my D drive. So Image
magic for me is inside my D drive. You
can see here the image magic folder. I
click on it and inside this folder I
should have the magic.xe file. You can
right click on it and press copy as path
to simply copy the path to image magic.
Then you can paste this path inside this
variable and put it in quotes like this
and then it will be good. We have
indicated to Movie Pi how to access the
image magic software. So again, I
installed the image magic on my D drive.
Maybe you have it on your C drive. But
don't worry, it will work the same way
as long as you specify the correct path
to the magic.xe file. And now that we
have made this modification, we are
ready to use Image Magic with Movie Pie
and write text on our videos. So that
was all for the installation of Image
Magic. Again, if you have a trouble
finding the path to the movie Pi folder,
you can refer to the path indicated in
your code editor. So here on Visual
Studio Code, I can find the folder where
my Python is installed. So just follow
the path I indicated to get the site
package folder, then move and inside you
will have the config defaults file to
modify. And once you have made the
modification, remember to press Ctrl S
to save. Then you can close this window.
So that was all for this video and I'll
see you in the next one.
So I'm making this video in addition to
the last one about the installation of
image magic because some people have
encountered the difficulties with the
creating text on Movie Pie due to movie
pie not being able to find the path
through the magic.xe file. even though
the correct path is specified in the
config default file we configured in the
last video. So some people despite
having specified the correct path to
magic.exe find that when they implement
text on movie pie the text does not
appear in the video. The reason for this
error is that some versions of Python do
not properly support what were called
air strings. So the air strings are the
strings where there is an error in the
front which allows us to define path
using just a backslash as used in
Windows. It's much simpler for copying
and pasting path from a directory.
However, in some versions of Python,
this does not work correctly. So to
resolve this problem, we will simply
rewrite the path in another way. So we
are just going to write the path
differently. As a reminder, for me, the
magic.xe file is in my D drive. For you,
it may be another directory. And to
solve the issue, essentially you just
need to remove the error and rewrite the
path adding an extra backslash each time
we change the directory. So here I have
added a backslash and here I will add
another as well. So you need to add two
backslashes every time you change
directory. So this is the classic way to
define a path to a directory or a file
in Python. With this writing style, it
will work every time regardless of your
Python version. And once you have made
the modifications, namely removing the
error and adding the extra backslashes,
make sure to save your file, you can
press Ctrl S. And once this is done, you
can move on to the next video where we
will be able to implement text on Movie
Pie without any issues. So that was all
for this video and I'll see you in the
next one. Now that we have seen how to
install image magic on our computer, we
can start writing text on our videos
with the Movie Pie. So the text we want
to write is the author's name on each
clip. So for example when the first clip
will play here we can see that the
author's name is Mr. Azy. So I would
like the author's name to be in the top
left corner. So the name Mr. Azy will be
written throughout the clip in the top
left corner. And that's what we're going
to do in this video. And of course it
needs to be an automated solution that
does it for each clip in the folder.
Very well. So before that we also need
to tell to movie pie which font to use
for writing the text. Actually by
default movie pie will choose a basic
font but it's not a font would have very
good quality. So the best practice I
recommend is to choose your own font
from the internet and incorporate it
into the script. So I chose a font
called Robboto. It's a royalty-free font
so you can use it without any issues.
And so this is the font we will use to
indicate the author's names. Very well.
And so like with all the other
resources, we are going to import it. So
here I skip a line and type font path
like this. Then I type equals. And here
I can copy past the line above. And I
just have to replace transition.mpp4
with the font. TTF. Be sure to write it
correctly. Perfect. So we've completed
the first step. We have imported the
font and then all that's left is to
display the author's name on each clip.
So since this is a modification we will
make to each clip, we will write our
code in the loop because it is in the
loop that we process each clip. And
first we will need to make a few small
textual modifications. We can see that
in the file names besides having the
author's name, we also have some numbers
with a dash here. And these are the
things we do not want to display. So
first we are going to remove the
numbers, the dots and the spaces to keep
only the author's name. For that we need
to import a library which is the OS
library. So it's a Python library that
allows us to interact with our operating
system. OS is for operating system by
the way. So with this library we can
create files, folders, delete them etc.
So therefore we will use this library to
retrieve the file names and remove the
text we do not want to keep. Very well.
So here let's type a command extract the
name from the clip path and I will
create a new variable that I will call
name which will contain the name of each
author and then let's type the function
os.path.base
name and I put clip path in parenthesis.
So what does this piece of code do? This
piece of code is simply retrieves the
full name of each file. So right now
this code will retrieve 01-
MR. Next, we will need to replace the
text we do not want. Starting with
thempp4. We don't need this part of the
text. So let's type the method.replace
open parenthesis. Then in quotes type
and then we type again inside quotes.
Basically nothing. Here we are just
replacing thempp4 with nothing because
we don't want to put anything in place
of thempp4. Perfect. So at this stage we
have removed thempp4 and now we just
have to remove the 01 dash and space. So
to remove these characters we will use
another function called the l strip
which is a function that also allows us
to remove characters but it works a
little differently. we will basically
indicate all the characters to be
removed in each name. So here we want to
remove the digits 0 1 2 3 4 5 6 7 8 and
9. And we will also indicate that we
want to remove the spaces and dashes.
And so that's what I'm doing here. I'm
simply indicating the characters that I
want to remove. So 0 1 2 3 4 5 6 7 8 9.
I'm also indicating the dash and then
the space. And that way all these
characters will be removed. So it's
quite simple. We first remove thempp4
and then we remove the uh the numbers,
the spaces and the dashes. Very well. So
now that we have the author's name
cleaned, we will incorporate it into the
video. For that, right after the video
clip variable, we will create a new
variable. So here, let's type a comment
create a text clip object with the clip
name. So in movie pie text have a
predefined object just like we have an
object for videos and an object for
audio files. So we had the function
audio file clip for audio files and the
function video file clip for video
files. And so just like them we also
have a function for text and that is
what we're going to import. So let's
scroll to the top and we will import the
function text clip. Perfect. And with
this function we are now able to create
a text clip object. So first here let's
create a variable called the text
underscoreclipip and then I just call
the text clip function that I have just
imported. So first of all I would like
the name to be displayed always in
uppercase. For that first I'm typing the
variable name which contains the name of
the author and then I type dotuper to
have the text in uppercase. So we can
type it like this with an opening and
closing parenthesis. And by doing this
all the text will be in uppercase. Next
I need to define the font size. So this
is done with the font size function like
this. And then we need to define a
number that corresponds to the size of
the text. The higher the number, the
larger the text will be. Here I put 100
because it is a sufficient value to have
text. In the top left corner that is a
small enough. Next we can define the
color. So, I recommend using white
because if you use a somewhat
extravagant color with the colorful
background of video games, it might not
be clearly visible. It depends, of
course, on the content you want to
automate, but generally it is best to
use white, especially for video games.
Next, we need to define the font we want
to use. So, for the font, we've already
imported it. So, we just need here to
redefine the path. So, we type font
equals to font path. And that way we
will be able to use the font we
imported. Then let's complete our code
by defining the text position in the
video. So as I mentioned earlier, I want
to put the text in the top left of the
video. For that, let's type in the
method set pause like this. Let's open
two parenthesis. And here we need to
provide two pieces of information. We
need to set the horizontal position and
the vertical position. Let's start with
the vertical position. So here I can
just type left and then we can type top.
This way I will have the text in the top
left corner. If I wanted to put it in
the top right here I will replace left
with the right. Perfect. So that was for
the position of the text. And finally
the last parameter we need to modify is
the duration of the text. So this text
needs to appear from the beginning to
the end of the clip. For that we can use
set duration just like we did for the
music. And then we can call our video
clip variable. And we just have to type
dot duration to indicate the duration of
the clip. Perfect. So one last piece of
code we need to add is the merging of
the video with the text because here we
have one video for the clip and one
video for the text and we need to merge
them so that they overlap exactly as we
did for the video sound where we over
overlapped the music with the sound of
the clips. So if you remember we have
used a function called the composite
audio clip and in the same way we will
use the function composite video clip to
merge the two videos. So here let's
import the function composite video clip
and then we will be able to call the
function and use it. So let's create the
variable that will use this function.
But first I will add a comment. Let's
type combine the video clip and the text
clip. And then I will create a new
variable which I will call video with
text. And here I will be able to call
the function I just imported. So
composite video clip. Let's open
parenthesis and then brackets. And here
I just need to specify video clip and
text clip. So first we have the variable
that contains the video the clip and
then the variable that contains the text
which is the name of the author of the
clip. Also here we need to make a little
modification. Instead of putting video
clip here, we will just put a video with
text to correctly add to the list the
video that contains the author's name.
And then it's done. We have completed
the modification we wanted to make to
the final video. If we scroll down to
the bottom of the code here, we can
replace video with transition with the
video with the music. Perfect. We can
then save the code. And now we can run
it. So to run the code, we can do as
usual. You can click on the button run
Python file to execute it. And there you
go. So let's wait for the code to
execute. We can see that the music has
been edited. And now it's time for the
video editing. So let's wait for the
editing to complete.
Perfect. So we can see that the code has
been executed. And by the way, I just
noticed that it's not a video with music
here. It's not a video with music we
should put, but rather video with text.
Sorry for my mistake. So you can just
type a video with text here. So now we
can go to our output folder and start
the video we just generated. And in this
video we should now have the author's
name in the top left corner for each
clip. Let's check that.
Perfect. So here we have the author's
name for the first clip. Very good.
Let's speed up a bit. Let's see if the
author's name is there for the second
and third clips. So for the second clip,
we also have the name here. It is the
sixth clip. So it looks the same.
This is the third clip. We can see that
each time you have the author's name
appearing in the top left corner. Very
good. However, there's a small
modification we could make regarding the
positioning. We can see that here I'm
enlarging the video a bit. the text is
very tight to the left. Let's put the
video in full screen. So as I said here
we can see that the text is quite tight
to the left whereas on the top part
vertically we have a bit more space. So
this is because of the left parameter
that we defined in our code that the
text has this position. So what we can
do to make the text a bit more to the
right. There is a solution to this.
Instead of putting left, we can simply
set the number of pixels to insert the
text from. So here, if we put one pixel,
for example, I will put one. The text
will be very, very tight to the left
since it will start from the first
pixel. And so the higher the number, the
more the text will move to the right. So
I did some tests on my side and the
ideal number is 20. So here I recommend
putting 20. This way the text will be a
little bit shifted to the right. As I
said before, the higher the number is,
the more the text will move to the
right. 20 is a good number of pixels so
that the text fits well in the top left
corner with as much space above the text
as to the left of the text. Very good.
So once that is done, we will be able to
run our code one last time to get the
final video with all the improvements we
wanted. First here, let's type clear to
clean a little bit the console and then
let's run this code. Perfect. So the
rendering is starting and we will meet
at the end of the code execution to see
the results. So we can see that the
script has been executed. Let's open the
file a video with text.mpp4. So I'm
opening it
and there we go. We can see now that the
text appearing in the top left corner
has been shifted a little bit to the
right. I find it a little bit more
aesthetically pleasing like that. where
before the text was completely tight to
the left, it's better like this. Oh, and
by the way, if you ever want to change
the font or the text size. So for the
text size, you can just modify the font
size parameter here. And for the font,
you can change it yourself by replacing
the font. TTF file. So you can replace
this file I left in the project
resources with another font you want to
use. Perfect. So now we have the
author's name displayed each time and
that's great. It's something often seen
in this type of compilation on the
internet even in those shown on
television where the author's name is
usually credited in the corner of the
screen. Perfect. So we can close this
video. And that was all for adding text
on Movie Pie. You have seen it's not
complicated to do. We do this with the
text clip function to indicate the text
we want to display with the font. also
the font size, the position, the
duration, etc. And then we just merge
the text with the video using the
composite video clip function that we
just imported. Perfect. So that was all
for this video. Thank you everyone.
So we have reached the end of this
training on Movie Pie. We have covered a
lot of interesting things together to
automate the editing of these clips.
First, we saw how to assemble multiple
clips to combine them into a single
video. We also learned how to resize
them to the 1,920
by 1,080 format with the 60fps
so that the video format meets the
standards used by video platforms. Next,
we saw how to add a music, specifically
background music, which we set to play
until the end of the video to perfectly
match its duration. We also covered how
to add an introduction video and an
outro video, as this is generally the
convention for such videos. This makes
the video much more professional. And of
course, if you already have your own
intro or your own outro, you can just
use them by replacing the files that I
have provided you. And you can do the
same with the music. Then we looked at
how to add a transition between each
clip to ensure that the transitions
between videos between the clips are
professionally done and so that the
transition are not too abrupt to watch.
And finally, we saw how to add a text to
the videos, especially to credit the
different authors. For this, we first
installed the image magic, which is an
essential prerequisite for adding text
to a video with Movie Pie. We then saw
how to configure it and then how to add
the text and modify parameters such as
the color, text size, position, etc. In
the end, we have been able to obtain
this video. We can quickly rewatch the
beginning. So here we have the intro.
[Music]
We have then here the first clip, the
music behind the text appearing at the
top left. The transition
>> down. One enemy remaining.
>> Perfect. So the editing is really
identical to the compilations of this
kind that we can find on the internet or
on the television. We have seen during
this training that it is quite easy to
automate this kind of editing and that's
what we did. And of course this code can
be reused regardless of the context of
the clips. During this course we have
used the clips from the video game
Valerant as an example. But you can also
use clips from sports, uh, some funny
animal clips, etc. The code will work
the same way. You just have to change
the music if you want. Also, the intro
and the outro. For the transition, you
can maybe keep it. It is a quite a
generic transition that can be used in
any context. At the end, you will get a
video in the full HD format with 60 fps.
So once again, it is a video that can be
published on video platforms with the
recommended quality standards. So if you
haven't done so yet, the final code can
be downloaded. And also if you liked the
course, please leave a little rating for
the course so that I can read your
feedback. And if you have any questions,
don't hesitate to contact me. And I'll
see you next time for a new course.
Goodbye everyone.
