TubeSum ← Transcribe a video

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

Transcribed Jun 15, 2026 Watch on YouTube ↗
Intermediate 23 min read For: Python developers or video editors with basic programming knowledge who want to automate video editing tasks.
3.7K
Views
70
Likes
11
Comments
0
Dislikes
2.2%
📈 Moderate

AI 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.

[00:02]
Course Goal

Learn to use the MoviePy library to automate video editing with Python scripts for mass processing.

[00:10]
Real-World Project

Automatically compile best moments from a video game (Valorant) with edits, representative of real-world automation.

[01:28]
Tools Used

Visual Studio Code is used as the code editor; Python and VS Code installation is covered.

[02:39]
Python Installation

Download Python from official site, check 'Add Python to PATH', install, and optionally disable path length limit.

[04:29]
VS Code Installation

Download and install Visual Studio Code, then install Python and Code Runner extensions.

[06:50]
Testing Python

Create a Python file, write 'print("hello world")', save, and run using the Code Runner button.

[07:58]
Installing MoviePy

Open terminal and run 'pip install moviepy' to install the library.

[08:36]
Project Resources

Download a zip file containing clips, resources (intro, outro, music, transition, font), and an empty Python script.

[14:15]
Assembling Clips

Use glob to fetch all MP4 clips, convert each to VideoFileClip, resize to 1920x1080, and concatenate using concatenate_videoclips.

[23:41]
Exporting Video

Write the final video to an MP4 file with 60 fps using write_videofile.

[29:01]
Adding Background Music

Load an MP3 file with AudioFileClip, loop it to match video duration using audio_loop, and composite audio with CompositeAudioClip.

[42:00]
Adding Intro and Outro

Load intro and outro MP4 files, convert to VideoFileClip, and concatenate them with the main clips.

[54:03]
Adding Transitions

Load a transition MP4 file, convert to VideoFileClip, and insert it between each clip in the loop.

[65:40]
Adding Text (Author Names)

Extract author name from filename using os.path.basename and string methods, create a TextClip, and composite it over the video using CompositeVideoClip.

[66:39]
ImageMagick Installation

Install ImageMagick for text support, then configure moviepy's config_defaults.py with the path to magick.exe.

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.

Clickbait Check

95% Legit

"The title accurately describes the course content: automating video editing with Python and MoviePy."

Mentioned in this Video

Tutorial Checklist

1 02:39 Download and install Python from python.org, ensuring 'Add Python to PATH' is checked.
2 04:29 Download and install Visual Studio Code.
3 06:08 In VS Code, install the Python extension and Code Runner extension.
4 07:58 Open terminal and run 'pip install moviepy'.
5 08:36 Download the project zip file and extract it into a folder.
6 14:15 Write code to import glob, fetch all MP4 clips, convert to VideoFileClip, resize to 1920x1080, and store in a list.
7 23:12 Use concatenate_videoclips to combine all clips into one video.
8 23:41 Export the final video using write_videofile with fps=60.
9 29:01 Load background music with AudioFileClip, loop it to match video duration using audio_loop, and composite audio with CompositeAudioClip.
10 42:00 Load intro and outro MP4 files, convert to VideoFileClip, and concatenate them with the main clips.
11 54:03 Load a transition MP4 file, convert to VideoFileClip, and insert it between each clip in the loop.
12 65:40 Extract author name from filename, create a TextClip with font, size, color, position, and duration, then composite it over the video using CompositeVideoClip.
13 66:39 Install ImageMagick and configure moviepy's config_defaults.py with the path to magick.exe.

Study Flashcards (12)

What Python library is used for video editing in this course?

easy Click to reveal answer

MoviePy

00:02

What is the first step to install Python?

easy Click to reveal answer

Download the latest version from python.org and run the installer, checking 'Add Python to PATH'.

02:39

Which VS Code extensions are recommended for Python development?

easy Click to reveal answer

Python extension and Code Runner extension.

06:08

How do you install MoviePy?

easy Click to reveal answer

Run 'pip install moviepy' in the terminal.

07:58

What function is used to convert an MP4 file into a MoviePy-compatible video object?

medium Click to reveal answer

VideoFileClip

19:34

How do you resize all clips to full HD in MoviePy?

medium Click to reveal answer

Use the target_resolution parameter in VideoFileClip, e.g., target_resolution=(1080, 1920).

21:20

What function combines multiple video clips into one?

medium Click to reveal answer

concatenate_videoclips

23:12

How do you add background music that loops to match video duration?

hard Click to reveal answer

Use AudioFileClip to load music, then audio_loop with duration=final_video.duration, and composite with CompositeAudioClip.

33:37

What is the purpose of ImageMagick in MoviePy?

medium Click to reveal answer

It is a dependency required to write text on videos.

66:39

How do you configure MoviePy to find ImageMagick on Windows?

hard Click to reveal answer

Edit the config_defaults.py file in the moviepy folder and set the IMAGEMAGICK_BINARY variable to the path of magick.exe.

70:51

What function creates a text clip in MoviePy?

medium Click to reveal answer

TextClip

80:28

How do you overlay a text clip onto a video clip?

hard Click to reveal answer

Use CompositeVideoClip with a list containing the video clip and the text clip.

83:37

💡 Key Takeaways

💡

Real-World Automation Project

The course uses a practical example (compiling Valorant clips) that can be adapted to any video compilation.

00:10
🔧

Resizing to Full HD

Ensuring all clips have uniform dimensions (1920x1080) prevents black bars and maintains professional quality.

21:20
🔧

Looping Background Music

The audio_loop function automatically repeats music to match the exact video duration, a common requirement in compilations.

33:37
🔧

Automated Text Credit

Extracting author names from filenames and overlaying them as text demonstrates how to add dynamic, per-clip information.

65:40
📊

Final Video Quality

The end result is a full-HD, 60fps video with intro, outro, transitions, music, and text—matching professional compilation standards.

91:00

✂️ Creator Tools: Viral Hooks

AI-generated clip ideas for Shorts based on the transcript

Automate Video Editing with Python & MoviePy

45s

Shows a practical, time-saving automation that appeals to content creators and developers.

▶ Play Clip

Resize All Clips to Full HD in One Line

45s

Demonstrates a simple fix for a common video editing problem, making it highly shareable.

▶ Play Clip

Concatenate Videos with Python in Seconds

45s

Highlights the power of automation by combining multiple clips into one video effortlessly.

▶ Play Clip

Add Looping Background Music Automatically

45s

Solves a common editing challenge (matching music length) with a clever loop technique.

▶ Play Clip

Insert Transitions Between Clips Programmatically

45s

Shows how to add professional transitions without manual editing, appealing to efficiency seekers.

▶ Play Clip

[00:00] Hello everyone. Welcome to this course

[00:02] dedicated to learning the movie PI

[00:04] library for Python in order to automate

[00:07] the editing of your videos. The goal of

[00:10] this course is to teach you how to

[00:11] develop Python scripts capable of mass

[00:14] processing your videos. You will learn

[00:17] how to write Python scripts to process

[00:19] hundreds of videos at once. Whether

[00:22] resizing, cropping, converting formats,

[00:25] adding text, music or transitions, Movie

[00:29] Pie greatly simplifies mass video

[00:31] editing while producing a professional

[00:34] quality videos ready for publishing on

[00:36] online platforms. In this course, we

[00:39] will work on a real world video editing

[00:41] automation project. It will involve

[00:44] automatically compiling the best moments

[00:46] of a video game with a series of edits,

[00:49] which is a representative real world

[00:51] case that can be easily automated to

[00:54] handle large amounts of video. The

[00:56] Python script can then be reused for any

[00:59] other type of compilation such as

[01:01] compilations of sports highlights,

[01:03] compilations of funny animal videos,

[01:06] etc. And you don't need any prior

[01:09] knowledge as the course explains

[01:11] everything you need to know and provides

[01:13] all the necessary resources. You can

[01:15] complete the course at your own pace. So

[01:18] without further ado, let's start this

[01:21] course together to learn how to automate

[01:23] your video editing with the Python and

[01:26] Movie Pie.

[01:28] During this training, I will be using

[01:31] the code editor Visual Studio Code. It

[01:33] is a widely used code editor that offers

[01:36] many advantages. So if you also want to

[01:39] work with it, I will show you in the

[01:41] next video how to install it on your

[01:43] computer and how to install Python with

[01:45] it if it's not already done. However, if

[01:49] you already have a code editor installed

[01:51] on your computer that you prefer to use,

[01:53] you can certainly continue using it

[01:55] during this course. You can use any code

[01:58] editor you prefer. And for those who

[02:00] want to install Visual Studio Code as

[02:02] well as Python if it's not already done,

[02:05] we will see how to do all that in the

[02:08] next video. In this video, we will see

[02:11] how to easily install Python and Visual

[02:13] Studio Code. You will see it only takes

[02:16] a few steps and a few minutes, allowing

[02:18] us to access to this very widely used

[02:21] development environment. It is currently

[02:23] the most popular development environment

[02:25] in the world used for many languages

[02:28] including Python. So to begin, we will

[02:31] first install Python because we need the

[02:33] programming language installed before we

[02:35] can use it in Visual Studio Code. So

[02:39] let's go to the official Python page.

[02:41] Click on downloads. And here you should

[02:44] see a yellow button offering to download

[02:46] the latest version of Python for your

[02:49] operating system. Since I'm on Windows,

[02:52] it suggests downloading Python for

[02:54] Windows. I can see that they are

[02:56] proposing me the version 3.11 of Python,

[02:59] but by the time you watch this video,

[03:01] there may be a newer version like 3.12,

[03:05] 3.13. You can just download the version

[03:08] displayed on your screen without any

[03:10] issues. So, let's click on download

[03:12] Python. Theex file starts downloading.

[03:15] Let's wait for it to download. All

[03:17] right, so it's done on my side. And once

[03:20] it's downloaded, we can launch the

[03:22] executable file. So we have this window

[03:26] that is appearing here. It's very

[03:28] important check the box add the

[03:30] python.exit to path. So this is a small

[03:33] option related to what we call

[03:35] environment variables. I highly

[03:38] recommend checking this box as it might

[03:40] not work properly if you don't. Then

[03:43] let's click on install now. Click yes

[03:46] and wait for the installation. Once the

[03:48] installation is complete, we get the

[03:50] message setup was successful. So the

[03:53] installation went correctly. We can

[03:55] click on this option disable path length

[03:58] limit because on some operating systems

[04:01] particularly Windows there is a limit on

[04:03] the length of path for accessing a file.

[04:07] If your path exceeds 260 characters, it

[04:11] might be impossible to navigate through

[04:13] such a long path and retrieve a file at

[04:16] the end. This situation rarely occurs

[04:18] but to be safe we can click here then

[04:21] click yes and it's done. We can click on

[04:24] close and now Python is installed on

[04:27] your computer. Next we will install

[04:29] Visual Studio Code. Now that we have the

[04:32] Python programming language on your

[04:33] computer, we need a development

[04:35] environment. Basically a software that

[04:37] will allow us to easily write and

[04:39] execute Python code. And for that we're

[04:42] going to use Visual Studio Code. So

[04:44] let's search for Visual Studio Code.

[04:49] Click on the first link and then click

[04:51] on download. You can select your

[04:53] operating system. Again, since I'm on

[04:56] Windows, I choose Windows. And then we

[04:58] can see that it starts downloading.

[05:00] Let's wait for it to download. All

[05:02] right, it's done on my side for the

[05:04] download of VS Code. Once it's done,

[05:07] similarly, click on the X file. It will

[05:11] launch. Then here we can click on I

[05:14] accept the agreement then next. You can

