added version 3

This commit is contained in:
2021-07-04 21:09:58 +02:00
parent b83a1a1451
commit d5001896ff
2 changed files with 66 additions and 3 deletions

View File

@@ -26,12 +26,13 @@ for file in os.listdir(inputdir):
os.system(cmd)
# ffmpeg -i input.mp4 -map 0:v output.mp4
# C:\Users\Thaloria\Downloads\ffmpeg-4.4-full_build\bin\ffmpeg.exe -i S03E07.mp4 -c:v libx264 -b:v 15M -maxrate 19M -bufsize 3M output.mp4
os.chdir(rescaleddir)
for file in os.listdir(rescaleddir):
ifilename = rescaleddir + "\\" + file
videofile = videodir + "\\" + file[:6] + ".mp4"
cmd = add_input(FFEXE_STATIC, ifilename)
cmd = cmd + " -map 0:v -c copy"
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)
@@ -57,6 +58,7 @@ for file in os.listdir(outputdir):
if not os.path.isfile(networkfilename):
shutil.copyfile(outputfilename, networkfilename)
os.chdir(rescaleddir)
for file in os.listdir(rescaleddir):
networkfilename = networkdir + "\\" + file[:6] + ".mp4"
@@ -64,5 +66,5 @@ for file in os.listdir(rescaleddir):
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(inputdir + "\\" + file[:6] + ".mkv")
os.remove(rescaleddir + "\\" + file)

61
main_3.py Normal file
View File

@@ -0,0 +1,61 @@
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)