from moviepy.editor import *
def hebing(): k = os.listdir('./video') sortKey = lambda x: int(re.search(r'(\d+).ts', x).group(1)) k.sort(key=sortKey) L = [] for file in k: hebing = VideoFileClip('./video/%s' % file) L.append(hebing) final_clip = concatenate_videoclips(L) final_clip.to_videofile('a.mp4', fps=24, remove_temp=True)