[05:17] change the installation folder if you

[05:19] wish but I'll continue clicking next.

[05:21] Leave it as default. Click next again

[05:23] and it's installing.

[05:27] Perfect. So the installation was very

[05:29] quick.

[05:31] It will launch and we land on this

[05:33] window.

[05:36] So you can close the welcome window if

[05:39] you want.

[05:41] You can change the theme to either a

[05:44] white background with different colors

[05:46] or a black background with higher

[05:48] contrast. I recommend keeping the

[05:51] default theme which is dark and modern

[05:54] to avoid the eye strain. You can now

[05:56] close this window.

[06:00] Now before we start coding, let's

[06:03] install two extensions to facilitate

[06:05] programming in VS Code.

[06:08] So click on the extension button here.

[06:11] Then install the Python extension which

[06:13] is the first one.

[06:16] Click on install. It's very quick.

[06:21] And once it's installed, we can install

[06:23] another extension called code runner

[06:27] which will add a button to easily

[06:29] execute Python code. So click on

[06:31] install. Again, it's very quick.

[06:36] Once done, you can close these two

[06:39] windows.

[06:41] I recommend closing and reopening VS

[06:43] Code to ensure all extensions load

[06:45] correctly. Do this just once after

[06:47] installing the extensions.

[06:50] Now, let's test a Python code to see if

[06:53] everything works correctly. So, we can

[06:55] create a new Python file by going to the

[06:57] top left. Let's click on new file and

[07:00] select Python file. You can write here

[07:02] anything. I will type print hello world.

[07:05] the typical first code when learning a

[07:07] new programming language.

[07:10] Let's save the file by pressing Ctrl S.

[07:14] Save it on the desktop. For example,

[07:16] name it test and click save. Now the

[07:21] file appears on the desktop as a test.

[07:24] py. Now execute it by clicking on the

[07:27] run code button and you should see the

[07:30] text hello world in the console.

[07:32] Perfect. So that was all for this video.

[07:35] We saw how to install Python, Visual

[07:38] Studio Code, and some extensions to make

[07:40] writing Python code easier. During this

[07:43] training, we will use the Movie Pi

[07:45] library, which was developed for Python.

[07:47] This library will allow us to do video

[07:50] editing in Python and more importantly,

[07:53] it will allow us to automate the editing

[07:55] of videos massively. Note that this

[07:58] library does not come with Python when

[08:00] we install Python for the first time. So

[08:03] you will need to install it separately.

[08:05] To do this, it's very simple. Open your

[08:08] terminal and then simply type pimp

[08:10] install pie like this.

[08:14] You can do this in a virtual environment

[08:16] if you prefer. Once done, press enter.

[08:19] The Movie Pi library will then be

[08:21] installed. So I've already installed the

[08:24] library on my side, so I don't need to

[08:26] do it again. But you will see it will

[08:29] install quickly and then we can start

[08:31] developing. So that was all for this

[08:33] video. Thank you everyone.

[08:36] All right. So you will find in the

[08:38] description of this video the resources

[08:40] that we will use during this training.

[08:43] It is a zip file that you can download

[08:45] and it is approximately 160 mgabytes. So

[08:49] it might seem a bit large but that's

[08:51] normal because it contains videos that

[08:54] we will use for the training. So these

[08:57] are the videos that we will assemble

[09:00] using movie pie and where we will do

[09:02] editing. So I invite you to download the

[09:05] zip file. You can place it somewhere on

[09:07] your computer. You can create a brand

[09:09] new folder that will contain the entire

[09:12] project that we will do during this

[09:14] training. So that's what I did. I

[09:16] created a new folder called the Movie Pi

[09:19] course. And in this folder, I placed the

[09:21] zip file that you can download from the

[09:24] description. So let's extract this file

[09:26] to retrieve the files inside. I click on

[09:30] extract all and then I click on the

[09:33] extract button. Now we have this folder

[09:36] that appears. Let's go inside right

[09:38] away. Inside this folder we can see that

[09:40] we have three other folders and a file

[09:42] in in the Python format. We will go

[09:45] through each of these elements one by

[09:47] one. So we can see that we have a first

[09:49] folder called the clips. If we go

[09:51] inside, we can see that we have 10

[09:54] videos in MP4 format. So these are

[09:57] videos that are about 30 seconds long

[09:59] and our clips from the video game

[10:01] Valerant. So during this training, these

[10:04] are the clips that we will use and we

[10:07] will see how to assemble them, edit them

[10:09] using Python and Movie Pie, add music,

[10:12] transitions, an introduction, etc. The

[10:16] idea is that we can then use this script

[10:18] for many other clips to generate

[10:20] automated videos whenever we have clips

[10:23] like this. So in this video, we'll make

[10:25] a compilation of the best moments from

[10:27] the game Valerant. But you understand

[10:29] that the script can work with any other

[10:32] of video game clips or it can also be

[10:34] clips for anything really. It could be

[10:37] clips of the best moments in sports, in

[10:39] football for example, etc. So that will

[10:42] be our goal during this training.

[10:44] assemble all these clips automatically,

[10:47] edit them and finally obtain a full HD

[10:50] video that we can then publish on the

[10:52] video platforms. So here I have just

[10:55] taken 10 clips. We could have added more

[10:58] but it is sufficient for this training.

[11:00] You can then go back to your folder. We

[11:02] will see another folder called the

[11:04] output which is empty for now. And this

[11:07] is the folder we will use to store the

[11:09] final videos generated by our Python

[11:12] program. For now, it is empty because we

[11:15] have not yet created the program and we

[11:18] have not yet executed it to have the

[11:20] final video created by the program.

[11:22] Let's go back to our folder. And

[11:24] finally, we have the resources folder

[11:27] where inside we have a number of

[11:30] resources that we will use for the

[11:32] editing. We have a font that we will

[11:34] use, an introductory video that we will

[11:37] place at the very beginning of the video

[11:40] before the clips play, a music track

[11:43] that will play in the background, an

[11:45] outro video. So, this one is the very

[11:48] last video that will be shown at the end

[11:50] of the video, and finally a transition

[11:53] video file between each clip. You will

[11:55] see we will integrate each of these

[11:58] elements as the course progresses. Next,

[12:01] we can return to the folder we have

[12:03] created. And here we finally have a

[12:05] Python file that is currently empty. So

[12:08] I open it and we can see that inside

[12:11] there is no code, nothing. I just

[12:14] created it and placed it in this folder

[12:17] to save some time for you. And it is in

[12:19] this Python file that we will write all

[12:21] of our code. All right. Also, if we

[12:25] click on this little button here, the

[12:27] explorer button, we can see that there

[12:29] is no folder attached to Visual Studio

[12:31] Code currently. So, what we will do is

[12:34] click on the open folder button here.

[12:36] You can also do it by clicking on the

[12:38] file button, then open folder. So, I

[12:41] click on it and then I have to find the

[12:44] folder where the Python script is

[12:47] located. So we have the movie pi course

[12:50] resources folder and as soon as we enter

[12:53] in this folder we arrive here where we

[12:56] have our three folders clips outputs and

[12:59] resources and this is the folder that we

[13:02] will open. So I click on the select a

[13:05] folder button my visual studio code

[13:07] window refreshes and then we can see on

[13:10] the left that I have the three folders

[13:12] of my directory. So again we have the

[13:15] clips folder which contains the 10 clips

[13:18] we will work on, the output folder which

[13:21] will contain the videos we will create

[13:24] and the resources folder which contains

[13:27] the various resources we will integrate

[13:29] into the video. And of course we have

[13:31] the Python file that I have just showed

[13:33] you which is currently empty and on

[13:36] which we will write all of our code. So

[13:38] when you want to execute the code or

[13:40] modify it, always remember to open the

[13:43] folder where all these elements are

[13:46] located. So they will be displayed here.

[13:48] And this way the Python script will not

[13:50] have any problems finding the different

[13:52] resources because the Python code here

[13:56] will need these resources to create the

[13:58] video which you will see later in this

[14:00] course. Again, the zip file to access

[14:03] these resources is available in the

[14:05] video description. So feel free to

[14:07] download it and once that is done we

[14:10] will meet in the next video to start the

[14:13] development.

[14:15] Now that you have put in place all the

[14:17] necessary resources for automatic video

[14:19] editing. We can start the development.

[14:22] First if we open the clips folder

[14:24] contained in the zip file we downloaded.

[14:27] We can see the different videos we will

[14:29] be looking to assemble and edit during

[14:32] this course. Here we have taken the

[14:35] example of 10 clips from the video game

[14:37] Valerant. But of course they can be

[14:40] clips of anything. You just need to have

[14:42] a series of videos to assemble and the

[14:45] code that we will write will work. So

[14:48] let's open one of the clips together to

[14:50] see what the video contains.

[14:57] >> Nice.

[15:01] Got him.

[15:04] Spike down.

[15:06] >> One enemy remaining.

[15:14] >> So, as you can see, these are best

[15:16] moments clips from Valerant featuring

[15:19] some great actions on the video game.

[15:22] So, we have 10 of them. And uh in this

[15:25] first video of the course, we will

[15:27] develop a method to assemble these 10

[15:30] clips into a single MP4 video that

[15:33] combines all of them. For that, we can

[15:36] go back to Visual Studio Code and let's

[15:39] create a video in MP4 format that

[15:41] combines all of them. So here I'm in the

[15:44] folder that we've obtained with the zip

[15:46] file. You can just open the automatic

[15:49] video editing Python file which is the

[15:52] Python file we will use throughout this

[15:54] training for our development. It is

[15:57] currently empty and let's start writing

[15:59] our code. So the first thing we will do

[16:02] is retrieve all the clips in the clips

[16:05] folder using the Python file. So here in

[16:08] the directory we have our 10 clips and

[16:12] we need to fetch them with the Python.

[16:14] To do this, let's use a library called

[16:16] the globe. So, this library is used to

[16:19] search for files on your computer. Next,

[16:22] we will create a variable containing the

[16:24] path to access each of these clips.

[16:27] Let's type a comment first. It's a

[16:30] convention I recommend you to follow.

[16:32] You should really add comments in your

[16:34] code to explain what we do at each step.

[16:36] So, here let's type collect all clips

[16:39] and then let's create a new variable

[16:42] called the clips. We can use the globe

[16:44] function from the globe library. So we

[16:47] need to type globe twice here. globe.g

[16:50] globe. Let's open parenthesis and

[16:52] specify the path to access the clips. So

[16:56] we open parenthesis with quotes and type

[16:59] the clips folder name. So if you wanted

[17:02] to access the output folder, we will

[17:04] type output. Let's type a slash and then

[17:07] specify that we want to fetch all files.

[17:10] So there are 10 of them. There are

[17:12] several ways to do this. We can manually

[17:15] specify the name of each clip or we can

[17:18] use more efficient methods to specify

[17:20] all files with the same extension. Here

[17:23] we can see that each of our files is in

[17:25] MP4 format. So we can put an

[17:28] asterisk.mpp4

[17:30] to retrieve all the MP4 files in this

[17:33] folder allowing us to get all our clips.

[17:36] We can see if Python correctly fetches

[17:38] our different clips. To do this, you

[17:41] just have to type print open parenthesis

[17:44] clips. Remember to save your code by

[17:46] pressing Ctrl S and then run the code.

[17:50] So I executed the code and we can see in

[17:53] the console the path to all our clips

[17:55] appearing. Note that for the clip names,

[17:58] we have the clip numbering first and the

[18:01] player's name. So the player who

[18:03] performed the action on the right. So at

[18:06] this stage we have just retrieved the

[18:08] path to treat them. Let's delete the

[18:11] print statement. It's unnecessary right

