merge all mp4 video files into one file python

Solutions on MaxInterview for merge all mp4 video files into one file python by the best coders in the world

showing results for - "merge all mp4 video files into one file python"
Fynn
09 Jun 2020
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)