Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Sitemap
Menu

Python 3 MoviePy Script to Merge Multiple Video Files in Command Line

Posted on February 12, 2023

Welcome folks today in this blog post we will be using the moviepy library to merge multiple video files in command line. All the full source code of the application is shown below.

 

 

Get Started

 

 

First of all we need to install the below moviepylibrary using the pip command as shown below

 

 

pip install moviepy

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Import everything needed to edit video clips
from moviepy.editor import *
 
# loading video dsa gfg intro video
clip = VideoFileClip("video.mp4")
 
# getting subclip as video is large
clip1 = clip.subclip(0, 5)
 
# getting subclip as video is large
clip2 = clip.subclip(15, 20)
 
# concatenating both the clips
final = concatenate_videoclips([clip1, clip2])
#writing the video into a file / saving the combined video
final.write_videofile("merge.mp4")
 
# showing final clip
final.ipython_display(width = 480)

 

 

As you can see we are importing the moviepy library at the very top and then we are only taking the first 5 seconds of the input video using the subclip()method and then we are using the concatenate_videoclips() method to merge multiple video files. And then we are writing the output video file using the write_videofile() method.

 

 

 

Recent Posts

  • Build a Fixed Deposit Interest Calculator Using Amount and Time in Browser Using HTML5 & Javascript
  • How to Download Files From URL in Node.js Using Node-Downloader-Helper Library
  • Angular 10 Image Carousel and Video Gallery Lightbox Modal Slider Using ng-image-slider Library
  • React Unsplash Api Photo Search App
  • React Form Validation Using Formik and Yup
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • javascript
  • Koajs
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme