python

Join two videos using moviepy in Python

from moviepy.editor import VideoFileClip, concatenate_videoclips

video_1 = VideoFileClip("path/to/first/video.mp4")
video_2 = VideoFileClip("path/to/second/video.mp4")

final_video= concatenate_videoclips([video_1, video_2], method="compose")
final_video.write_videofile("path/to/final/video.mp4")

You can join or concatenate or join two videos in Python using moviepy package. You can install moviepy using pip by running below command

pip install moviepy

After installing moviepy you can import VideoFileClip and concatenate_videoclips from moviepy.editor which we will use to merge our videos. If you are merging videos that have different resolutions, don't forget to use method="compose" in concatenate_videoclips method.

Was this helpful?