[18:14] now. And let's create a list to contain

[18:17] all these clips. Right now the clips are

[18:20] all separated. And our goal is to group

[18:23] them into a single MP4 video. So let's

[18:26] start by creating an empty list. Let's

[18:28] type uh initialize a list to store all

[18:31] processed clips. So this list will be

[18:34] called all clips. I advise you to use a

[18:37] clear variable names to understand their

[18:39] purposes. So this list will store all

[18:41] the videos. And to list the clips, uh

[18:45] let's create a loop to fetch all these

[18:47] clips, transform them into movie pie

[18:50] objects for their processing. So here

[18:53] let's type a comment process each game

[18:55] clip and uh let's create a loop. We can

[18:58] type for clip path in clips. So for each

[19:02] clip you have fetched we will process

[19:04] it. The first point that we have to do

[19:07] is that each MP4 file that we have is in

[19:10] a format that cannot be manipulated by

[19:13] movie pie. When the movie pie library

[19:15] edits the different videos we provide.

[19:18] It cannot work directly with the MP4

[19:20] files. It's a file format that we have

[19:23] to adapt for movie pie to perform

[19:25] operations on it. So to do this we first

[19:28] need to import a function from the movie

[19:30] pie library. So let's type from movie

[19:32] pi.editor

[19:34] import video file clip. Video file clip

[19:37] is the function that will allow us to

[19:39] convert these MP4 videos into a format

[19:42] that movie pie can process. Let's type a

[19:45] comment create a video file clip object

[19:48] and resize it.

[19:52] I will explain the resize port later. So

[19:55] let's create a new variable called the

[19:57] video_clipip and call the function we

[20:00] just imported video file clip with clip

[20:03] path. So this little piece of code will

[20:06] convert the MP4 video into a format that

[20:09] MoviePie can use for editing. But the

[20:12] final video will be in MP4 format to

[20:14] publish on any platform. So don't worry

[20:17] about it. By the way, it can also be

[20:19] under format. It's not limited to MP4.

[20:22] It can be for example.

[20:24] So next, an interesting feature that

[20:27] comes with the function video file clip

[20:29] is that we can also resize each clip.

[20:32] Generally, we want our final videos in

[20:35] full HD format. So in 1,920x

[20:39] 1,080 pixels, but some clips can come in

[20:43] different formats, such as 1,280x

[20:48] 720 pixels or smaller or larger formats.

[20:52] And if all the videos don't have the

[20:54] same dimensions, the final video will

[20:57] have some clips appearing too small or

[21:00] too large, which won't look good. So, we

[21:03] add a bit of code to ensure all clips

[21:05] have the same dimensions. So, here we

[21:08] will choose 1,920x

[21:11] 1,080 pixels, which is a full HD format

[21:15] used by all video platforms. So here

[21:18] let's type a comma and type

[21:20] target_resolution

[21:22] equals we can open parenthesis here and

[21:25] then we type 1,80

[21:28] comma 1,920.

[21:31] So we put the height first and then the

[21:34] width. And this code will ensure that

[21:36] all the MP4 files will be in 1,920x

[21:41] 1080 format avoiding dimension issues.

[21:45] If you want, you can test this by taking

[21:47] some clips with different formats. By

[21:50] the way, to know the video format, go to

[21:53] the clips folder, pick a video, right

[21:55] click, then click on properties, and in

[21:59] the details tab, you'll see the video

[22:01] dimensions. So, here we have 1,920x,80

[22:06] pixels. So, this video doesn't need

[22:09] modification since it's already in full

[22:11] HD format. But if it were, for example,

[22:14] in 1,280

[22:17] by 720 pixel, which is a common format,

[22:21] the program will then resize it to

[22:23] 1,920x

[22:26] 1,080 pixels. Perfect. So next, we will

[22:31] add each processed video to the list we

[22:33] created earlier to have all the videos

[22:36] in one list to concatenate them later.

[22:39] So let's type a comment add the

[22:41] processed clips to the list and then we

[22:44] can type the code all clipsapped

[22:48] within parenthesis video clip. So this

[22:51] line adds each video clip to the all

[22:53] clips list. To summarize, in this loop,

[22:56] we have fetched each clip from the clips

[22:58] folder, convert it to the video file

[23:01] clip format used by Movie Pie, resized

[23:03] it, and add it to the all clips list to

[23:06] have all videos in just one list.

[23:09] Finally, we have to concatenate these

[23:12] clips. So here, let's type a comment

[23:14] concatenate all processed clips. We can

[23:17] create a new variable called the final

[23:19] video and import a new function called

[23:22] uh concatenate video clips. This

[23:25] function will allow us to combine all

[23:27] the clips into one video. And here we

[23:30] specify the list containing our clips

[23:33] which is the um the variable all clips.

[23:38] So now the last step is generating our

[23:41] MP4 video. Let's type a comment. write

[23:44] the final video to an MP4 file.

[23:48] We can retype our variable final video

[23:51] and then use the function write video

[23:54] file. So this code will convert our

[23:57] edited video back to MP4 format. We open

[24:00] parenthesis and specify the folder to

[24:03] save the video. So let's save it in the

[24:06] output folder which has been created to

[24:08] store our edited videos. So I'm typing

[24:11] here output/ video.mpp4.

[24:14] By the way, the video.mpp4

[24:17] will be basically the name of your video

[24:20] inside your computer. So you can replace

[24:23] the video port with any name you want

[24:25] actually. But here I'm keeping it

[24:28] simple. I'm just typing video. It's

[24:30] sufficient for the moment. And uh don't

[24:32] forget to specify the format. So here I

[24:35] have typed MP4. Lastly, we must specify

[24:39] the number of FPS's we want in the

[24:42] video. Usually, we use 60 FPSs for

[24:45] smooth videos. So, I type FPS equals to

[24:49] 60. Basically, FPS's are the number of

[24:52] frames per second in your video. The

[24:55] more you have, the more your video will

[24:57] be better. It will be more smooth, more

[24:59] fluid. Next, uh let's save the script

[25:03] here. I'm pressing the Ctrl S. And we

[25:06] can run it to see if we got our final

[25:08] edited video with all the clips

[25:10] combined. But just before running the

[25:13] code, remember that the more clips are

[25:15] in the folder, the longer will be the

[25:18] execution of the code. Here we work with

[25:20] the MP4 videos, each about something

[25:23] like 30 seconds long. So the execution

[25:26] may take a while, but keep in mind that

[25:29] this is normal. If you have used editing

[25:31] software like Adob Premiere Pro or Final

[25:34] Cut Pro, you know that rendering videos

[25:37] takes time. Here we basically do the

[25:40] same but with the Python. So save your

[25:43] code and run it. And keep in mind that

[25:46] it's normal if it takes time. So to run

[25:48] the code in Visual Studio Code, click on

[25:50] run a Python file rather than run code

[25:53] to execute the code directly in the

[25:56] terminal. This avoids display issues in

[25:59] the output window. So here I clicked on

[26:02] run Python file. We see a message from

[26:05] movie pile confirming the video is being

[26:07] edited with the audio editing first and

[26:10] then video editing. Uh progress

[26:13] percentage appears and at 100% our video

[26:16] will be ready. And by the way, this

[26:19] display in the terminal is why I

[26:22] recommend clicking on run Python file as

[26:24] the percentage display might be

[26:26] incorrect in the terminal if we have

[26:29] clicked on run code.

[26:38] Perfect. So here we are at 100%. We see

[26:42] a message from movie pie saying the

[26:44] video is ready in the indicated path. So

[26:48] let's check the output folder and here

[26:50] we can find the video. I double click on

[26:53] it. So the video last 3 minutes

[26:56] containing all our clips. We can quickly

[26:58] view it. So the first clip is displayed.

[27:07] One enemy remaining.

[27:15] >> Advancing, we see the second clip that

[27:18] follows automatically.

[27:31] >> Head shot.

[27:39] One enemy remaining.

[27:43] >> And this continues until the last clip.

[27:46] Perfect. So now we have our video with

[27:50] all the clips assembled. So to

[27:53] summarize, in this video we saw how to

[27:55] combine multiple MP4 files into one. We

[27:58] concatenated all the clips and resized

[28:01] them to 1,920

[28:03] by 1,080 pixels to ensure uniform

[28:07] dimensions. Without resizing, some clips

[28:10] will appear smaller with black bars on

[28:13] the sides, which will not look good.

[28:15] With this code, we can assemble many

[28:18] clips into a final HD video with the 60

[28:21] fps. You can verify this by right

[28:24] clicking on the output video, selecting

[28:26] properties and checking the details tab.

[28:29] So here we can see that the video is in

[28:31] the full HD dimensions and with the

[28:34] 60fps. So at this stage we have a video

[28:38] base for further editing. And during

[28:40] this course, we will modify this video

[28:43] to add an intro, an outro video, a

[28:46] background music, some transitions

[28:48] between clips, and text to credit the

[28:52] authors of the clips. So, keep your code

[28:55] as well. We will improve it in the

[28:57] future videos. And I'll see you in the

[28:59] next video.

[29:01] Now that we have seen how to concatenate

[29:03] a set of videos to generate a single

[29:05] video in MP4 format, we will look to

[29:07] improve this video a bit. So if I go

[29:10] back to my directory in the outputs

[29:12] folder, I have the video that we

[29:14] generated in the previous tutorial. So

[29:17] I'm opening it. And as a result, it's

[29:21] simply the 10 clips that we have

[29:22] assembled. But the editing of this video

[29:25] is very basic. We only group the videos

[29:28] together, resize them, and export them

[29:31] with the 60fps. But for this type of

[29:34] video, for this kind of compilation,

[29:37] it's good to add other elements on top,

[29:39] such as a background music. It is very

[29:42] common to see a little background music

[29:44] in this type of video, and that's what

[29:46] we're going to do in this video. We will

[29:48] ensure to add a background music that

[29:50] lasts the entire duration of the video.

[29:53] So, this video currently last 3 minutes

[29:56] and 4 seconds, and we will make sure to

[29:58] add a music that also stops at 3 minutes

[30:01] and 4 seconds. And we will even modify

[30:04] the code to ensure that if our music

[30:06] only lasts two minutes, for example, and

[30:08] the video with the assembled clips last

[30:10] three minutes, we will make the music

[30:13] loop so that it restarts and ends

[30:16] precisely at 3 minutes and 4 seconds.

[30:19] Perfect. So, let's close this window and

[30:22] we can go in the resources folder. So in

[30:26] the resources folder, there are several

[30:28] elements that we will use during this

[30:30] training, including the music element,

[30:33] which is the music we will play in the

[30:35] background. You can open this file to

[30:37] listen to the music if you wish. So it

[30:40] is an MP3 file. I open it. I let you

[30:43] listen to the music if you wish.

[30:53] So, it's a music that has a bit of a

[30:55] video game feel and it is, by the way, a

[30:58] royalty-free. It is a music by the

[31:00] artist Kevin Mle, which is a

[31:02] royalty-free and can be used as long as

[31:05] you mention the author. So, thanks to

[31:07] him. And it's also a music that fits

[31:09] well with the theme of the video we are

[31:11] editing. So, a compilation of best

[31:14] moments in video games. Perfect. Let's

[31:16] move to our Python code. Here I'm on my

[31:19] Python code and the first thing we will

[31:21] do is to retrieve the music as we did

[31:24] for the clips. So if I go to resources,

[31:28] we will retrieve the music.mpp3 file.

[31:31] For that, let's modify the code a bit.

[31:34] So let's keep a line here and type

[31:36] define path for resources like this. And

[31:40] let's create a variable called the music

[31:43] path. So the path to access the music,

