61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
import os
|
|
import shutil
|
|
from Utils import FFEXE_STATIC, add_input, add_output
|
|
|
|
|
|
season = r"E:\tmp\Season3\\"
|
|
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 3"
|
|
|
|
|
|
# -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
|
|
mp4_filename = file[:6] + ".mp4"
|
|
audiofilename = audiodir + "\\" + file[:6] + ".m4a"
|
|
|
|
|
|
prefixed = [filename for filename in os.listdir(rescaleddir) if filename.startswith(file[:6])]
|
|
if len(prefixed) == 0:
|
|
continue
|
|
rscale_filename = rescaleddir + "\\" + prefixed[0]
|
|
|
|
videofile = videodir + "\\" + mp4_filename
|
|
outputfilename = outputdir + "\\" + mp4_filename
|
|
networkfilename = networkdir + "\\" + mp4_filename
|
|
|
|
cmd = add_input(FFEXE_STATIC, ifilename)
|
|
cmd = cmd + " -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"
|
|
cmd = add_output(cmd, audiofilename)
|
|
if not os.path.isfile(audiofilename):
|
|
os.system(cmd)
|
|
|
|
cmd = add_input(FFEXE_STATIC, rscale_filename)
|
|
cmd = cmd + " -map 0:v -c libx264 -b:v 15M -maxrate 19M -bufsize 3M"
|
|
cmd = add_output(cmd, videofile)
|
|
if not os.path.isfile(videofile):
|
|
os.system(cmd)
|
|
|
|
cmd = add_input(FFEXE_STATIC, videofile)
|
|
cmd = add_input(cmd, audiofilename)
|
|
cmd = cmd + " -map 0:v -map 1:a -metadata:s:a:0 title='Original' -metadata:s:a:1 title='Audiokommentar' -c copy"
|
|
cmd = add_output(cmd, outputfilename)
|
|
if not os.path.isfile(outputfilename):
|
|
os.system(cmd)
|
|
|
|
if not os.path.isfile(networkfilename):
|
|
shutil.copyfile(outputfilename, networkfilename)
|
|
|
|
if os.path.isfile(networkfilename):
|
|
os.remove(audiofilename)
|
|
os.remove(videofile)
|
|
os.remove(outputfilename)
|
|
os.remove(ifilename)
|
|
os.remove(rscale_filename) |