1from moviepy.editor import *
2import os
3from natsort import natsorted
4
5L =[]
6
7for root, dirs, files in os.walk("/path/to/the/files"):
8
9 #files.sort()
10 files = natsorted(files)
11 for file in files:
12 if os.path.splitext(file)[1] == '.mp4':
13 filePath = os.path.join(root, file)
14 video = VideoFileClip(filePath)
15 L.append(video)
16
17final_clip = concatenate_videoclips(L)
18final_clip.to_videofile("output.mp4", fps=24, remove_temp=False)