def concatenate(): stringa = "ffmpeg -i \"concat:" elenco_video = glob.glob("*.mp4") elenco_file_temp = [] for f in elenco_video: file = "temp" + str(elenco_video.index(f) + 1) + ".ts" os.system("ffmpeg -i " + f + " -c copy -bsf:v h264_mp4toannexb -f mpegts " + file) elenco_file_temp.append(file) print(elenco_file_temp) for f in elenco_file_temp: stringa += f if elenco_file_temp.index(f) != len(elenco_file_temp)-1: stringa += "|" else: stringa += "\" -c copy -bsf:a aac_adtstoasc output.mp4" print(stringa) os.system(stringa) concatenate()
A little script to trim the video
You can make this a little more useful (or you can just run the code in the cmd). Later I will make something a little more complex out of this ffmpeg command.
import os os.system("ffmpeg -i joinmp4.mp4 -ss 00:00:03 -to 00:10:50 -c:v copy -c:a copy joinmp4_b.mp4")