Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
No results
  • About AskPython
  • Blog
  • Contact Me
  • Free Online Developer Tools Hub
  • Home
  • Meet the Team
  • Privacy Policy
  • Python
  • Python Course for Beginners Online FREE
  • Python Tutorial – Mega Index
  • Terms and Conditions

🚀 Supercharge your YouTube channel's growth with AI.

Try YTGrowAI Free
  • Home
  • Blog
  • About AskPython
  • Python Course
  • Start Here

Python: Moviepy Module

  • Isha BansalIsha Bansal
  • May 25, 2021
  • Python Modules
Python: Moviepy Module

Hello fellow coder! Today in this tutorial we will be learning a very interesting way of editing and loading videos with the Moviepy module.

Introduction to Moviepy Module

MoviePy module is used for loading, downloading and editing videos from your system where editing includes cropping, rotating, trimming into smaller clips and other video effects.

It can also be used to edit audio in the video. It can also add watermarks on the video and other text items according to your preferences.

Pretty cool right?! So let’s learn to implement it now!

Implementing Moviepy

To implement moviepy, first we need to make sure that we have moviepy installed in our system using the pip install command.

After you have successfully installed the moviepy module, we are all set to implement the module! For the following tutorial, I would be using a video that can be found here. You can choose any video you like.

But before processing further, we need to import the moviepy module to make it ready for editing in the following way.

from moviepy.editor import *

1. Loading the Video

To load the video we make use of the VideoFileClip function and pass the path of the video file as a parameter.

I have used mp4 format, you can whichever format you prefer as moviepy module supports a variety of video formats.

We will store the output of the function inside a variable and to view the video recorded we make make use of the ipython_display function.

You can keep the parenthesis blank but I have provided a width property for better visualization.

The code and output for the whole process is displayed below. The video is perfectly playable.

from moviepy.editor import *
v1 = VideoFileClip("video.mp4")
v1.ipython_display(width = 400)
Output Loading Video Moviepy
Output Loading Video Moviepy

2. Editing the Video

Now that we know how to successfully load a video, let’s start to edit the video a little bit.

All the functions of the moviepy module are out of scope for a single tutorial, but you will learn a few tricks by the end of the tutorial.

We will be doing the following operations on the video loaded in the code above:

  1. Trimming the video to 15 seconds
  2. Rotating the video by an angle of 45 degrees
  3. Lowering the volume of the audio

Let’s learn how to do each edit one after another!

First, we have trimming for which we make use of the function subclip which takes the starting and ending time of the video in seconds.

We will be trimming the video to 15 seconds so we provide start as 0 and end as 15. The code to do the same is shown below.

v2 = v2.subclip(0, 15)

Next we have, rotating the video to a certain angle which is simply done by the rotate function which takes the angle of rotation. You can play around with this function.

We are choosing a angle of 45 degrees for which the code is shown below.

v2 = v2.rotate(45)

Last but not the least we will be setting the volume of the audio in the video which is performed by the help of volumex function which sets the maximum volume you need for the audio.

The code for the same is shown below.

v2 = v2.volumex(0.3)

Now that we know how the individual edits take place, lets combine all of them and see the output of the video.

The complete code and output is shown below.

from moviepy.editor import *
v2 = VideoFileClip("video.mp4")

v2 = v2.subclip(0, 15)
v2 = v2.rotate(45)
v2 = v2.volumex(0.3)

v2.ipython_display(width = 400)
Output Edited Video Moviepy
Output Edited Video Moviepy

Conclusion

Congratulations! You’ve just learned to load and edit a video with simple python coding. But these were just the basics, there’s a lot more to learn about MoviePy.

Stay tuned for more such tutorials! Happy coding!

Isha Bansal
Isha Bansal

Hey there stranger!
Do check out my blogs if you are a keen learner!

Hope you like them!

Articles: 185
Python: Top Machine Learning libraries
Previous Post Python: Top Machine Learning libraries
Next Post Python vs Scala Programming Language
Python vs Scala Programming Language

Related Posts

np.linalg.eig: Eigenvalues and Eigenvectors

np.linalg.eig: Eigenvalues and Eigenvectors

  • November 30, 2026
np.sin() in NumPy: Radians, Arrays, and Examples

How to Use np.sin() in NumPy

  • November 30, 2026
cv2.imread: Load Images with OpenCV

cv2.imread: Load Images with OpenCV

  • November 30, 2026

Partner Websites

  • GoLangDocs
  • LinuxForDevices
  • CodeForGeek

Popular Categories

  • Python Programming
  • Python Modules
  • OOPS in Python
  • Python Programming Examples
  • Strings in Python

Hall of Fame

  • Python Programming
  • OOPS in Python
  • Creating Python Modules
  • Args and Kwargs in Python
  • Python Dictionary (Dict) Tutorial
  • Python List – 15 Things You MUST Know
  • Python Set – Things You MUST Know
  • Python String Functions: Methods by Task

Important Links

  • Home
  • Python Course
  • Start Here
  • Blog
  • About AskPython
Latest posts
  • np.linalg.eig: Eigenvalues and Eigenvectors
  • What Does %s Mean in a Python Format String?
  • How to Use np.sin() in NumPy
  • cv2.imread: Load Images with OpenCV
  • pd.read_json: Read JSON Into a DataFrame

Copyright © 2026 - AskPython. All rights reserved.