import os import shutil # startdir = os.path.join("E:", "tmp", "input") season = r"E:\tmp\Season2\\" inputdir = season + "input" audiodir = season + "audio" videodir = season + "video" rescaleddir = season + "rescaled" outputdir = season + "output" networkdir = r"\\nas451\Video\serieUR\Kalkofes Mattscheibe - Premiere Klassiker\Season 2" networkdir2 = r"\\nas451\Inbox\Kalkofe\Scale1080p\Season2\rescaled" ffexe = r"C:\Users\Thaloria\Downloads\ffmpeg-4.4-full_build\bin\ffmpeg.exe" # -i S01E01.mkv -map 0:a S01E01.m4a # ffmpeg -i input.mp4 -map 0 -c copy -metadata:s:a:0 title="One" -metadata:s:a:1 title="Two" -metadata:s:a:0 language=eng -metadata:s:a:1 language=spa output.mp4 os.chdir(inputdir) for file in os.listdir(inputdir): ifilename = inputdir + "\\" + file audiofilename = audiodir + "\\" + file[:6] + ".m4a" cmd = ffexe + " -i " + ifilename + " -map 0:a -metadata:s:a:0 title='Original' -metadata:s:a:1 title='Audiokommentar' -metadata:s:a:0 language=ger -metadata:s:a:1 language=ger " + audiofilename if not os.path.isfile(audiofilename): os.system(cmd) # ffmpeg -i input.mp4 -map 0:v output.mp4 os.chdir(rescaleddir) for file in os.listdir(rescaleddir): ifilename = rescaleddir + "\\" + file videofile = videodir + "\\" + file[:6] + ".mp4" cmd = ffexe + " -i " + ifilename + " -map 0:v -c copy " + videofile if not os.path.isfile(videofile): os.system(cmd) # ffmpeg -i video.mp4 -i audio.m4a -map 0:v -map 0:a output.mkv os.chdir(videodir) for file in os.listdir(videodir): videofile = videodir + "\\" + file audiofilename = audiodir + "\\" + file[:6] + ".m4a" outputfilename = outputdir + "\\" + file[:6] + ".mp4" cmd = ffexe + " -i " + videofile + " -i " + audiofilename + " -map 0:v -map 1:a -metadata:s:a:0 title='Original' -metadata:s:a:1 title='Audiokommentar' -c copy " + outputfilename if not os.path.isfile(outputfilename): os.system(cmd) os.chdir(outputdir) for file in os.listdir(outputdir): outputfilename = outputdir + "\\" + file networkfilename = networkdir + "\\" + file if not os.path.isfile(networkfilename): shutil.copyfile(outputfilename, networkfilename) os.chdir(rescaleddir) for file in os.listdir(rescaleddir): networkfilename = networkdir + "\\" + file[:6] + ".mp4" if os.path.isfile(networkfilename): os.remove(audiodir + "\\" + file[:6] + ".m4a") os.remove(videodir + "\\" + file[:6] + ".mp4") os.remove(outputdir + "\\" + file[:6] + ".mp4") os.remove(inputdir + "\\" + file[:6] + ".mkv") os.remove(rescaleddir + "\\" + file)