From db2ff6ebfdca8b0340576a4ef2dbaf077da2de7f Mon Sep 17 00:00:00 2001 From: Elghinnarisa Date: Fri, 9 Sep 2022 19:46:34 +0200 Subject: [PATCH] updated ffmpeg binaries, general improvements --- .gitignore | 4 +++ bulk_covert_drop.py | 20 +++++++-------- ffprobe_drop.py | 37 +++++++++++++++++++++++++++ getnative_drop.py | 25 +++++++++++++++++++ quality_test.py | 58 +++++++++++++++++++++++++++++++++++++++++++ sub-and-audio_drop.py | 11 ++++---- 6 files changed, 139 insertions(+), 16 deletions(-) create mode 100644 ffprobe_drop.py create mode 100644 getnative_drop.py create mode 100644 quality_test.py diff --git a/.gitignore b/.gitignore index 19cd851..6893b69 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ test - Copy.mkv test.mkv test123.mkv *.jpg +test.mkv1out.mkv +test.mkv0out.mkv +input.txt +.gitignore diff --git a/bulk_covert_drop.py b/bulk_covert_drop.py index 42ff653..7edb02a 100644 --- a/bulk_covert_drop.py +++ b/bulk_covert_drop.py @@ -10,7 +10,7 @@ droppedName = Path(droppedFile).name skipto = "" duration = "" - +print(droppedName) @@ -19,17 +19,17 @@ del sys.argv[0] #vid: -for each in sys.argv: +for file in sys.argv: i = 0 - path = each - basename = os.path.basename(path) - print(each) - arguments = ( "ffmpeg.exe ", " -i ", '"', each, '"',skipto, duration, " -map 0:v ", " -c:v libx265 -preset slow -crf 21 -x265-params "'level=51:no-sao:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6'" -pix_fmt yuv420p10le ", " -map 0:a -c:a copy -map 0:s -c:s copy -f matroska ",'"',"E:/Projects/python/ffmpeg_by_textfile/out_done/", basename, '"' ) - - arg_list = "".join(map(str, arguments)) - print(arg_list) + path = file + basename = os.path.basename(file) + print(file) + #arguments = ( "ffmpeg.exe ", " -i ", '"', each, '"',skipto, duration, " -map 0:v ", ",'"',"E:/Projects/python/ffmpeg_by_textfile/out_done/", basename, '"' ) + args = 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset slow -crf 21 -x265-params level=51:no-sao:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6 -pix_fmt yuv420p10le -map 0:a -c:a copy -map 0:s -c:s copy -f matroska "E:/Projects/python/ffmpeg_quality_testing/out/{basename}"'.format(file=file, basename=basename) + #arg_list = "".join(map(str, arguments)) + print(args) #print(each) - subprocess.run(arg_list) + subprocess.run(args) i += 1 diff --git a/ffprobe_drop.py b/ffprobe_drop.py new file mode 100644 index 0000000..b547558 --- /dev/null +++ b/ffprobe_drop.py @@ -0,0 +1,37 @@ +import subprocess +import sys +from pathlib import Path + + +droppedFile = sys.argv[1] +droppedName = Path(droppedFile).name + +skipto = " -ss " + +#droppedFile = "test.mkv" +count = 0 +del sys.argv[0] + +for each in sys.argv: + i = 0 + + print(each) + arguments = ( "ffprobe.exe ", " -i ", '"' , each, '"' ) + + arg_list = "".join(map(str, arguments)) + print(arg_list) + #print(each) + cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8') + subprocess_err = cmd.stderr.read() + + #for line in subprocess_err: + # print(line) + print(subprocess_err) + + + i += 1 + + + + +k=input("press close to exit") diff --git a/getnative_drop.py b/getnative_drop.py new file mode 100644 index 0000000..b68881e --- /dev/null +++ b/getnative_drop.py @@ -0,0 +1,25 @@ +import subprocess +from pathlib import Path +import sys + + +droppedFile = sys.argv[1] +droppedName = Path(droppedFile).name +del sys.argv[0] + +for each in sys.argv: + print(each) + print(droppedFile) + print(droppedName) + args = 'py -3 -m getnative --show-plot-gui -dir "E:/Projects/python/ffmpeg_work_folder/out_search" "{each}" '.format(each=each) + print(args) + #print(each) + run = subprocess.Popen(args) + + + + + + + +k=input("press close to exit") diff --git a/quality_test.py b/quality_test.py new file mode 100644 index 0000000..d39a4c8 --- /dev/null +++ b/quality_test.py @@ -0,0 +1,58 @@ +import re +import subprocess +import sys +from pathlib import Path +import os + +droppedFile = sys.argv[1] +droppedName = Path(droppedFile).name + +skipto = " -ss " + +#droppedFile = ["sam_overlord_bluraysource.mkv"] + +lines = "-map 0:v -c:v libx265 -preset slow -crf 21 -x265-params level=51:no-sao:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6 -pix_fmt yuv420p10le -map 0:a -c:a copy -map 0:s -c:s copy" +#org_lineslines = " -map 0:v -c:v libx264 -crf 0 -map 0:a -c:a copy -map 0:s -c:s copy" +#-map 0:v -c:v libx265 -preset slow -crf 21 -x265-params level=51:no-sao:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6 -pix_fmt yuv420p10le -map 0:a -c:a copy -map 0:s -c:s copy -f +del sys.argv[0] + + +number_of_segments=int(input("Number of segments: ")) +segment_length=int(input("How long should each segment be(seconds)? ")) + +for i, file in enumerate(sys.argv): + + arg_list = 'ffprobe.exe -show_entries format=duration -i "{file}"'.format(file=file) + print(arg_list) + cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8') + + subprocess_std = cmd.communicate()[0] + + print("stdout printing: " , subprocess_std) + video_duration = [int(s) for s in re.findall(r"[0-9]+", subprocess_std)][0] + print("video_duration: ", video_duration, "s") + duration_percent = video_duration / 100 + print(duration_percent) + + time = duration_percent * 15 + + skip = ((duration_percent * 90) - (duration_percent* 20)) / (number_of_segments -1) + + + + + for i in range(0, number_of_segments): + + args = 'ffmpeg.exe -i "{file}" -ss {time} -t {segment_length} {lines} -f matroska "{file}{i}out.mkv"'.format(time=skip*i+time, segment_length=segment_length, file=file, lines=lines, i=i) + #args = 'ffmpeg.exe -i "{file}" -ss {time} -t {segment_length} {org_lineslines} -f matroska "{file}{i}ORIGINAL_COMP.mkv"'.format(time=skip*i+time, segment_length=segment_length, file=file, org_lineslines=org_lineslines, i=i) + print(args) + run = subprocess.Popen(args) + + + + + + print('\n') + + +input("press enter to exit") \ No newline at end of file diff --git a/sub-and-audio_drop.py b/sub-and-audio_drop.py index 708ed41..84f4954 100644 --- a/sub-and-audio_drop.py +++ b/sub-and-audio_drop.py @@ -15,9 +15,9 @@ skipto = " -ss " del sys.argv[0] -for i, each in enumerate(sys.argv): +for i, file in enumerate(sys.argv): - arg_list = 'ffprobe.exe -i "{each}"'.format(each=each) + arg_list = 'ffprobe.exe -i "{file}"'.format(file=file) cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8') @@ -39,12 +39,11 @@ audio_track = "".join(" -map 0:a:{}".format(y) for y in x) z = (int(z) for z in input ("Enter subtitle tracks to keep: ").split()) subtitle_track = "".join(" -map 0:s:{}".format(y) for y in z) -for each in sys.argv: +for file in sys.argv: - path = each - basename = os.path.basename(path) + basename = os.path.basename(file) - arg_list = 'ffmpeg.exe -i "{each}" -map 0:v {audio_track} {subtitle_track} -c copy "E:/Projects/ffmpeg_tests/audio_tracks/out/{basename}"'.format(each=each, audio_track=audio_track, subtitle_track=subtitle_track, basename=basename) + arg_list = 'ffmpeg.exe -i "{file}" -map 0:v {audio_track} {subtitle_track} -c copy "E:/Projects/ffmpeg_tests/audio_tracks/out/{basename}"'.format(file=file, audio_track=audio_track, subtitle_track=subtitle_track, basename=basename) print(arg_list)