[31:46] let's use a quotation marks as we did

[31:48] for the clips. And this time we will not

[31:51] use the globe function with an asterisk

[31:54] MP4 since we are looking for only one

[31:57] MP3 file and not all elements in the

[32:00] resources folder. So I will type the

[32:02] name of the folder first resources. So

[32:06] this folder slash and here I will type

[32:09] the name of my file. So music.mpp3 MP3

[32:13] like this. So we have retrieved the path

[32:15] to access our music and we will be able

[32:18] to integrate it into our video. For that

[32:21] we will need to import a new function

[32:24] which is the audio file clip function.

[32:27] So this function works exactly like the

[32:29] video file clip function. So video file

[32:32] clip allows us to convert a video to the

[32:35] movie by format so that we can edit it.

[32:38] And audio file clip is exactly the same

[32:41] but for audio files. So we convert audio

[32:44] files maybe MP3 files for example to a

[32:48] format that can be edited by Movie Pie.

[32:50] Very well. So let's modify our code. We

[32:53] can skip a line here. And after using

[32:56] the concatenate video clips function, we

[33:00] will type a comment. It will be a bit

[33:02] long because we will perform certain

[33:04] operations. Let's type load a background

[33:07] music and loop it to match the duration

[33:11] of the clips. So first we will load the

[33:14] background music and then we will loop

[33:16] it to match the duration of the clips.

[33:18] So if our music lasts only 2 minutes but

[33:22] the total duration of our clips is 6

[33:24] minutes then we will loop the music so

[33:28] that it ends at the end of the 6

[33:30] minutes. We will basically repeat the

[33:33] music until the clips end. Very well. So

[33:37] let's create a new variable called the

[33:39] background music abbreviated as a bg

[33:42] music. Let's type equal and here we use

[33:45] the function we imported. So audio file

[33:48] clip like this. I open parenthesis and

[33:52] here I simply put the path to the music

[33:54] we defined here. There. So we have

[33:57] loaded the music and converted it to the

[33:59] format used by Movie Pie. Then we need

[34:02] to modify the duration of the music to

[34:04] match the total duration of the clips.

[34:07] For that we will create a new variable

[34:09] called the loop to music and we will use

[34:12] a new function that we will also import.

[34:14] This time let's type from movie audio fx

[34:19] all import audio loop. So it's a new

[34:22] function that we import and we'll use

[34:24] directly. So we type audio loop like

[34:28] this. We open parenthesis and we specify

[34:31] the music we want to shorten or

[34:33] lengthen. So let's type the variable we

[34:36] just created here background music. And

[34:38] then we must specify the duration this

[34:40] music should have. For that we type the

[34:43] parameter duration like this. And to get

[34:46] the duration it's very simple. We type

[34:49] our concatenated video just here. So

[34:52] final video I remind you that this line

[34:54] of code allows us to concatenate all our

[34:57] videos and so it contains our final

[34:59] video and if I call this variable in the

[35:01] duration parameter and then type the

[35:04] method duration I will be able to

[35:07] retrieve the total duration of the video

[35:09] with all the clips grouped together and

[35:12] that's what we want with this line of

[35:14] code we have modified the duration of

[35:16] the music to match the duration of all

[35:18] the grouped clips. So, for example, if

[35:21] all the grouped clips last 4 minutes and

[35:24] 15 seconds in total, then the music here

[35:27] will also last 4 minutes and 15 seconds.

[35:31] How does this work? Basically, the music

[35:33] is replayed to match the duration of the

[35:36] video. Now that we have modified the

[35:38] duration of the music, we need to

[35:40] integrate it into the video because

[35:42] currently in the code we wrote, we have

[35:45] only converted to music to the format

[35:47] used by Movie Pie and modified its

[35:50] duration. But we have not yet integrated

[35:53] it into the video. For this, let's type

[35:56] a new line of code here. First, I will

[35:58] type a comment combine the audio of the

[36:00] clips with the background music. And so

[36:03] to do this, we must import again a new

[36:06] function which is the composite audio

[36:09] clip function. This function will allow

[36:11] us to combine the background music with

[36:13] the audio from the clips. So we will

[36:16] basically merge the two audio tracks

[36:18] into a single track. I will create a new

[36:21] variable here called final video with

[36:23] the music. In this variable I will call

[36:26] the final video variable. So this is the

[36:29] video that does not contain the music

[36:31] only the assembled clips and I will use

[36:34] the set audio method to define the audio

[36:37] that will play in this video. Next let's

[36:40] open parenthesis and use the function we

[36:43] just imported composite audio file clip

[36:46] and then open again some parentheses and

[36:49] some brackets. Let's type firstly final

[36:52] video.audio to define that we will have

[36:55] the sound of the clips first. So this

[36:58] sound from the clips of Valerant. And

[37:01] then we must specify the background

[37:03] music which we defined here as looped

[37:06] music. And we also need to specify the

[37:08] duration that must match the duration of

[37:11] the clips. So I typed here set

[37:15] duration open parenthesis and type final

[37:19] video dot duration. Perfect. Then we

[37:22] just need to modify the last line of

[37:24] code because the video we will write at

[37:27] the end is no longer the final video

[37:29] variable but final video with the music.

[37:32] And now we should be good. If I execute

[37:36] this code, I should have the video we

[37:38] obtained previously, the exact same

[37:40] video but with added background music.

[37:43] And by the way, we should pay attention

[37:45] to the file name. Currently we have kept

[37:48] the same name as the video that we

[37:50] previously generated. If you leave the

[37:53] same name, it will simply replace the

[37:55] old video file. But if you want to keep

[37:58] both versions for comparison, for

[38:00] example, you can simply put a new name

[38:02] here. For example, the video with music

[38:05] and thus we will not replace the

[38:07] previous video. You do as you wish. In

[38:10] any case, it will not impact the result

[38:13] of this video. So we can now execute the

[38:16] script again. Let's go to run and click

[38:18] on run Python file. You can also click

[38:21] on run code directly but the display in

[38:24] the terminal will not be the same. But

[38:26] keep in mind that in any cases it will

[38:28] not impact the video. So let's click on

[38:31] run Python file. And now the script will

[38:34] begin to execute. Perfect. So here the

[38:37] music has been added and the video is

[38:39] currently being processed. Again, the

[38:42] more clips there are, and the longer

[38:44] they are, the longer the editing will

[38:46] take. If you want for your tests, you

[38:49] can limit the number of clips. I have a

[38:51] powerful enough computer, so I can

[38:53] afford to include all the clips. That's

[38:56] not a problem. But you, if your computer

[38:58] is struggling a little bit, you can only

[39:00] keep five or six clips and remove the

[39:03] rest. And when we will finish this

[39:06] project, you can use all the clips you

[39:08] want. Perfect. So, let's wait for the

[39:11] editing to finish. We wait to reach

[39:13] 100%. By the way, we can already see in

[39:16] the output folder that we have the MP4

[39:19] file of the video, but it is still being

[39:21] processed. We also have a temporary file

[39:24] that contains the music here, but this

[39:27] temporary file will be automatically

[39:29] deleted. And there we go. We have a

[39:31] message that says the processing is

[39:33] finished and that the video is ready in

[39:36] the output folder. So we have our video

[39:38] with the music.mpp4 file and we can also

[39:42] see that the MP3 file that appeared here

[39:45] for the editing has disappeared

[39:47] automatically. Very well. So let's open

[39:50] our folder. Let's go to the outputs

[39:52] folder. And here we can see our few

[39:54] videos with the new one that was created

[39:57] and contains the music. So let's open it

[40:00] and we will be able to hear the music.

[40:15] Spike down. One enemy remaining.

[40:27] >> Good.

[40:36] I'll run through you every

[40:43] >> very well. So of course if you wish to

[40:46] use another music you can do so you

[40:48] simply need to modify the music file

[40:50] that is here and rename it to music.mpp3

[40:54] or you can rename directly the name of

[40:56] the variable here and it will work very

[40:58] well. The script is adapted to work with

[41:00] any music. And if you plan to publish

[41:02] this video on video platforms and

[41:04] monetize the videos, make sure to check

[41:07] if you have the rights to use this

[41:09] music. So for the music we use in this

[41:12] training from the artistic Kevin Mle,

[41:14] this music is royaltyree. We can use it

[41:17] as long as we credit the author. Very

[41:20] well. So that was all for this video. We

[41:22] have seen how to put a background music

[41:24] that loops during a video. So this is

[41:27] something we see very regularly in

[41:29] compilations whether it is a video game

[41:31] compilations or sports games lot of

[41:34] things there's very often a little music

[41:36] that plays in the background and that

[41:38] makes the video more pleasant to watch.

[41:41] Perfect. So in the next videos we will

[41:44] continue to improve this video. See you

[41:47] everyone.

[41:48] Before moving on to the next lesson

[41:51] please take a moment to rate this course

[41:53] and share your feedback. I will be

[41:55] delighted to hear your thoughts on the

[41:57] content and your overall experience.

[42:00] So at this stage of the course, we have

[42:03] seen how to retrieve all our clips in

[42:05] the clips folder as well as the music.

[42:07] And then we have seen how to transform

[42:09] each clip into a format usable by Movie

[42:12] Pie. We then modify the resolution of

[42:15] each clip to be in 1,920x

[42:19] 1080 format, which is the full HD

[42:22] format. We then combined all these clips

[42:24] together to form a single video. We

[42:27] added music that we modified to match

[42:29] exactly the duration of the video with

[42:31] the combined clips. And finally, we

[42:34] exported everything in the MP4 format to

[42:37] have a video ready to be published on

[42:39] video platforms. Now, we will continue

[42:42] to make modifications to this video. We

[42:44] will see how to add an introduction

[42:46] video and an outro video to the final

[42:49] video that we edit. So, in this kind of

[42:51] compilation that you can see on the

[42:53] internet, there is often a little

[42:55] introduction with the creator's name and

[42:58] an outro video at the end where people

[43:00] are usually asked to subscribe to the

[43:03] channel. You have surely seen content

[43:05] like this before. So, in this video, I

[43:08] will show you how to add an intro at the

[43:10] beginning of the video and an outro at

[43:13] the end. For this, I have prepared some

[43:16] intro and outro files in advance. So

[43:19] these are the videos that we will add to

[43:21] our compilation. Let's quickly view

[43:23] them. So here I have the first file that

[43:26] serves as the introduction. So I click

[43:29] on it to open it and let's take a look

[43:31] at it.

[43:44] Very well. So this is the introduction.

[43:46] The idea is to place this video at the

[43:49] beginning of the video and we will do

[43:51] the same at the end with the outro. So

[43:53] for the outro, let's take a look at it.

[44:07] Perfect. So these are two videos that I

[44:10] have prepared beforehand before the

[44:12] course. And by the way, again, you can

[44:15] download all of these files if you

[44:17] haven't downloaded everything already.

[44:19] Oh, and by the way, if you have your own

[44:21] introduction or your own outro video,

[44:24] you can of course use them instead. But

[44:27] for this course, I'm going to use the

[44:29] two files that I've just showed you. Oh,

[44:32] and by the way, you might have

[44:33] recognized the background music. It's

[44:35] again the music from Kevin Mloud. It's

[44:38] the one that we have used in the

[44:40] previous video. Perfect. So let's go

[44:42] back to the code. So this was the code

[44:44] from the previous video. And first let's

[44:47] import the intro and the outro files. So

[44:51] here I type intro path equals and inside

[44:55] the resources folder. And this time I

[44:58] type intro.mpp4.

[45:00] And then we do exactly the same but for

[45:03] the outro. So I copy and paste this line

[45:06] of code. And here I put outro same I

[45:10] modify here. And perfect. So we just

