import subprocess import os ffmpeg_path = "ffmpeg" cmd = f"{ffmpeg_path} -y -loglevel error -f concat -safe 0 -i %s -c copy test.mp4" tmp_merge_file = "merge.tmp" with open(tmp_merge_file, mode="w", encoding="utf8") as f: f.write("file './72439149X00E26C681B09_20240311000015_20240311000030.mp4'\n") # f.write("file ./72439149X00E26C681B09_20240311001015_20240311001030.mp4") proc = subprocess.Popen( cmd % tmp_merge_file, stdin=subprocess.PIPE, stdout=None, shell=True ) proc.communicate() os.remove(tmp_merge_file)