unMcFucking
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,3 +11,5 @@ test.mkv1out.mkv
|
|||||||
test.mkv0out.mkv
|
test.mkv0out.mkv
|
||||||
input.txt
|
input.txt
|
||||||
.gitignore
|
.gitignore
|
||||||
|
*.mkv
|
||||||
|
|
||||||
|
|||||||
BIN
__pycache__/functiontest.cpython-310.pyc
Normal file
BIN
__pycache__/functiontest.cpython-310.pyc
Normal file
Binary file not shown.
@@ -3,6 +3,7 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
output_folder_name ="/bulk_convert_out/"
|
||||||
|
|
||||||
droppedFile = sys.argv[1]
|
droppedFile = sys.argv[1]
|
||||||
droppedName = Path(droppedFile).name
|
droppedName = Path(droppedFile).name
|
||||||
@@ -12,27 +13,24 @@ duration = ""
|
|||||||
|
|
||||||
print(droppedName)
|
print(droppedName)
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
del sys.argv[0]
|
del sys.argv[0]
|
||||||
|
|
||||||
#vid:
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
|
||||||
for file in sys.argv:
|
for file in sys.argv:
|
||||||
i = 0
|
|
||||||
path = file
|
|
||||||
basename = os.path.basename(file)
|
basename = os.path.basename(file)
|
||||||
print(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 20 -x265-params "level=51:no-sao=1:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6" -pix_fmt yuv420p10le -map 0:a -c:a libopus -b:a 192k -map 0:s -c:s copy -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=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(args)
|
||||||
#print(each)
|
|
||||||
subprocess.run(args)
|
subprocess.run(args)
|
||||||
i += 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
k=input("press close to exit")
|
k=input("press close to exit")
|
||||||
38
bulk_covert_drop_5_1_audio.py
Normal file
38
bulk_covert_drop_5_1_audio.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
output_folder_name = "/bulk_convert_out/"
|
||||||
|
|
||||||
|
droppedFile = sys.argv[1]
|
||||||
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
|
skipto = ""
|
||||||
|
duration = ""
|
||||||
|
|
||||||
|
print(droppedName)
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
|
||||||
|
for file in sys.argv:
|
||||||
|
|
||||||
|
basename = os.path.basename(file)
|
||||||
|
print(file)
|
||||||
|
# opus audio - might not work for surround -
|
||||||
|
args = 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset slow -crf 20 -x265-params "level=51:no-sao=1:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6" -pix_fmt yuv420p10le -map 0:a -c:a libopus -ac 6 -b:a 576k -map 0:s -c:s copy -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||||
|
#arg_list = "".join(map(str, arguments))
|
||||||
|
print(args)
|
||||||
|
#print(each)
|
||||||
|
subprocess.run(args)
|
||||||
|
|
||||||
|
|
||||||
|
k=input("press close to exit")
|
||||||
24
functions.py
Normal file
24
functions.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from functiontest import *
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
|
||||||
|
#droppedFile = sys.argv[1]
|
||||||
|
#droppedName = Path(droppedFile).name
|
||||||
|
output_folder_name ="/bulk_convert_out/"
|
||||||
|
|
||||||
|
droppedFile = ['test.mkv']
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
arguments = sys.argv[1:]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
for file in droppedFile:
|
||||||
|
subprocess.run(function(file, output_folder_name))
|
||||||
4
functiontest.py
Normal file
4
functiontest.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import os
|
||||||
|
def function(file="", output_path="", output_folder_name=""):
|
||||||
|
basename = os.path.basename(file)
|
||||||
|
return 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset slow -crf 20 -x265-params "level=51:no-sao=1:bframes=8:psy-rd=1.5:psy-rdoq=5:aq-mode=3:ref=6" -pix_fmt yuv420p10le -map 0:a -c:a libopus -b:a 192k -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||||
69
getnative_aio.py
Normal file
69
getnative_aio.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
from ast import arguments
|
||||||
|
import re, subprocess, sys, os, shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
output_folder_name = "/temp/"
|
||||||
|
droppedFile = sys.argv[1]
|
||||||
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
|
#droppedFile = ['test_source.mkv']
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
arguments = sys.argv[1:]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
number_of_ss=int(input("Number of ss: "))
|
||||||
|
print(number_of_ss)
|
||||||
|
|
||||||
|
#run ffprobe to get duration of input file, then get appropriate timestamps out of it
|
||||||
|
for i, file in enumerate(arguments):
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
||||||
|
#use search instead of findall, no need to add it in a list
|
||||||
|
#int(re.search(r"[0-9]+", subprocces_std)[0])
|
||||||
|
#convert result to int
|
||||||
|
video_duration = [int(s) for s in re.findall(r"[0-9]+", subprocess_std)][0]
|
||||||
|
duration_percent = video_duration / 100
|
||||||
|
time = duration_percent * 15
|
||||||
|
skip = ((duration_percent * 90) - (duration_percent* 15)) / (number_of_ss -1)
|
||||||
|
|
||||||
|
#run ffmpeg to get screenshots and previously determined timestamps
|
||||||
|
|
||||||
|
for i in range(0, number_of_ss):
|
||||||
|
|
||||||
|
basename = os.path.basename(file)
|
||||||
|
args = 'ffmpeg.exe -ss {time} -i "{file}" -frames:v 1 -q:v 1 "{output_path}{output_folder_name}{basename}{i}.jpg"'.format(time=skip*i+time, file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename, i=i)
|
||||||
|
print(args)
|
||||||
|
subprocess.call(args)
|
||||||
|
|
||||||
|
|
||||||
|
#Find all new images in the output folder
|
||||||
|
img = os.listdir(output_path+output_folder_name)
|
||||||
|
|
||||||
|
#run getnative on all images created
|
||||||
|
for each in img:
|
||||||
|
args = 'py -3 -m getnative --show-plot-gui "{output_path}{output_folder_name}{each}" '.format(output_path=output_path,output_folder_name=output_folder_name, each=each)
|
||||||
|
print(args)
|
||||||
|
|
||||||
|
subprocess.call(args)
|
||||||
|
|
||||||
|
#clean the trash files generated
|
||||||
|
lwi = os.listdir(output_path)
|
||||||
|
for item in lwi:
|
||||||
|
if item.endswith(".lwi"):
|
||||||
|
os.remove(os.path.join(output_path, item))
|
||||||
|
shutil.rmtree(output_path+"/temp")
|
||||||
|
shutil.rmtree(output_path+"/results")
|
||||||
|
|
||||||
|
input("press enter to exit")
|
||||||
@@ -1,25 +1,32 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
output_folder_name = "/out_search"
|
||||||
|
|
||||||
droppedFile = sys.argv[1]
|
droppedFile = sys.argv[1]
|
||||||
droppedName = Path(droppedFile).name
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
del sys.argv[0]
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
for each in sys.argv:
|
for each in sys.argv:
|
||||||
print(each)
|
print(each)
|
||||||
print(droppedFile)
|
print(droppedFile)
|
||||||
print(droppedName)
|
print(droppedName)
|
||||||
args = 'py -3 -m getnative --show-plot-gui -dir "E:/Projects/python/ffmpeg_work_folder/out_search" "{each}" '.format(each=each)
|
args = 'py -3 -m getnative --show-plot-gui -dir "{output_path}/out_search" "{each}" '.format(output_path=output_path, each=each)
|
||||||
print(args)
|
print(args)
|
||||||
#print(each)
|
#print(each)
|
||||||
run = subprocess.Popen(args)
|
run = subprocess.Popen(args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
k=input("press close to exit")
|
k=input("press close to exit")
|
||||||
|
|||||||
0
improvements.txt
Normal file
0
improvements.txt
Normal file
106
long_path_test.py
Normal file
106
long_path_test.py
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
output_folder_name = "/out_sub_audio/"
|
||||||
|
regex_subtitle = re.compile("Stream #0:\d+(\(\w*\))?: Subtitle:.*")
|
||||||
|
regex_audio = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
|
||||||
|
nr_files = 0
|
||||||
|
files_processed = []
|
||||||
|
droppedFile = sys.argv[1]
|
||||||
|
droppedName = Path(droppedFile).name
|
||||||
|
originalfiles = sys.orig_argv[2:]
|
||||||
|
|
||||||
|
|
||||||
|
# To fix I need to create symlinks to files with long paths and use the links instead. And then remove said symlinks once
|
||||||
|
|
||||||
|
|
||||||
|
#droppedFile= ['X:\\test\\longpathtest\\longerpathlongerpathlongerpathlongerpathlongerpathlongerpathlongerpath\\longpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpath\\fourteen\\[Kira-Fansub]_Choujuushin Gravion_Episode 06_(BD 1280x960 h264 JP AAC EN AAC) [E7D92968].mkv', '', ' X:\\test\\longpathtest\\longerpathlongerpathlongerpathlongerpathlongerpathlongerpathlongerpath\\longpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpathlongpath\\fourteen\\[Kira-Fansub]_Choujuushin Gravion_Episode 09_(BD 1280x960 h264 JP AAC EN AAC) [A2727604].mkv']
|
||||||
|
#originalfiles = droppedFile
|
||||||
|
|
||||||
|
print(droppedFile)
|
||||||
|
print()
|
||||||
|
print()
|
||||||
|
print("printing original: ", originalfiles)
|
||||||
|
|
||||||
|
joined = (' '.join(originalfiles))
|
||||||
|
print("printing joined: ", joined)
|
||||||
|
listed = re.split(r'([A-Z]:.+?)(?=[A-Z]:)', joined)
|
||||||
|
listed = list(filter(None, listed))
|
||||||
|
|
||||||
|
|
||||||
|
print("printing listed: ", listed)
|
||||||
|
|
||||||
|
sym_target = "E:/Projects/python/ffmpeg_collection/temp/test/"
|
||||||
|
sym_location = os.path.split(listed[0])
|
||||||
|
print("sym locations: ", sym_location)
|
||||||
|
|
||||||
|
#os.symlink(sym_location[0], sym_target ,target_is_directory=True)
|
||||||
|
#sym_list = []
|
||||||
|
#for each in listed:
|
||||||
|
# r = tuple(os.path.split(each))
|
||||||
|
# name = tuple(r[1])
|
||||||
|
# print("printing R", r[1])
|
||||||
|
# path_used = tuple(sym_target)
|
||||||
|
# print(type(name))
|
||||||
|
# print(type(path_used))
|
||||||
|
# join_before = (''.join(path_used + name ))
|
||||||
|
# sym_list.append(join_before)
|
||||||
|
# print("printing symlist: ", sym_list)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
#droppedFile = "test.mkv"
|
||||||
|
|
||||||
|
|
||||||
|
for i, file in enumerate(listed):
|
||||||
|
arg_list = '.\\ffprobe.exe -i "{file}"'.format(file=file)
|
||||||
|
print(arg_list)
|
||||||
|
|
||||||
|
cmd = subprocess.Popen(["powershell.exe", arg_list], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
|
||||||
|
|
||||||
|
subprocess_err = cmd.communicate()[1]
|
||||||
|
print(subprocess_err)
|
||||||
|
|
||||||
|
print("file", i+1,":", Path(file).name)
|
||||||
|
|
||||||
|
for r, match in enumerate(regex_audio.finditer(subprocess_err)):
|
||||||
|
print("Audio Track", r,": ", match.group(0))
|
||||||
|
for r, match in enumerate(regex_subtitle.finditer(subprocess_err)):
|
||||||
|
print("Subtitle Track", r,": ", match.group(0))
|
||||||
|
print('\n')
|
||||||
|
|
||||||
|
|
||||||
|
x = (int(x) for x in input ("Enter audio tracks to keep: ").split())
|
||||||
|
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 file in sym_list:
|
||||||
|
|
||||||
|
basename = os.path.basename(file)
|
||||||
|
|
||||||
|
arg_list = 'ffmpeg.exe -i "{file}" -map 0:v {audio_track} {subtitle_track} -c copy "{output_path}{output_folder_name}{basename}"'.format(file=file, audio_track=audio_track, subtitle_track=subtitle_track, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||||
|
print(arg_list)
|
||||||
|
subprocess.run(arg_list)
|
||||||
|
nr_files = nr_files+1
|
||||||
|
files_processed.append(file)
|
||||||
|
|
||||||
|
|
||||||
|
print("Number of files processed: ", nr_files)
|
||||||
|
print(*files_processed, sep='\n')
|
||||||
|
input("press enter to exit")
|
||||||
8
powershell_test
Normal file
8
powershell_test
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import subprocess, sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
folder_path=os.getcwd()
|
||||||
|
p = subprocess.Popen(["powershell.exe", "dir"])
|
||||||
|
|
||||||
|
|
||||||
|
res=p.communicate()
|
||||||
@@ -3,18 +3,26 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
output_folder_name = "/quality_test_out/"
|
||||||
droppedFile = sys.argv[1]
|
droppedFile = sys.argv[1]
|
||||||
droppedName = Path(droppedFile).name
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
skipto = " -ss "
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
#droppedFile = ["sam_overlord_bluraysource.mkv"]
|
#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"
|
lines = "-map 0:v -c:v libx265 -preset slow -crf 20 -x265-params level=51:no-sao=1: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"
|
#org_lineslines = " -map 0:v -c:v libx264 -crf 5 -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: "))
|
number_of_segments=int(input("Number of segments: "))
|
||||||
@@ -42,8 +50,8 @@ for i, file in enumerate(sys.argv):
|
|||||||
|
|
||||||
|
|
||||||
for i in range(0, number_of_segments):
|
for i in range(0, number_of_segments):
|
||||||
|
basename = os.path.basename(file)
|
||||||
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} {lines} -f matroska "{output_path}{output_folder_name}compare_{i}{basename}"'.format(time=skip*i+time, segment_length=segment_length, file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename, 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)
|
#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)
|
print(args)
|
||||||
run = subprocess.Popen(args)
|
run = subprocess.Popen(args)
|
||||||
|
|||||||
65
quality_test_originals.py
Normal file
65
quality_test_originals.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
output_folder_name = "/quality_test_out/"
|
||||||
|
droppedFile = sys.argv[1]
|
||||||
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
#droppedFile = ["sam_overlord_bluraysource.mkv"]
|
||||||
|
|
||||||
|
|
||||||
|
#lines = "-map 0:v -c:v libx265 -preset slow -crf 22 -x265-params level=51:no-sao=1: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 5 -map 0:a -c:a copy -map 0:s -c:s copy"
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
basename = os.path.basename(file)
|
||||||
|
#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 "{output_path}{output_folder_name}ORIGINAL_COMP_{i}{basename}"'.format(time=skip*i+time, segment_length=segment_length, file=file, org_lineslines=org_lineslines, output_path=output_path, output_folder_name=output_folder_name, basename=basename, i=i)
|
||||||
|
print(args)
|
||||||
|
run = subprocess.Popen(args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print('\n')
|
||||||
|
|
||||||
|
|
||||||
|
input("press enter to exit")
|
||||||
1
regex_test.txt
Normal file
1
regex_test.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
['X:\\test\\file\\video.mkv', 'X:\\test\\EDEN', 'ZERO', '(2021)', 'file.mkv' 'D:\\five\\fourteen\\anime\\stuff', 'TOTALLY', 'A', 'ANIMUS.mkv']
|
||||||
@@ -3,15 +3,22 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
regex = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
|
output_folder_name = "/screenshots/"
|
||||||
|
|
||||||
|
|
||||||
droppedFile = sys.argv[1]
|
droppedFile = sys.argv[1]
|
||||||
droppedName = Path(droppedFile).name
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
#droppedFile = ['sam_overlord_bluraysource.mkv']
|
#droppedFile = ['test_source.mkv']
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
del sys.argv[0]
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
number_of_ss=int(input("Number of ss: "))
|
number_of_ss=int(input("Number of ss: "))
|
||||||
print(number_of_ss)
|
print(number_of_ss)
|
||||||
|
|
||||||
@@ -34,7 +41,8 @@ for i, file in enumerate(sys.argv):
|
|||||||
skip = ((duration_percent * 90) - (duration_percent* 15)) / (number_of_ss -1)
|
skip = ((duration_percent * 90) - (duration_percent* 15)) / (number_of_ss -1)
|
||||||
for i in range(0, number_of_ss):
|
for i in range(0, number_of_ss):
|
||||||
|
|
||||||
args = 'ffmpeg.exe -ss {time} -i "{file}" -frames:v 1 -q:v 1 "{file}{i}.jpg"'.format(time=skip*i+time, file=file, i=i)
|
basename = os.path.basename(file)
|
||||||
|
args = 'ffmpeg.exe -ss {time} -i "{file}" -frames:v 1 -q:v 1 "{output_path}{output_folder_name}{basename}{i}.jpg"'.format(time=skip*i+time, file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename, i=i)
|
||||||
print(args)
|
print(args)
|
||||||
run = subprocess.Popen(args)
|
run = subprocess.Popen(args)
|
||||||
|
|
||||||
|
|||||||
@@ -3,27 +3,39 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
regex_subtitle = re.compile("Stream #0:\d(\(\w*\))?: Subtitle:.*")
|
output_folder_name = "/out_sub_audio/"
|
||||||
|
regex_subtitle = re.compile("Stream #0:\d+(\(\w*\))?: Subtitle:.*")
|
||||||
regex_audio = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
|
regex_audio = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
|
||||||
|
nr_files = 0
|
||||||
|
files_processed = []
|
||||||
droppedFile = sys.argv[1]
|
droppedFile = sys.argv[1]
|
||||||
droppedName = Path(droppedFile).name
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
skipto = " -ss "
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
#droppedFile = "test.mkv"
|
#droppedFile = "test.mkv"
|
||||||
|
|
||||||
del sys.argv[0]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i, file in enumerate(sys.argv):
|
for i, file in enumerate(sys.argv):
|
||||||
|
|
||||||
arg_list = 'ffprobe.exe -i "{file}"'.format(file=file)
|
arg_list = 'ffprobe.exe -i "{file}"'.format(file=file)
|
||||||
|
|
||||||
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
|
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
|
||||||
|
|
||||||
subprocess_err = cmd.communicate()[1]
|
subprocess_err = cmd.communicate()[1]
|
||||||
|
|
||||||
print("file", i+1)
|
print("file", i+1,":", Path(file).name)
|
||||||
|
|
||||||
for r, match in enumerate(regex_audio.finditer(subprocess_err)):
|
for r, match in enumerate(regex_audio.finditer(subprocess_err)):
|
||||||
print("Audio Track", r,": ", match.group(0))
|
print("Audio Track", r,": ", match.group(0))
|
||||||
@@ -43,11 +55,13 @@ for file in sys.argv:
|
|||||||
|
|
||||||
basename = os.path.basename(file)
|
basename = os.path.basename(file)
|
||||||
|
|
||||||
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)
|
arg_list = 'ffmpeg.exe -i "{file}" -map 0:v {audio_track} {subtitle_track} -c copy "{output_path}{output_folder_name}{basename}"'.format(file=file, audio_track=audio_track, subtitle_track=subtitle_track, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||||
|
|
||||||
print(arg_list)
|
print(arg_list)
|
||||||
|
|
||||||
subprocess.run(arg_list)
|
subprocess.run(arg_list)
|
||||||
|
nr_files = nr_files+1
|
||||||
|
files_processed.append(file)
|
||||||
|
|
||||||
|
|
||||||
|
print("Number of files processed: ", nr_files)
|
||||||
|
print(*files_processed, sep='\n')
|
||||||
input("press enter to exit")
|
input("press enter to exit")
|
||||||
|
|||||||
68
sub-and-audio_drop_to_file.py
Normal file
68
sub-and-audio_drop_to_file.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
output_folder_name = "/out_sub_audio/"
|
||||||
|
regex_subtitle = re.compile("Stream #0:\d+(\(\w*\))?: Subtitle:.*")
|
||||||
|
regex_audio = re.compile("Stream #0:\d(\(\w*\))?: Audio:.*")
|
||||||
|
nr_files = 0
|
||||||
|
files_processed = []
|
||||||
|
droppedFile = sys.argv[1]
|
||||||
|
droppedName = Path(droppedFile).name
|
||||||
|
|
||||||
|
|
||||||
|
#get path of script location and remove the tail
|
||||||
|
head_tail = os.path.split(sys.argv[0])
|
||||||
|
output_path = head_tail[0]
|
||||||
|
del sys.argv[0]
|
||||||
|
|
||||||
|
#check if output folder exists, otherwise create it
|
||||||
|
isExist = os.path.exists(output_path+output_folder_name)
|
||||||
|
if not isExist:
|
||||||
|
os.makedirs(output_path+output_folder_name)
|
||||||
|
|
||||||
|
#droppedFile = "test.mkv"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i, file in enumerate(sys.argv):
|
||||||
|
arg_list = 'ffprobe.exe -i "{file}"'.format(file=file)
|
||||||
|
|
||||||
|
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
|
||||||
|
|
||||||
|
subprocess_err = cmd.communicate()[1]
|
||||||
|
|
||||||
|
print("file", i+1,":", Path(file).name)
|
||||||
|
|
||||||
|
for r, match in enumerate(regex_audio.finditer(subprocess_err)):
|
||||||
|
print("Audio Track", r,": ", match.group(0))
|
||||||
|
for r, match in enumerate(regex_subtitle.finditer(subprocess_err)):
|
||||||
|
print("Subtitle Track", r,": ", match.group(0))
|
||||||
|
print('\n')
|
||||||
|
|
||||||
|
|
||||||
|
x = (int(x) for x in input ("Enter audio tracks to keep: ").split())
|
||||||
|
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 file in sys.argv:
|
||||||
|
|
||||||
|
basename = os.path.basename(file)
|
||||||
|
|
||||||
|
arg_list = 'ffmpeg.exe -i "{file}" -map 0:v {audio_track} {subtitle_track} -c copy "{output_path}{output_folder_name}{basename}"'.format(file=file, audio_track=audio_track, subtitle_track=subtitle_track, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||||
|
print(arg_list)
|
||||||
|
with open ('input.txt', 'a') as of:
|
||||||
|
of.write(arg_list + "\n")
|
||||||
|
nr_files = nr_files+1
|
||||||
|
files_processed.append(file)
|
||||||
|
|
||||||
|
|
||||||
|
print("Number of files processed: ", nr_files)
|
||||||
|
print(*files_processed, sep='\n')
|
||||||
|
input("press enter to exit")
|
||||||
Reference in New Issue
Block a user