[45:12] specified the path to access our intro

[45:15] video and our outro video. Then we will

[45:18] need to process these two videos the

[45:21] same way we processed the clips. So

[45:23] these videos are currently in MP4 format

[45:26] which is not a format that movie pie can

[45:29] handle. So as we did for the clips here

[45:31] with the video file clip function, we

[45:34] will do exactly the same but for these

[45:36] two videos. But you will see it will be

[45:38] very quick. Let's insert a line here and

[45:41] we can type a comment create a video

[45:43] file clip for intro. Here I will create

[45:46] a list that I will call intro clips. So

[45:49] I put clips in pl. You will understand

[45:52] later why I use the pole. It's because

[45:55] later in the training we will add other

[45:57] things to this list. So here I open

[46:00] brackets and I type the pass for the

[46:03] intro. So intro pass. And as we did for

[46:06] the clips, we can resize the videos. So

[46:10] for the intro and the outro that we

[46:12] already have in the resources, this

[46:14] video are already in the full HD format.

[46:17] So we don't actually need to specify the

[46:19] target resolution again. But if you are

[46:22] working on an intro that is not in this

[46:24] format, then it is better to put the

[46:26] code anyway. But if you are working on

[46:28] an intro that is not in this format,

[46:31] then it is better to put this code. So

[46:33] for me, even if the intro and outro that

[46:36] I'm using are already in the format

[46:38] 1,920x

[46:41] 1080, it doesn't hurt to specify the

[46:43] target resolution again so that we are

[46:46] sure that we have the full HD format.

[46:49] Perfect. So next I will copy and paste

[46:52] these two lines of code and do the same

[46:54] for the outro. So here I type outro

[46:57] clips and instead of using the intro

[46:59] path I put out pass for the target

[47:03] resolution we keep the same. And now

[47:05] that we have defined the path to access

[47:08] the intro and the outro and converted

[47:10] them with the video file clip we will be

[47:13] able to integrate them into the final

[47:15] video. And you will see it's very easy

[47:17] to do. We can go down to the bottom of

[47:20] our code and before exporting the video

[47:22] in MP4 format, let's make one last

[47:25] modification. Let's use the concatenate

[47:28] video clip function again. So I will

[47:31] copy and paste this code here. And I'm

[47:33] adding the comment uh combine the intro,

[47:36] main clips, and outro into the final

[47:39] video. In the parenthesis, let's add the

[47:42] intro and the outro that we just

[47:44] imported. So I type intro clips then I

[47:48] type plus not a comma because in Python

[47:51] when we want to combine lists we type

[47:54] plus. So intro clips plus main clips

[47:57] plus outro clips. There is a little

[48:00] particularity since intro clips and

[48:02] outro clips are lists with only one

[48:04] element inside. We need to put brackets

[48:07] in the second list which here contains

[48:10] all our clips.

[48:14] Perfect. So now if we execute this code,

[48:17] we will get our video with the intro and

[48:19] the outro. So before we execute the

[48:21] code, let's rename some variables. For

[48:24] instance, we can see that final video

[48:26] appears multiple times. Let's modify it

[48:28] here. In this line of code, we were just

[48:31] assembling the clips together, but it's

[48:33] not the final video. Let's rather name

[48:35] it clips port like this, representing

[48:38] the clips portion. And then let's modify

[48:42] the other instances where we specify the

[48:44] final video. So here we put clip sport

[48:48] and we replace it here here as well. And

[48:51] we do the same for this line. This way

[48:54] we will only have one final video

[48:56] variable which will be the actual final

[48:58] video that includes the intro, the

[49:00] clips, the outro and the music. Actually

[49:03] even this variable here can be renamed

[49:05] to clip sport as well.

[49:08] Perfect. Next uh here let's remove the

[49:12] with the music leaving just a final

[49:14] video. And here we can type video with

[49:17] intro and outro.

[49:22] Perfect. I could have specified that it

[49:24] also includes music as well, but I won't

[49:27] do that to avoid making the title too

[49:29] long. And that's it. So now we have our

[49:32] code that gathers all the clips from the

[49:34] clips folder, adds background music, and

[49:37] includes an intro and an outro at the

[49:40] end. So we can proceed to execute the

[49:42] code. So remember to save your work

[49:44] again. And now we can click on the run

[49:47] Python file button. There we go. Let's

[49:50] enlarge the terminal a bit to see the

[49:53] results better. Oh, and we can see an

[49:55] error appearing. Oh yes. Uh here in the

[49:58] brackets I need to put clips port also

[50:01] to use here the clips that have been

[50:03] concatenated. Save your code. And now

[50:06] let's reexecute it. Normally there

[50:09] shouldn't be any errors now. So I click

[50:11] on run Python file. And now the code is

[50:14] executing. We will end up with our video

[50:17] containing the intro, the outro, the

[50:19] clips and the music. Let's wait for it

[50:21] to finish. In the meantime, for those

[50:24] who used to work with Python, you may

[50:27] have noticed that for the intro and

[50:29] outro variables, we created a list. Even

[50:32] though there is only one element, it's

[50:34] not logical to create a list for a

[50:36] single element. But you will see in the

[50:38] next video that we'll make some small

[50:40] transformations where we will add

[50:42] elements to this list, making it more

[50:44] consistent to use lists. Here I prefer

[50:47] to create the list directly to avoid

[50:50] having to modify a lot of code later.

[50:52] Perfect. So if we go to the output

[50:54] folder, we should see the video being

[50:56] created here and also the audio file

[50:59] which is a temporary file created during

[51:02] the editing process. And uh this file

[51:05] will be automatically deleted afterward.

[51:07] Perfect. So let's wait for the code to

[51:09] finish executing.

[51:12] And there we go. The code has finished

[51:14] executing and the video have been saved

[51:16] in the output folder. So let's go check

[51:19] the results immediately. Here we can see

[51:21] the video with a different thumbnail

[51:23] from the previous videos because a new

[51:26] element has been added. So I click on it

[51:29] and theoretically we should start

[51:31] directly with the intro then the clips

[51:34] and finally the outro. So let's play the

[51:37] video.

[51:47] First we see the intro and then it

[51:50] directly transitions to the clips.

[52:02] >> One enemy remaining.

[52:15] Let's quickly go through the other

[52:16] clips.

[52:23] And if I go towards the end, we should

[52:25] see the outro.

[52:52] Perfect. So, we can see that the code

[52:54] worked very well. We start with the

[52:56] intro, then move on directly to our

[52:59] clips. And at the end after the last

[53:02] clip, we transition directly to the

[53:04] outro with a little video thanking

[53:06] viewers for watching and reminding them

[53:09] to subscribe. Perfect. So, we are

[53:12] getting closer to the compilation videos

[53:14] we can find on the internet. We

[53:16] understand that this editing process can

[53:18] be easily automated with the Python and

[53:20] Movie Pie. As seen throughout this

[53:22] course, we are gradually creating a very

[53:25] polished video with an intro, an outro,

[53:28] a music clips in full HD format, 60fps,

[53:32] making it very close to our professional

[53:34] video that could be easily published on

[53:37] a video platform. Of course, we will

[53:39] make a few more tweaks to improve this

[53:41] video, which we will see in the upcoming

[53:44] videos. So, that's all for this video.

[53:46] Remember to save your code by pressing

[53:48] Ctrl S. If you want to clean the

[53:50] console, you can write the clear command

[53:53] in the console and execute it. Perfect.

[53:57] So that was all for this video. I see

[53:59] you in the next one for more editing.

[54:03] In this video, we will see how to add a

[54:05] transition between each clip. So if we

[54:08] go back to the video we have created in

[54:10] the last video. So I'm going to my

[54:12] output folder and it was this video.

[54:15] Let's take a look at it. Here we are on

[54:18] the intro and you will see that when we

[54:20] move to the first clip, there is no

[54:22] transition. It's a bit abrupt.

[54:28] We moved directly to the first clip

[54:31] without any transition or anything.

[54:33] Personally, I don't find it very

[54:35] pleasant to watch. And it's the same for

[54:38] all other transitions between each clip.

[54:41] For example, if I go to the end of this

[54:43] first clip, you will see that we will

[54:45] move to the next clip in the same abrupt

[54:48] manner.

[54:59] >> So, here we are on the second clip. And

[55:01] I would like that between each clip

[55:04] there is a little effect, a little

[55:06] transition that makes the change from

[55:09] one clip to another less abrupt. So if I

[55:12] go back to my clips, I would like to be

[55:14] a little transition between each video.

[55:17] Something that makes the transition from

[55:19] one clip to another more pleasant to

[55:21] watch. And that's what we are going to

[55:23] do in this video. For this, we will use

[55:25] a video effect, another MP4 file that

[55:29] will serve as a transition. It is a

[55:31] video that lasts about a second, maybe

[55:34] even less. And it has a visual snow

[55:37] effect like on TV. So, I'm going to open

[55:40] it and you will see it's a simple video

[55:42] of not even a second with the visual

[55:45] snow, which is the name given to this

[55:47] small color of the dots, these black and

[55:50] white dots. And I would like to apply

[55:52] this transition between each clip. It's

[55:54] a transition often seen in compilations

[55:57] and it makes the transitions more

[56:00] pleasant to watch. Therefore, our goal

[56:02] in this video will be to integrate this

[56:05] transition between each clip. So, let's

[56:07] go back to Visual Studio Code, back to

[56:10] the same code we wrote in the previous

[56:12] video where we added the intro and the

[56:15] outro. In the same way, we will be able

[56:18] to add this transition effect. So, let's

[56:21] add a variable containing the

[56:22] transition. So I type transition path

[56:26] like this. And like the previous

[56:28] variables I will copy paste and instead

[56:31] of putting outro I type transition to

[56:34] get our transition file located in our

[56:36] resources folder. We will then apply

[56:39] this transition between each clip. For

[56:41] this we need to modify this loop where

[56:43] we take each video each clip from the

[56:46] clip folder convert it with the video

[56:49] file clip function and add each clip to

[56:52] a list to group them all. So what we're

[56:54] going to do is once we add a first clip

[56:57] right after we will add the transition.

[57:00] So there will be a transition between

[57:02] each clip. Here let's type a comment add

[57:05] a video transition clip to the list and

[57:08] then I'm adding it to the new list. So

[57:11] this new list will contain all clips. So

[57:14] I type all clips.append

[57:17] and then I call my transition. So I use

[57:19] the video file clip function. Since the

[57:22] transition is currently an MP4 video

[57:25] format that needs to be converted to a

[57:28] format Movie Pi can modify. So I'm using

[57:30] video file clip. I define the variable

[57:33] name to access the MP4 file. And then

[57:36] like all the other video clips, I

[57:39] modified the resolution to 1,920

[57:43] by 1,080.

[57:45] So first we specified the height and

[57:47] then the width. So with this

[57:49] modification we will have a transition

[57:52] appearing between each clip. You will

[57:54] see it when we will execute the code.

[57:56] Before that remember to change the name

[57:58] of the final video. If you want I will

[58:01] name it video with the transition. But

[58:04] even if you don't change the name, it

[58:06] won't be a big deal. It will just

[58:08] overwrite the old video. So let's

[58:11] execute this code to see the result.

[58:13] Let's click on run Python file and wait

[58:16] for the code to execute again. If you

[58:19] wish, you can remove a few clips from

[58:21] the clips folder like the last four or

[58:24] five to speed up the execution process.

[58:27] You can reintegrate them at the end of

[58:29] the course to have all the clips. For

[58:32] now, since we are still in the testing

[58:34] and development phase, you don't have to

[58:36] include all clips, just a few so we can

[58:39] see the different transitions between

