added json tests
refactored main to utils add_input and add_output used static ffmpeg paths
This commit is contained in:
19
main.py
19
main.py
@@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from Utils import FFEXE_STATIC, add_input, add_output
|
||||||
# startdir = os.path.join("E:", "tmp", "input")
|
|
||||||
|
|
||||||
|
|
||||||
season = r"E:\tmp\Season2\\"
|
season = r"E:\tmp\Season2\\"
|
||||||
@@ -11,9 +10,7 @@ videodir = season + "video"
|
|||||||
rescaleddir = season + "rescaled"
|
rescaleddir = season + "rescaled"
|
||||||
outputdir = season + "output"
|
outputdir = season + "output"
|
||||||
networkdir = r"\\nas451\Video\serieUR\Kalkofes Mattscheibe - Premiere Klassiker\Season 2"
|
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
|
# -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
|
# 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
|
||||||
@@ -22,7 +19,9 @@ os.chdir(inputdir)
|
|||||||
for file in os.listdir(inputdir):
|
for file in os.listdir(inputdir):
|
||||||
ifilename = inputdir + "\\" + file
|
ifilename = inputdir + "\\" + file
|
||||||
audiofilename = audiodir + "\\" + file[:6] + ".m4a"
|
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
|
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):
|
if not os.path.isfile(audiofilename):
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
@@ -31,7 +30,9 @@ os.chdir(rescaleddir)
|
|||||||
for file in os.listdir(rescaleddir):
|
for file in os.listdir(rescaleddir):
|
||||||
ifilename = rescaleddir + "\\" + file
|
ifilename = rescaleddir + "\\" + file
|
||||||
videofile = videodir + "\\" + file[:6] + ".mp4"
|
videofile = videodir + "\\" + file[:6] + ".mp4"
|
||||||
cmd = ffexe + " -i " + ifilename + " -map 0:v -c copy " + videofile
|
cmd = add_input(FFEXE_STATIC, ifilename)
|
||||||
|
cmd = cmd + " -map 0:v -c copy"
|
||||||
|
cmd = add_output(cmd, videofile)
|
||||||
if not os.path.isfile(videofile):
|
if not os.path.isfile(videofile):
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
@@ -41,7 +42,11 @@ for file in os.listdir(videodir):
|
|||||||
videofile = videodir + "\\" + file
|
videofile = videodir + "\\" + file
|
||||||
audiofilename = audiodir + "\\" + file[:6] + ".m4a"
|
audiofilename = audiodir + "\\" + file[:6] + ".m4a"
|
||||||
outputfilename = outputdir + "\\" + file[:6] + ".mp4"
|
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
|
|
||||||
|
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):
|
if not os.path.isfile(outputfilename):
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
|
|||||||
28
main2.py
28
main2.py
@@ -1,18 +1,38 @@
|
|||||||
import os
|
import os
|
||||||
from Utils import FFEXE_STATIC, select_video_stream, add_stream_selection, stream_selector, add_output, format_output, \
|
from Utils import FFEXE_STATIC, select_video_stream, add_stream_selection, stream_selector, add_output, format_output, \
|
||||||
add_input
|
add_input
|
||||||
|
import json
|
||||||
|
|
||||||
input_0 = r"E:\tmp\S01e01.mkv"
|
|
||||||
input_1 = r"E:\tmp\S01e01_1.88x_1920x1080_dtvs-2.mp4"
|
input_0 = r"E:\tmp\Bab5-Sample\S01e01.mkv"
|
||||||
output = r"E:\tmp\out.mp4"
|
input_1 = r"E:\tmp\Bab5-Sample\S01e01_1.88x_1920x1080_dtvs-2.mp4"
|
||||||
|
output = r"E:\tmp\Bab5-Sample\out.mp4"
|
||||||
|
|
||||||
streams = stream_selector(input_0, 0)
|
streams = stream_selector(input_0, 0)
|
||||||
streams = select_video_stream(streams)
|
streams = select_video_stream(streams, 1)
|
||||||
|
|
||||||
cmd = add_input(FFEXE_STATIC, input_0)
|
cmd = add_input(FFEXE_STATIC, input_0)
|
||||||
cmd = add_input(cmd, input_1)
|
cmd = add_input(cmd, input_1)
|
||||||
cmd = add_stream_selection(cmd, streams)
|
cmd = add_stream_selection(cmd, streams)
|
||||||
cmd = add_output(cmd, output)
|
cmd = add_output(cmd, output)
|
||||||
|
|
||||||
|
|
||||||
|
# C:\Users\Thaloria\Downloads\ffmpeg-4.4-full_build\bin\ffprobe.exe -v quiet -print_format json -show_format -show_streams S01e01.mkv > S01e01.json
|
||||||
|
|
||||||
|
# read file
|
||||||
|
with open(r"E:\tmp\Bab5-Sample\S01e01.json", 'r') as myfile:
|
||||||
|
data = myfile.read()
|
||||||
|
|
||||||
|
# parse file
|
||||||
|
obj = json.loads(data)
|
||||||
|
for i in obj['streams']:
|
||||||
|
if i['codec_type'] == 'video':
|
||||||
|
print(i['codec_type'])
|
||||||
|
else:
|
||||||
|
print(i['codec_type'])
|
||||||
|
print(i['tags'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(cmd)
|
print(cmd)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user