[58:41] each clip. So, let's wait for the code

[58:43] to execute and we will see the results

[58:45] at the end. So, now the execution is

[58:48] complete and we can see that the video

[58:50] has been created. Let's go watch it

[58:52] right away. So, I go to my folder then

[58:55] to my output folder and I click on the

[58:58] newly created video. Let's fast forward

[59:01] a bit to any clip and wait for it to end

[59:04] and then you will see the transition we

[59:06] added.

[59:13] >> Perfect. So you saw the transition

[59:15] between the clips. We can take another

[59:18] example. Let's go further into the

[59:20] video.

[59:34] So, as you can see, there's a transition

[59:36] between each clip, making it much more

[59:38] pleasant to watch. However, there is one

[59:41] little thing missing. Currently, there

[59:43] is no transition between the intro and

[59:46] the first clip. I will show you. If we

[59:49] go back to the beginning and launch the

[59:51] video, you will see there is no

[59:53] transition between the intro and the

[59:55] first clip.

[1:00:06] There is however a transition for the

[1:00:08] last clip and the outro which makes

[1:00:11] sense because in the code we always add

[1:00:13] the transition after each clip. So it's

[1:00:16] normal that after the last clip there is

[1:00:18] a transition added resulting in a

[1:00:21] transition for the outro.

[1:00:28] Thus, we are missing only the transition

[1:00:30] between the intro and the first clip.

[1:00:33] This is a small modification that we

[1:00:35] will make right away. So, let's go back

[1:00:37] to our code and make some changes to add

[1:00:40] this transition right after the intro.

[1:00:43] So, we're going to modify this line of

[1:00:44] code, adding a new element with the

[1:00:47] video file clip function. This is why I

[1:00:50] used the plural here. Even though we

[1:00:52] currently have only one element, now we

[1:00:55] will have two. So to make the code

[1:00:58] easier to read, let's add a line break

[1:01:01] here, separating the elements we we will

[1:01:04] add. Here I type a comma and call the

[1:01:07] video file clip function again, placing

[1:01:09] the transition immediately after the

[1:01:11] intro. Then I set the target resolution

[1:01:15] as usual to keep the full HD format.

[1:01:18] Although the video in our resources is

[1:01:20] already in this format, this code will

[1:01:23] automatically resize any future

[1:01:25] transitions that might not be in this

[1:01:28] format. So we have now added this

[1:01:30] transition. For consistency, we can do

[1:01:33] the same with the outro, but we won't

[1:01:35] add a transition here because there is

[1:01:38] already one after the last clip as you

[1:01:40] saw. However, we can format the code to

[1:01:42] make it easier to read. Save the code.

[1:01:45] And uh now we have to concatenate the

[1:01:48] elements of this list. Currently we have

[1:01:50] a list containing two videos the intro

[1:01:53] and the transition. Now we need to group

[1:01:56] them. So copy and paste this line of

[1:01:58] code to concatenate the intro elements.

[1:02:00] Here instead of clips I use the intro

[1:02:03] part and instead of all clips I use

[1:02:06] intro clips. This concatenates the intro

[1:02:09] with the transition. We can do the same

[1:02:11] with the outro making development

[1:02:14] easier.

[1:02:18] change the comments accordingly to

[1:02:20] concatenate the intro clips and

[1:02:22] concatenate the outro clips. Now let's

[1:02:25] go down in the code and make a final

[1:02:27] modification. So in the last concatenate

[1:02:30] function, since we are now working with

[1:02:32] lists containing multiple elements,

[1:02:35] let's remove the square brackets,

[1:02:37] replace the plus signs with the commas,

[1:02:40] and place the brackets just after the

[1:02:43] parenthesis. We have to make this

[1:02:45] modification now that we are working

[1:02:47] with lists that have multiple elements

[1:02:50] which will avoid us execution errors. So

[1:02:52] we have now made the necessary

[1:02:54] modifications to have the transition

[1:02:56] after the intro and the all the other

[1:02:59] transitions that follow. So save the

[1:03:01] code again and let's modify the comment

[1:03:04] here. So here we typed intro and

[1:03:06] transition clips. You can also add outro

[1:03:10] here. And finally, execute the code by

[1:03:13] clicking on the run pattern file button.

[1:03:15] Before that, uh just clear the console

[1:03:17] by typing clear to clean it up. Click on

[1:03:20] run Python file and the code will

[1:03:23] execute.

[1:03:26] Oh, we can see that we have a small

[1:03:28] error to correct here. Instead of

[1:03:31] putting intro clips and outro clips, we

[1:03:34] need to put intro part and outro part.

[1:03:37] So we need to properly specify these

[1:03:39] variables since they contain the

[1:03:42] concatenation of the intro with the

[1:03:44] transition. Finally, let's execute the

[1:03:46] code. Beforehand, we can type clear to

[1:03:49] clean the console and then click on run

[1:03:51] Python file.

[1:03:54] You will see first the audio processing,

[1:03:57] then the video processing. So the video

[1:03:59] is generated with the same name as the

[1:04:01] previous one as I chose to overwrite the

[1:04:04] old one without the intro transition. So

[1:04:08] now that the execution is complete,

[1:04:10] let's go watch the video. So I return to

[1:04:12] my output folder and launch the video

[1:04:15] with transition. So first we see the

[1:04:18] intro and then we should see the

[1:04:20] transition after the intro.

[1:04:31] And there it is, the transition right

[1:04:34] after the intro. And similarly, there's

[1:04:36] a transition between each clip, making

[1:04:39] the video much more pleasant to watch.

[1:04:48] >> We can verify this at the end as well,

[1:04:50] just before the outro.

[1:05:13] Perfect. So, in this video, we saw how

[1:05:16] to add a transition between each clip.

[1:05:19] Something commonly seen in such videos.

[1:05:21] You saw it. It's not complicated to

[1:05:24] implement and can be done quite easily.

[1:05:27] In the next videos, we will continue to

[1:05:30] explore other ways to edit our videos

[1:05:32] with Movie Pie. So, that was all for

[1:05:35] this video and I'll see you in the next

[1:05:37] one. In this video, we will continue to

[1:05:40] make transformations on the video

[1:05:41] generated by our program by adding a

[1:05:44] text this time. So, if we go back to the

[1:05:46] folder containing our clips, by looking

[1:05:49] at the name of each clip, we can see

[1:05:51] that at the end of the name of each

[1:05:53] clip, there is the author of the player

[1:05:56] who recorded the video. For example, for

[1:05:59] the video number four, the author is

[1:06:01] called the gravity. So, it's the name of

[1:06:04] the player who made this clip. And it

[1:06:06] would be nice to mention the author's

[1:06:08] name in the video. We could for example

[1:06:11] add a small text at the top left with

[1:06:14] the author's name. So a small white text

[1:06:17] for instance that we would put in a

[1:06:19] thoroughly small font so that it doesn't

[1:06:22] cover the entire video. And in this way

[1:06:25] we can mention the author and that's

[1:06:27] what we're going to do with our program.

[1:06:30] We will modify it to add the author's

[1:06:32] name at the top left each time. So this

[1:06:35] is something that we can do. But to add

[1:06:37] the text with the movie pie, we need

[1:06:39] first to install another element,

[1:06:42] another dependency, specifically the

[1:06:45] image magic software. So here I am on

[1:06:47] the official movie pie documentation and

[1:06:50] it is clearly indicated here that image

[1:06:52] magic is a dependency that can be useful

[1:06:55] if you want to write text on our videos.

[1:06:58] So it is a small dependency that we need

[1:07:01] to install in addition to be able to

[1:07:03] write text on our video with the Python

[1:07:06] and Movie Pie. And by the way, once the

[1:07:09] software is installed, if you are on

[1:07:11] Windows, we will have to make a few

[1:07:13] small configurations so that movie pie

[1:07:15] can detect image magic. But if you are

[1:07:17] on Mac or Linux, in theory, image magic

[1:07:21] should be detected automatically. So in

[1:07:23] this video I will show you how to

[1:07:25] install image magic and ensure it is

[1:07:28] detected by Windows if you are working

[1:07:30] on a Windows machine of course. So to

[1:07:32] install Image Magic it's very simple.

[1:07:35] Let's open a new window here and let's

[1:07:37] type image magic like this. Then you can

[1:07:41] press enter. You can then click on the

[1:07:43] first link. Perfect. So we land on this

[1:07:46] page. So it is a free open-source

[1:07:48] software. So of course there is nothing

[1:07:51] to pay. Let's go to the download menu to

[1:07:54] download the software. And here we just

[1:07:56] have to choose the version of image

[1:07:58] magic according to our operating system.

[1:08:01] So if you are on Linux, you can download

[1:08:03] the image magic for this operating

[1:08:05] system. If you are using a Mac, you can

[1:08:08] also uh install Image Magic for this

[1:08:11] operating system. And finally, if you

[1:08:13] are on Windows, you can download Image

[1:08:15] Magic directly by clicking on the little

[1:08:17] link here. Let's click on it. And we can

[1:08:20] see that the software is downloading.

[1:08:23] Okay. So the software has been

[1:08:24] successfully downloaded to my computer.

[1:08:27] And now we just have to install it. So I

[1:08:30] went to my downloads and for the

[1:08:32] installation there's nothing simpler.

[1:08:34] You can click on the.exe file. And there

[1:08:37] will be only a few buttons to press to

[1:08:39] download image magic. It's very easy to

[1:08:41] install. So here I press yes. You can

[1:08:45] click on accept agreements. You can read

[1:08:47] the license if you wish. Click on next.

[1:08:50] You can leave the default settings

[1:08:53] except maybe for create a desktop icon

[1:08:56] to avoid creating a shortcut to access

[1:08:58] image magic directly from your desktop.

[1:09:02] Then click next. And now you just have

[1:09:04] to click install. So for my port it is

[1:09:07] already done. So I don't need to click

[1:09:10] on install. I'm just going to close this

[1:09:12] file. But for you you can click on

[1:09:14] install to install the software if you

[1:09:17] haven't already done. So once that is

[1:09:19] done, we will need to modify a Python

[1:09:21] file that is on our computer and that

[1:09:24] was installed automatically when we

[1:09:26] installed the Movie Pi library at the

[1:09:28] very beginning of the course. So you

[1:09:31] need to go to the folder where Python is

[1:09:33] installed on your computer. A little

[1:09:35] tip, if you are using Visual Studio

[1:09:38] Code, in the terminal, you should have

[1:09:40] the path to your Python.exe and you need

[1:09:43] to go to that path. So here we can see

[1:09:46] that my Python.exe Excel file is in my

[1:09:48] app data folder. To get there in my

[1:09:51] research bar here, I type percent ape

[1:09:54] data percent. I then click on the folder

[1:09:57] that appears. So here we are

[1:10:00] automatically taken to the roaming

[1:10:02] folder. Let's back up once to be in the

[1:10:04] app data folder. Next, let's go inside

[1:10:07] the local folder. Then you can click in

[1:10:10] program as indicated in the path here.

[1:10:12] So program then python then python 3.12.

[1:10:16] So I'm just following the path indicated

[1:10:19] here and then we need to go to the lib

[1:10:21] folder. So this is no longer indicated

[1:10:24] here. So now you have to follow the path

[1:10:26] that I'm indicating. So next let's go to

[1:10:29] the lib folder then to site packages.

[1:10:33] And inside this folder we have almost

[1:10:35] all the libraries that we download on

[1:10:37] python. So here we just need to look for

[1:10:40] the movie pi folder. So here it is.

[1:10:44] Inside this folder we find most of the

[1:10:46] files that were downloaded when we

[1:10:48] installed the movie pi library. And here

[1:10:51] we need to modify the config default.

[1:10:54] py. You can open this file to edit it.

[1:10:57] So it opens directly in visual studio

[1:10:59] code for me. So in this file you need to

[1:11:02] change this line. There is a variable

[1:11:05] called the image magic binary with the

[1:11:07] path to access the software we just

[1:11:10] downloaded. So image magic the path is

[1:11:13] not specified by default. I had already

[1:11:16] made the modification. So me I have the

[1:11:19] correct path to access Image magic but

[1:11:22] you you will need to set the correct

[1:11:24] path to access the software. So I've

[1:11:27] installed it on my D drive. So Image

[1:11:30] magic for me is inside my D drive. You

[1:11:32] can see here the image magic folder. I

[1:11:35] click on it and inside this folder I

[1:11:38] should have the magic.xe file. You can

[1:11:41] right click on it and press copy as path

[1:11:44] to simply copy the path to image magic.

[1:11:47] Then you can paste this path inside this

[1:11:50] variable and put it in quotes like this

[1:11:57] and then it will be good. We have

[1:11:59] indicated to Movie Pi how to access the

[1:12:02] image magic software. So again, I

[1:12:05] installed the image magic on my D drive.

[1:12:07] Maybe you have it on your C drive. But

[1:12:10] don't worry, it will work the same way

[1:12:12] as long as you specify the correct path

[1:12:14] to the magic.xe file. And now that we

[1:12:17] have made this modification, we are

[1:12:19] ready to use Image Magic with Movie Pie

[1:12:22] and write text on our videos. So that

[1:12:25] was all for the installation of Image

[1:12:27] Magic. Again, if you have a trouble

[1:12:30] finding the path to the movie Pi folder,

[1:12:32] you can refer to the path indicated in

[1:12:34] your code editor. So here on Visual

[1:12:37] Studio Code, I can find the folder where

[1:12:40] my Python is installed. So just follow

[1:12:43] the path I indicated to get the site

[1:12:45] package folder, then move and inside you

[1:12:49] will have the config defaults file to

[1:12:52] modify. And once you have made the

[1:12:54] modification, remember to press Ctrl S

[1:12:57] to save. Then you can close this window.

[1:13:00] So that was all for this video and I'll

[1:13:02] see you in the next one.

[1:13:05] So I'm making this video in addition to

[1:13:07] the last one about the installation of

[1:13:10] image magic because some people have

[1:13:12] encountered the difficulties with the

[1:13:14] creating text on Movie Pie due to movie

[1:13:17] pie not being able to find the path

[1:13:19] through the magic.xe file. even though

[1:13:22] the correct path is specified in the

[1:13:24] config default file we configured in the

[1:13:28] last video. So some people despite

[1:13:31] having specified the correct path to

[1:13:33] magic.exe find that when they implement

[1:13:36] text on movie pie the text does not

[1:13:39] appear in the video. The reason for this

[1:13:41] error is that some versions of Python do

[1:13:44] not properly support what were called

[1:13:47] air strings. So the air strings are the

[1:13:50] strings where there is an error in the

[1:13:52] front which allows us to define path

[1:13:55] using just a backslash as used in

[1:13:57] Windows. It's much simpler for copying

[1:14:00] and pasting path from a directory.

[1:14:02] However, in some versions of Python,

[1:14:05] this does not work correctly. So to

[1:14:08] resolve this problem, we will simply

[1:14:10] rewrite the path in another way. So we

[1:14:13] are just going to write the path

[1:14:15] differently. As a reminder, for me, the

[1:14:17] magic.xe file is in my D drive. For you,

[1:14:21] it may be another directory. And to

[1:14:23] solve the issue, essentially you just

[1:14:26] need to remove the error and rewrite the

[1:14:28] path adding an extra backslash each time

[1:14:32] we change the directory. So here I have

[1:14:34] added a backslash and here I will add

[1:14:37] another as well. So you need to add two

[1:14:40] backslashes every time you change

[1:14:42] directory. So this is the classic way to

[1:14:45] define a path to a directory or a file

[1:14:48] in Python. With this writing style, it

[1:14:50] will work every time regardless of your

[1:14:53] Python version. And once you have made

[1:14:56] the modifications, namely removing the

[1:14:58] error and adding the extra backslashes,

[1:15:01] make sure to save your file, you can

[1:15:03] press Ctrl S. And once this is done, you

[1:15:06] can move on to the next video where we

[1:15:09] will be able to implement text on Movie

[1:15:11] Pie without any issues. So that was all

[1:15:14] for this video and I'll see you in the

[1:15:16] next one. Now that we have seen how to

[1:15:19] install image magic on our computer, we

[1:15:21] can start writing text on our videos

[1:15:24] with the Movie Pie. So the text we want

[1:15:26] to write is the author's name on each

[1:15:29] clip. So for example when the first clip

[1:15:32] will play here we can see that the

[1:15:34] author's name is Mr. Azy. So I would

[1:15:37] like the author's name to be in the top

[1:15:39] left corner. So the name Mr. Azy will be

[1:15:43] written throughout the clip in the top

[1:15:45] left corner. And that's what we're going

[1:15:47] to do in this video. And of course it

[1:15:50] needs to be an automated solution that

[1:15:52] does it for each clip in the folder.

[1:15:54] Very well. So before that we also need

[1:15:57] to tell to movie pie which font to use

[1:16:00] for writing the text. Actually by

[1:16:02] default movie pie will choose a basic

[1:16:05] font but it's not a font would have very

[1:16:08] good quality. So the best practice I

[1:16:10] recommend is to choose your own font

[1:16:13] from the internet and incorporate it

[1:16:15] into the script. So I chose a font

[1:16:18] called Robboto. It's a royalty-free font

[1:16:21] so you can use it without any issues.

[1:16:24] And so this is the font we will use to

[1:16:26] indicate the author's names. Very well.

[1:16:29] And so like with all the other

[1:16:30] resources, we are going to import it. So

[1:16:34] here I skip a line and type font path

[1:16:36] like this. Then I type equals. And here

[1:16:40] I can copy past the line above. And I

[1:16:42] just have to replace transition.mpp4

[1:16:45] with the font. TTF. Be sure to write it

[1:16:49] correctly. Perfect. So we've completed

[1:16:51] the first step. We have imported the

[1:16:53] font and then all that's left is to

[1:16:57] display the author's name on each clip.

[1:16:59] So since this is a modification we will

[1:17:01] make to each clip, we will write our

[1:17:04] code in the loop because it is in the

[1:17:06] loop that we process each clip. And

[1:17:08] first we will need to make a few small

[1:17:11] textual modifications. We can see that

[1:17:13] in the file names besides having the

[1:17:15] author's name, we also have some numbers

[1:17:18] with a dash here. And these are the

[1:17:21] things we do not want to display. So

[1:17:23] first we are going to remove the

[1:17:25] numbers, the dots and the spaces to keep

[1:17:29] only the author's name. For that we need

[1:17:32] to import a library which is the OS

[1:17:35] library. So it's a Python library that

[1:17:37] allows us to interact with our operating

[1:17:39] system. OS is for operating system by

[1:17:43] the way. So with this library we can

[1:17:45] create files, folders, delete them etc.

[1:17:49] So therefore we will use this library to

[1:17:51] retrieve the file names and remove the

[1:17:54] text we do not want to keep. Very well.

[1:17:57] So here let's type a command extract the

[1:18:00] name from the clip path and I will

[1:18:02] create a new variable that I will call

[1:18:04] name which will contain the name of each

[1:18:07] author and then let's type the function

[1:18:10] os.path.base

[1:18:12] name and I put clip path in parenthesis.

[1:18:16] So what does this piece of code do? This

[1:18:18] piece of code is simply retrieves the

[1:18:20] full name of each file. So right now

[1:18:23] this code will retrieve 01-

[1:18:26] MR. Next, we will need to replace the

[1:18:29] text we do not want. Starting with

[1:18:32] thempp4. We don't need this part of the

[1:18:35] text. So let's type the method.replace

[1:18:38] open parenthesis. Then in quotes type

[1:18:42] and then we type again inside quotes.

[1:18:45] Basically nothing. Here we are just

[1:18:47] replacing thempp4 with nothing because

[1:18:51] we don't want to put anything in place

[1:18:53] of thempp4. Perfect. So at this stage we

[1:18:56] have removed thempp4 and now we just

[1:18:59] have to remove the 01 dash and space. So

[1:19:03] to remove these characters we will use

[1:19:05] another function called the l strip

[1:19:08] which is a function that also allows us

[1:19:09] to remove characters but it works a

[1:19:12] little differently. we will basically

[1:19:14] indicate all the characters to be

[1:19:16] removed in each name. So here we want to

[1:19:19] remove the digits 0 1 2 3 4 5 6 7 8 and

[1:19:24] 9. And we will also indicate that we

[1:19:26] want to remove the spaces and dashes.

[1:19:29] And so that's what I'm doing here. I'm

[1:19:30] simply indicating the characters that I

[1:19:32] want to remove. So 0 1 2 3 4 5 6 7 8 9.

[1:19:37] I'm also indicating the dash and then

[1:19:39] the space. And that way all these

[1:19:42] characters will be removed. So it's

[1:19:44] quite simple. We first remove thempp4

[1:19:47] and then we remove the uh the numbers,

[1:19:50] the spaces and the dashes. Very well. So

[1:19:53] now that we have the author's name

[1:19:55] cleaned, we will incorporate it into the

[1:19:57] video. For that, right after the video

[1:20:00] clip variable, we will create a new

[1:20:02] variable. So here, let's type a comment

[1:20:04] create a text clip object with the clip

[1:20:07] name. So in movie pie text have a

[1:20:10] predefined object just like we have an

[1:20:12] object for videos and an object for

[1:20:14] audio files. So we had the function

[1:20:16] audio file clip for audio files and the

[1:20:19] function video file clip for video

[1:20:21] files. And so just like them we also

[1:20:24] have a function for text and that is

[1:20:26] what we're going to import. So let's

[1:20:28] scroll to the top and we will import the

[1:20:30] function text clip. Perfect. And with

[1:20:33] this function we are now able to create

[1:20:35] a text clip object. So first here let's

[1:20:38] create a variable called the text

[1:20:40] underscoreclipip and then I just call

[1:20:42] the text clip function that I have just

[1:20:44] imported. So first of all I would like

[1:20:47] the name to be displayed always in

[1:20:49] uppercase. For that first I'm typing the

[1:20:53] variable name which contains the name of

[1:20:56] the author and then I type dotuper to

[1:20:59] have the text in uppercase. So we can

[1:21:01] type it like this with an opening and

[1:21:04] closing parenthesis. And by doing this

[1:21:07] all the text will be in uppercase. Next

[1:21:10] I need to define the font size. So this

[1:21:12] is done with the font size function like

[1:21:15] this. And then we need to define a

[1:21:17] number that corresponds to the size of

[1:21:19] the text. The higher the number, the

[1:21:21] larger the text will be. Here I put 100

[1:21:24] because it is a sufficient value to have

[1:21:26] text. In the top left corner that is a

[1:21:29] small enough. Next we can define the

[1:21:31] color. So, I recommend using white

[1:21:33] because if you use a somewhat

[1:21:35] extravagant color with the colorful

[1:21:38] background of video games, it might not

[1:21:40] be clearly visible. It depends, of

[1:21:42] course, on the content you want to

[1:21:44] automate, but generally it is best to

[1:21:46] use white, especially for video games.

[1:21:49] Next, we need to define the font we want

[1:21:52] to use. So, for the font, we've already

[1:21:54] imported it. So, we just need here to

[1:21:57] redefine the path. So, we type font

[1:21:59] equals to font path. And that way we

[1:22:02] will be able to use the font we

[1:22:04] imported. Then let's complete our code

[1:22:07] by defining the text position in the

[1:22:09] video. So as I mentioned earlier, I want

[1:22:11] to put the text in the top left of the

[1:22:14] video. For that, let's type in the

[1:22:16] method set pause like this. Let's open

[1:22:21] two parenthesis. And here we need to

[1:22:23] provide two pieces of information. We

[1:22:26] need to set the horizontal position and

[1:22:28] the vertical position. Let's start with

[1:22:30] the vertical position. So here I can

[1:22:33] just type left and then we can type top.

[1:22:36] This way I will have the text in the top

[1:22:39] left corner. If I wanted to put it in

[1:22:41] the top right here I will replace left

[1:22:43] with the right. Perfect. So that was for

[1:22:46] the position of the text. And finally

[1:22:49] the last parameter we need to modify is

[1:22:52] the duration of the text. So this text

[1:22:55] needs to appear from the beginning to

[1:22:57] the end of the clip. For that we can use

[1:23:00] set duration just like we did for the

[1:23:02] music. And then we can call our video

[1:23:04] clip variable. And we just have to type

[1:23:07] dot duration to indicate the duration of

[1:23:09] the clip. Perfect. So one last piece of

[1:23:13] code we need to add is the merging of

[1:23:15] the video with the text because here we

[1:23:18] have one video for the clip and one

[1:23:20] video for the text and we need to merge

[1:23:22] them so that they overlap exactly as we

[1:23:25] did for the video sound where we over

[1:23:28] overlapped the music with the sound of

[1:23:30] the clips. So if you remember we have

[1:23:32] used a function called the composite

[1:23:34] audio clip and in the same way we will

[1:23:37] use the function composite video clip to

[1:23:39] merge the two videos. So here let's

[1:23:42] import the function composite video clip

[1:23:44] and then we will be able to call the

[1:23:46] function and use it. So let's create the

[1:23:49] variable that will use this function.

[1:23:52] But first I will add a comment. Let's

[1:23:54] type combine the video clip and the text

[1:23:57] clip. And then I will create a new

[1:23:59] variable which I will call video with

[1:24:01] text. And here I will be able to call

[1:24:04] the function I just imported. So

[1:24:06] composite video clip. Let's open

[1:24:08] parenthesis and then brackets. And here

[1:24:11] I just need to specify video clip and

[1:24:14] text clip. So first we have the variable

[1:24:17] that contains the video the clip and

[1:24:19] then the variable that contains the text

[1:24:22] which is the name of the author of the

[1:24:24] clip. Also here we need to make a little

[1:24:27] modification. Instead of putting video

[1:24:30] clip here, we will just put a video with

[1:24:32] text to correctly add to the list the

[1:24:34] video that contains the author's name.

[1:24:36] And then it's done. We have completed

[1:24:38] the modification we wanted to make to

[1:24:40] the final video. If we scroll down to

[1:24:42] the bottom of the code here, we can

[1:24:44] replace video with transition with the

[1:24:47] video with the music. Perfect. We can

[1:24:49] then save the code. And now we can run

[1:24:52] it. So to run the code, we can do as

[1:24:55] usual. You can click on the button run

[1:24:57] Python file to execute it. And there you

[1:24:59] go. So let's wait for the code to

[1:25:01] execute. We can see that the music has

[1:25:03] been edited. And now it's time for the

[1:25:05] video editing. So let's wait for the

[1:25:08] editing to complete.

[1:25:10] Perfect. So we can see that the code has

[1:25:13] been executed. And by the way, I just

[1:25:15] noticed that it's not a video with music

[1:25:17] here. It's not a video with music we

[1:25:19] should put, but rather video with text.

[1:25:22] Sorry for my mistake. So you can just

[1:25:24] type a video with text here. So now we

[1:25:26] can go to our output folder and start

[1:25:29] the video we just generated. And in this

[1:25:32] video we should now have the author's

[1:25:34] name in the top left corner for each

[1:25:36] clip. Let's check that.

[1:25:43] Perfect. So here we have the author's

[1:25:45] name for the first clip. Very good.

[1:25:48] Let's speed up a bit. Let's see if the

[1:25:50] author's name is there for the second

[1:25:52] and third clips. So for the second clip,

[1:25:55] we also have the name here. It is the

[1:25:58] sixth clip. So it looks the same.

[1:26:02] This is the third clip. We can see that

[1:26:04] each time you have the author's name

[1:26:07] appearing in the top left corner. Very

[1:26:09] good. However, there's a small

[1:26:11] modification we could make regarding the

[1:26:14] positioning. We can see that here I'm

[1:26:16] enlarging the video a bit. the text is

[1:26:19] very tight to the left. Let's put the

[1:26:21] video in full screen. So as I said here

[1:26:24] we can see that the text is quite tight

[1:26:26] to the left whereas on the top part

[1:26:29] vertically we have a bit more space. So

[1:26:32] this is because of the left parameter

[1:26:33] that we defined in our code that the

[1:26:36] text has this position. So what we can

[1:26:39] do to make the text a bit more to the

[1:26:41] right. There is a solution to this.

[1:26:43] Instead of putting left, we can simply

[1:26:45] set the number of pixels to insert the

[1:26:48] text from. So here, if we put one pixel,

[1:26:51] for example, I will put one. The text

[1:26:53] will be very, very tight to the left

[1:26:55] since it will start from the first

[1:26:57] pixel. And so the higher the number, the

[1:27:00] more the text will move to the right. So

[1:27:02] I did some tests on my side and the

[1:27:04] ideal number is 20. So here I recommend

[1:27:07] putting 20. This way the text will be a

[1:27:10] little bit shifted to the right. As I

[1:27:12] said before, the higher the number is,

[1:27:14] the more the text will move to the

[1:27:16] right. 20 is a good number of pixels so

[1:27:19] that the text fits well in the top left

[1:27:21] corner with as much space above the text

[1:27:24] as to the left of the text. Very good.

[1:27:27] So once that is done, we will be able to

[1:27:29] run our code one last time to get the

[1:27:31] final video with all the improvements we

[1:27:34] wanted. First here, let's type clear to

[1:27:36] clean a little bit the console and then

[1:27:39] let's run this code. Perfect. So the

[1:27:41] rendering is starting and we will meet

[1:27:43] at the end of the code execution to see

[1:27:45] the results. So we can see that the

[1:27:48] script has been executed. Let's open the

[1:27:50] file a video with text.mpp4. So I'm

[1:27:53] opening it

[1:27:58] and there we go. We can see now that the

[1:28:00] text appearing in the top left corner

[1:28:02] has been shifted a little bit to the

[1:28:04] right. I find it a little bit more

[1:28:06] aesthetically pleasing like that. where

[1:28:09] before the text was completely tight to

[1:28:11] the left, it's better like this. Oh, and

[1:28:14] by the way, if you ever want to change

[1:28:16] the font or the text size. So for the

[1:28:19] text size, you can just modify the font

[1:28:21] size parameter here. And for the font,

[1:28:24] you can change it yourself by replacing

[1:28:26] the font. TTF file. So you can replace

[1:28:30] this file I left in the project

[1:28:32] resources with another font you want to

[1:28:34] use. Perfect. So now we have the

[1:28:37] author's name displayed each time and

[1:28:39] that's great. It's something often seen

[1:28:41] in this type of compilation on the

[1:28:43] internet even in those shown on

[1:28:45] television where the author's name is

[1:28:47] usually credited in the corner of the

[1:28:49] screen. Perfect. So we can close this

[1:28:51] video. And that was all for adding text

[1:28:54] on Movie Pie. You have seen it's not

[1:28:56] complicated to do. We do this with the

[1:28:58] text clip function to indicate the text

[1:29:01] we want to display with the font. also

[1:29:03] the font size, the position, the

[1:29:05] duration, etc. And then we just merge

[1:29:08] the text with the video using the

[1:29:10] composite video clip function that we

[1:29:13] just imported. Perfect. So that was all

[1:29:15] for this video. Thank you everyone.

[1:29:19] So we have reached the end of this

[1:29:22] training on Movie Pie. We have covered a

[1:29:24] lot of interesting things together to

[1:29:26] automate the editing of these clips.

[1:29:29] First, we saw how to assemble multiple

[1:29:32] clips to combine them into a single

[1:29:34] video. We also learned how to resize

[1:29:37] them to the 1,920

[1:29:40] by 1,080 format with the 60fps

[1:29:44] so that the video format meets the

[1:29:46] standards used by video platforms. Next,

[1:29:49] we saw how to add a music, specifically

[1:29:52] background music, which we set to play

[1:29:54] until the end of the video to perfectly

[1:29:57] match its duration. We also covered how

[1:30:00] to add an introduction video and an

[1:30:03] outro video, as this is generally the

[1:30:05] convention for such videos. This makes

[1:30:08] the video much more professional. And of

[1:30:11] course, if you already have your own

[1:30:12] intro or your own outro, you can just

[1:30:15] use them by replacing the files that I

[1:30:18] have provided you. And you can do the

[1:30:20] same with the music. Then we looked at

[1:30:22] how to add a transition between each

[1:30:24] clip to ensure that the transitions

[1:30:27] between videos between the clips are

[1:30:29] professionally done and so that the

[1:30:32] transition are not too abrupt to watch.

[1:30:34] And finally, we saw how to add a text to

[1:30:37] the videos, especially to credit the

[1:30:40] different authors. For this, we first

[1:30:43] installed the image magic, which is an

[1:30:45] essential prerequisite for adding text

[1:30:47] to a video with Movie Pie. We then saw

[1:30:50] how to configure it and then how to add

[1:30:52] the text and modify parameters such as

[1:30:55] the color, text size, position, etc. In

[1:30:58] the end, we have been able to obtain

[1:31:00] this video. We can quickly rewatch the

[1:31:03] beginning. So here we have the intro.

[1:31:06] [Music]

[1:31:13] We have then here the first clip, the

[1:31:16] music behind the text appearing at the

[1:31:19] top left. The transition

[1:31:33] >> down. One enemy remaining.

[1:31:47] >> Perfect. So the editing is really

[1:31:50] identical to the compilations of this

[1:31:52] kind that we can find on the internet or

[1:31:55] on the television. We have seen during

[1:31:57] this training that it is quite easy to

[1:31:59] automate this kind of editing and that's

[1:32:01] what we did. And of course this code can

[1:32:04] be reused regardless of the context of

[1:32:07] the clips. During this course we have

[1:32:09] used the clips from the video game

[1:32:10] Valerant as an example. But you can also

[1:32:13] use clips from sports, uh, some funny

[1:32:16] animal clips, etc. The code will work

[1:32:19] the same way. You just have to change

[1:32:21] the music if you want. Also, the intro

[1:32:23] and the outro. For the transition, you

[1:32:26] can maybe keep it. It is a quite a

[1:32:28] generic transition that can be used in

[1:32:30] any context. At the end, you will get a

[1:32:33] video in the full HD format with 60 fps.

[1:32:36] So once again, it is a video that can be

[1:32:38] published on video platforms with the

[1:32:40] recommended quality standards. So if you

[1:32:43] haven't done so yet, the final code can

[1:32:46] be downloaded. And also if you liked the

[1:32:48] course, please leave a little rating for

[1:32:51] the course so that I can read your

[1:32:53] feedback. And if you have any questions,

[1:32:56] don't hesitate to contact me. And I'll

[1:32:58] see you next time for a new course.

[1:33:01] Goodbye everyone.

⚡ Saved you time reading this? Transcribe any YouTube video for free — no signup needed.