just updates
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -15,3 +15,9 @@ input.txt
|
||||
long_path_test.py
|
||||
\__pycache__
|
||||
log.txt
|
||||
ffmpeg2pass-0.log
|
||||
sauce.mp4
|
||||
.gitignore
|
||||
test.webm
|
||||
subprocess_err.txt
|
||||
mkvmerge.exe
|
||||
|
||||
29
append_to_textfile.py
Normal file
29
append_to_textfile.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
with open ('test.txt', 'a', encoding="utf-8") as file:
|
||||
for each in listed:
|
||||
file.write(each+"\n")
|
||||
29
append_to_textfile5_1.py
Normal file
29
append_to_textfile5_1.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
with open ('test5_1.txt', 'a') as file:
|
||||
for each in listed:
|
||||
file.write(each+"\n")
|
||||
@@ -2,15 +2,20 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import psutil
|
||||
import re
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
skipto = ""
|
||||
duration = ""
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
@@ -27,20 +32,14 @@ isExist = os.path.exists(output_path+output_folder_name)
|
||||
if not isExist:
|
||||
os.makedirs(output_path+output_folder_name)
|
||||
|
||||
def run_ffmpeg(file):
|
||||
|
||||
for file in listed:
|
||||
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
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}" -fps_mode passthrough -map 0:v:0 -c:v libx265 -preset slow -crf 20 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -pix_fmt yuv420p10le -map 0:a -c:a copy -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(args)
|
||||
psutil.Process.cpu_affinity([0,1])
|
||||
psutil.Popen(args)
|
||||
|
||||
|
||||
for file in arguments:
|
||||
run_ffmpeg(file)
|
||||
|
||||
|
||||
|
||||
subprocess.run(args)
|
||||
|
||||
|
||||
k=input("press close to exit")
|
||||
@@ -2,14 +2,20 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
skipto = ""
|
||||
duration = ""
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
@@ -27,11 +33,11 @@ if not isExist:
|
||||
os.makedirs(output_path+output_folder_name)
|
||||
|
||||
|
||||
for file in arguments:
|
||||
for file in listed:
|
||||
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
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}" -fps_mode passthrough -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
subprocess.run(args)
|
||||
|
||||
|
||||
@@ -2,13 +2,19 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
output_folder_name = "/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
skipto = ""
|
||||
duration = ""
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
@@ -26,12 +32,12 @@ if not isExist:
|
||||
os.makedirs(output_path+output_folder_name)
|
||||
|
||||
|
||||
for file in arguments:
|
||||
for file in listed:
|
||||
|
||||
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)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:v -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
|
||||
47
bulk_covert_drop_5_1_audio_movie.py
Normal file
47
bulk_covert_drop_5_1_audio_movie.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
output_folder_name = "/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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 listed:
|
||||
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
# opus audio - might not work for surround -
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:v -c:v libx265 -preset slow -crf 14.5 -x265-params "no-sao=1:bframes=8:psy-rd=1.5:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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")
|
||||
@@ -2,13 +2,19 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
output_folder_name = "/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
skipto = ""
|
||||
duration = ""
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
@@ -23,12 +29,12 @@ if not isExist:
|
||||
os.makedirs(output_path+output_folder_name)
|
||||
|
||||
|
||||
for file in sys.argv:
|
||||
for file in listed:
|
||||
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
# opus audio - might not work for surround -
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:v -c:v copy -map 0:a:0 -c:a libopus -b:a 192 -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 copy -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)
|
||||
#arg_list = "".join(map(str, arguments))
|
||||
print(args)
|
||||
#print(each)
|
||||
|
||||
45
bulk_covert_drop_movie.py
Normal file
45
bulk_covert_drop_movie.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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 listed:
|
||||
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:v -c:v libx265 -preset slow -crf 14.9 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
subprocess.run(args)
|
||||
|
||||
|
||||
k=input("press close to exit")
|
||||
98
bulk_threading_test.py
Normal file
98
bulk_threading_test.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -analyzeduration 20000000 -probesize 20000000 -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0? -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
98
bulk_threading_test_2_1_audio.py
Normal file
98
bulk_threading_test_2_1_audio.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -analyzeduration 20000000 -probesize 20000000 -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -pix_fmt yuv420p10le -map 0:a? -c:a aac -ac 3 -b:a 256k -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
98
bulk_threading_test_5_1_audio.py
Normal file
98
bulk_threading_test_5_1_audio.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map_metadata -1 -map 0:t? -map 0:v:0? -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -pix_fmt yuv420p10le -map 0:a -c:a libopus -b:a 576k -ac 6 -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
98
bulk_threading_test_5_1_audio_movie.py
Normal file
98
bulk_threading_test_5_1_audio_movie.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map_metadata -1 -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 14.7 -x265-params "no-sao=1:bframes=8:psy-rd=2.5:psy-rdoq=4:aq-mode=3:ref=6:deblock=-1,-1" -pix_fmt yuv420p10le -map 0:a? -c:a libopus -ac 6 -b:a 768k -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
99
bulk_threading_test_audio_only.py
Normal file
99
bulk_threading_test_audio_only.py
Normal file
@@ -0,0 +1,99 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mka)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
#51: -c:a libopus -ac 6 -b:a 576k - standard -c:a libopus -b:a 192k
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:v:0? -c:v copy -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
99
bulk_threading_test_audio_only_5_1.py
Normal file
99
bulk_threading_test_audio_only_5_1.py
Normal file
@@ -0,0 +1,99 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
#51: -c:a libopus -ac 6 -b:a 576k - standard -c:a libopus -b:a 192k
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:t? -map 0:v:0? -c:v copy -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
104
bulk_threading_test_audio_only_5_1_add_metadata.py
Normal file
104
bulk_threading_test_audio_only_5_1_add_metadata.py
Normal file
@@ -0,0 +1,104 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
#output_path = head_tail[0]
|
||||
|
||||
output_path = "F:/temp"
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
#51: -c:a libopus -ac 6 -b:a 576k - standard -c:a libopus -b:a 192k
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:t? -map 0:v:0 -c:v copy -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "E:/Projects/python/ffmpeg_work_folder/bulk_convert_out/mvkmergedupdated/{basename}" "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
subprocess.run(arg_list)
|
||||
print(output_path+output_folder_name+basename)
|
||||
os.remove(output_path+output_folder_name+basename)
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
104
bulk_threading_test_audio_only_5_1_add_metadataHQ.py
Normal file
104
bulk_threading_test_audio_only_5_1_add_metadataHQ.py
Normal file
@@ -0,0 +1,104 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
#output_path = head_tail[0]
|
||||
|
||||
output_path = "F:/temp"
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
#51: -c:a libopus -ac 6 -b:a 576k - standard -c:a libopus -b:a 192k
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:t? -map 0:v:0? -c:v copy -map 0:a -c:a libopus -ac 6 -b:a 768k -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "E:/Projects/python/ffmpeg_work_folder/bulk_convert_out/mvkmergedupdated/{basename}" "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
subprocess.run(arg_list)
|
||||
print(output_path+output_folder_name+basename)
|
||||
os.remove(output_path+output_folder_name+basename)
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
99
bulk_threading_test_audio_only_7_1.py
Normal file
99
bulk_threading_test_audio_only_7_1.py
Normal file
@@ -0,0 +1,99 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
#51: -c:a libopus -ac 6 -b:a 576k - standard -c:a libopus -b:a 192k
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:t? -map 0:v:0? -c:v copy -map 0:a -c:a libopus -ac 8 -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
104
bulk_threading_test_audio_only_add_metadata.py
Normal file
104
bulk_threading_test_audio_only_add_metadata.py
Normal file
@@ -0,0 +1,104 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
#output_path = head_tail[0]
|
||||
|
||||
output_path = "F:/temp"
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
#51: -c:a libopus -ac 6 -b:a 576k - standard -c:a libopus -b:a 192k
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:t? -map 0:v:0 -c:v copy -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "E:/Projects/python/ffmpeg_work_folder/bulk_convert_out/mvkmergedupdated/{basename}" "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
subprocess.run(arg_list)
|
||||
print(output_path+output_folder_name+basename)
|
||||
os.remove(output_path+output_folder_name+basename)
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
112
bulk_threading_test_by_file.py
Normal file
112
bulk_threading_test_by_file.py
Normal file
@@ -0,0 +1,112 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="test.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+') as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "{output_path}{output_folder_name}/mvkmergedupdated/{basename}" "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(arg_list)
|
||||
merg_results = subprocess.Popen(arg_list)
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if i < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
111
bulk_threading_test_by_file5_1.py
Normal file
111
bulk_threading_test_by_file5_1.py
Normal file
@@ -0,0 +1,111 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="test5_1.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+') as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "{output_path}{output_folder_name}/mvkmergedupdated/{basename}" "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(arg_list)
|
||||
merg_results = subprocess.Popen(arg_list)
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if i < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
111
bulk_threading_test_by_file5_1_movie.py
Normal file
111
bulk_threading_test_by_file5_1_movie.py
Normal file
@@ -0,0 +1,111 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="test5_1.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+') as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 14.9 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "{output_path}{output_folder_name}/mvkmergedupdated/{basename}" "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(arg_list)
|
||||
merg_results = subprocess.Popen(arg_list)
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if i < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
109
bulk_threading_test_by_file_crop_video.py
Normal file
109
bulk_threading_test_by_file_crop_video.py
Normal file
@@ -0,0 +1,109 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="test.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+') as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -vf crop=1920:816:0:132 -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if i < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
109
bulk_threading_test_by_file_crop_video_5_1.py
Normal file
109
bulk_threading_test_by_file_crop_video_5_1.py
Normal file
@@ -0,0 +1,109 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="test5_1.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+') as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -vf crop=1920:816:0:132 -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if i < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
111
bulk_threading_test_by_file_metadata_only.py
Normal file
111
bulk_threading_test_by_file_metadata_only.py
Normal file
@@ -0,0 +1,111 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="mkv_merge_paths_to_update.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+', encoding="utf8") as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
#args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
#print(args)
|
||||
#results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
#data = results.wait()
|
||||
arg_list = 'mkvmerge.exe --output "E:/Projects/python/ffmpeg_work_folder/bulk_convert_out/mvkmergedupdated/{basename}" "{file}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(arg_list)
|
||||
merg_results = subprocess.Popen(arg_list)
|
||||
data = merg_results.wait()
|
||||
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if i < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
110
bulk_threading_test_by_file_video_only.py
Normal file
110
bulk_threading_test_by_file_video_only.py
Normal file
@@ -0,0 +1,110 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
file="test_vidonly.txt"
|
||||
|
||||
max_threads=int(input("max threads: "))
|
||||
print(type(max_threads))
|
||||
u=0
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
def read_file(path=""):
|
||||
with open(file,'r+') as f:
|
||||
path = f.readlines(1)
|
||||
all = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.writelines(all)
|
||||
return path
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self, input_file=""):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.input_file = input_file
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global u
|
||||
global finished_count
|
||||
file = str(input_file[0])
|
||||
file = file.rstrip("\n")
|
||||
basename=os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:t? -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -pix_fmt yuv420p10le -map 0:a -c:a copy -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
u=u-1
|
||||
|
||||
|
||||
|
||||
filesize = os.path.getsize(file)
|
||||
while filesize != 0:
|
||||
if u < max_threads:
|
||||
global self
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
input_file = read_file()
|
||||
print(input_file)
|
||||
t1 = CustomThread(input_file)
|
||||
t1.start()
|
||||
if filesize == 0:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished","out of", )
|
||||
sleep(1)
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking while")
|
||||
break
|
||||
filesize = os.path.getsize(file)
|
||||
if filesize != 0:
|
||||
print("breaking if")
|
||||
continue
|
||||
t1.join()
|
||||
print("Completed","out of", "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
u=u+1
|
||||
|
||||
else:
|
||||
print("Finished ","out of ")
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
98
bulk_threading_test_copy_audio.py
Normal file
98
bulk_threading_test_copy_audio.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -analyzeduration 20000000 -probesize 20000000 -i "{file}" -fps_mode passthrough -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -pix_fmt yuv420p10le -map 0:a -c:a copy -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
98
bulk_threading_test_no_subs.py
Normal file
98
bulk_threading_test_no_subs.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map 0:v:0 -c:v libx265 -preset slow -crf 15.4 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
98
bulk_threading_testcrf_18.py
Normal file
98
bulk_threading_testcrf_18.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -analyzeduration 20000000 -probesize 20000000 -i "{file}" -fps_mode passthrough -map 0:v:0 -c:v libx265 -preset slow -crf 18 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, creationflags=0x00004000, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
51
combine.py
Normal file
51
combine.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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)
|
||||
|
||||
print("printing listed", listed)
|
||||
edited_list = ['-i "' + s +'"' for s in listed]
|
||||
print("printing edited list", edited_list)
|
||||
joined_list =' '.join(map(str, edited_list))
|
||||
print(joined_list)
|
||||
for file in edited_list:
|
||||
|
||||
#
|
||||
print("printng file", file)
|
||||
#args = 'ffmpeg.exe -i "{file}" -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)
|
||||
#print(args)
|
||||
basename = os.path.basename(listed[0])
|
||||
print(basename)
|
||||
args = 'ffmpeg.exe {joined_list} -c copy -f matroska "{output_path}{output_folder_name}{basename}"'.format(joined_list=joined_list, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(args)
|
||||
subprocess.run(args)
|
||||
k=input("press close to exit")
|
||||
@@ -1,44 +0,0 @@
|
||||
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]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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)
|
||||
|
||||
i=1
|
||||
x=5
|
||||
while i < x:
|
||||
|
||||
for file in arguments:
|
||||
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
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)
|
||||
print(args)
|
||||
subprocess.run(args, returncode=0)
|
||||
print(subprocess.CompletedProcess)
|
||||
|
||||
i=i+1
|
||||
|
||||
k=input("press close to exit")
|
||||
@@ -1,89 +0,0 @@
|
||||
from multiprocessing.connection import wait
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
#droppedFile = sys.argv[1]
|
||||
#droppedName = Path(droppedFile).name
|
||||
|
||||
skipto = ""
|
||||
duration = ""
|
||||
|
||||
#print(droppedName)
|
||||
droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
arguments = droppedFile
|
||||
|
||||
#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)
|
||||
x=3
|
||||
i=0
|
||||
org_count = len(arguments)
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.ret = None
|
||||
|
||||
def run(self):
|
||||
#sleep(1)
|
||||
global i
|
||||
file=arguments.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset veryfast -crf 22 -map 0:a -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
streeamdata = results.communicate()[0]
|
||||
if results.returncode == 0:
|
||||
self.ret = 0
|
||||
print(self.ret)
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
while arguments != False:
|
||||
if i < x:
|
||||
global self
|
||||
|
||||
#streamdata= results.communicate()[0]
|
||||
if bool(arguments) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(arguments) == False:
|
||||
t1.join()
|
||||
print("Completed Successfully")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
current_threads = threading.active_count()-1
|
||||
current_left = len(arguments)
|
||||
current_count = current_threads-current_left
|
||||
print("Finished ",current_count,"out of ", org_count)
|
||||
f = open("log.txt", "a")
|
||||
f.write("entering false \n")
|
||||
f.close()
|
||||
sleep(1)
|
||||
print("continuing")
|
||||
@@ -62,6 +62,7 @@ for each in img:
|
||||
|
||||
subprocess.call(args)
|
||||
|
||||
|
||||
#clean the trash files generated
|
||||
lwi = os.listdir(output_path)
|
||||
for item in lwi:
|
||||
|
||||
84
json_parse.py
Normal file
84
json_parse.py
Normal file
@@ -0,0 +1,84 @@
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
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:]
|
||||
audio_list = []
|
||||
sub_list = []
|
||||
|
||||
|
||||
# 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 = ['E:\\Projects\\python\\ffmpeg_work_folder\\01 - The Great Tower of Druaga (Inner).mkv']
|
||||
|
||||
|
||||
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[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}" -show_entries format:streams -of xml'.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()[0]
|
||||
|
||||
print("file", i+1,":", Path(file).name)
|
||||
|
||||
print(subprocess_err)
|
||||
|
||||
root = ET.fromstring(subprocess_err)
|
||||
|
||||
#print(root)
|
||||
streams = root[1].findall("stream")
|
||||
|
||||
print(streams)
|
||||
|
||||
for stream in streams:
|
||||
if stream.get("codec_type") == "audio":
|
||||
index = stream.get("index")
|
||||
print("index:", stream.get("index"))
|
||||
print("channels:",stream.get("channels"))
|
||||
print("printing index variable:" ,index )
|
||||
|
||||
for tag in stream.findall("tag"):
|
||||
if tag.get("key") == "title":
|
||||
print("name:", tag.get("value"))
|
||||
if tag.get("key") == "BPS":
|
||||
print("BPS:",tag.get("value"))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ audio_list = []
|
||||
sub_list = []
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
@@ -38,6 +41,8 @@ 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)
|
||||
@@ -78,6 +83,7 @@ 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 listed:
|
||||
print("listed printing again: ", listed)
|
||||
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)
|
||||
|
||||
56
mkvmerge_metadataupdate.py
Normal file
56
mkvmerge_metadataupdate.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
output_folder_name = "\mkvmerge_out\\"
|
||||
regex_subtitle = re.compile("Stream #0:\d+(\(\w*\))?: Subtitle:.*")
|
||||
regex_audio = re.compile("Stream #0:\d+(\(\w*\))?: Audio:.*")
|
||||
nr_files = 0
|
||||
files_processed = []
|
||||
audio_list = []
|
||||
sub_list = []
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
|
||||
|
||||
#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
|
||||
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[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 listed:
|
||||
basename = os.path.basename(file)
|
||||
|
||||
arg_list = 'mkvmerge.exe --output "{output_path}{output_folder_name}{basename}" "{file}"'.format(file=file, 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")
|
||||
@@ -23,7 +23,7 @@ if not isExist:
|
||||
|
||||
#droppedFile = ["sam_overlord_bluraysource.mkv"]
|
||||
|
||||
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"
|
||||
lines = "-map 0:v -c:v libx265 -preset slow -crf 14.7 -x265-params level=51:no-sao=1:bframes=8:psy-rd=1.5:psy-rdoq=1.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"
|
||||
|
||||
|
||||
|
||||
88
quality_test_new.py
Normal file
88
quality_test_new.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from ast import Num
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
output_folder_name = "/quality_test_out/"
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile = ['ORIGINAL_COMP_0Episode 00 - Ninovo.mkv']
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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)
|
||||
|
||||
#droppedFile = ["sam_overlord_bluraysource.mkv"]
|
||||
|
||||
def subproc_ffmpeg(file="",crf_value="", output_path="", output_folder_name=""):
|
||||
basename = os.path.basename(file)
|
||||
print(basename)
|
||||
print(file)
|
||||
print("printing output path: ", output_path)
|
||||
print("printing folder_name: ", output_folder_name)
|
||||
return 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset slow -crf "{crf_value}" -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.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}crf-{crf_value}_{basename}"'.format(file=file, crf_value=crf_value, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
|
||||
print("CRF granuality? 1 or 0.1: ")
|
||||
while True:
|
||||
crf_gran=float(input("> "))
|
||||
if crf_gran == 1:
|
||||
large_gran = True
|
||||
print("Stepping in whole values")
|
||||
break
|
||||
if crf_gran == 0.1:
|
||||
large_gran = False
|
||||
print("stepping in decimal values")
|
||||
break
|
||||
print("Invalid choice, try again")
|
||||
|
||||
|
||||
|
||||
|
||||
crf_range = [int(z) for z in input ("CRF range to test? Seperate with dash (eg: 15-17): ").split('-')]
|
||||
print(crf_range)
|
||||
if large_gran == True:
|
||||
while crf_range[0] <= crf_range[1]:
|
||||
crf_value = crf_range[0]
|
||||
for file in listed:
|
||||
|
||||
subprocess.run(subproc_ffmpeg(file, crf_value, output_path, output_folder_name), creationflags=0x00004000)
|
||||
crf_range[0] += 1
|
||||
if large_gran == False:
|
||||
while crf_range[0] < crf_range[1]:
|
||||
crf_value = round(crf_range[0], 1)
|
||||
for file in listed:
|
||||
|
||||
subprocess.run(subproc_ffmpeg(file, crf_value, output_path, output_folder_name))
|
||||
crf_range[0] += 0.1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
input("press enter to exit")
|
||||
88
quality_test_new5_1.py
Normal file
88
quality_test_new5_1.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from ast import Num
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
output_folder_name = "/quality_test_out/"
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
#droppedFile = ['ORIGINAL_COMP_0Episode 00 - Ninovo.mkv']
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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)
|
||||
|
||||
#droppedFile = ["sam_overlord_bluraysource.mkv"]
|
||||
|
||||
def subproc_ffmpeg(file="",crf_value="", output_path="", output_folder_name=""):
|
||||
basename = os.path.basename(file)
|
||||
print(basename)
|
||||
print(file)
|
||||
print("printing output path: ", output_path)
|
||||
print("printing folder_name: ", output_folder_name)
|
||||
return 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset slow -crf "{crf_value}" -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6" -pix_fmt yuv420p10le -map 0:a -c:a libopus -ac 6 -b:a 576k -f matroska "{output_path}{output_folder_name}crf-{crf_value}_{basename}"'.format(file=file, crf_value=crf_value, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
|
||||
print("CRF granuality? 1 or 0.1: ")
|
||||
while True:
|
||||
crf_gran=float(input("> "))
|
||||
if crf_gran == 1:
|
||||
large_gran = True
|
||||
print("Stepping in whole values")
|
||||
break
|
||||
if crf_gran == 0.1:
|
||||
large_gran = False
|
||||
print("stepping in decimal values")
|
||||
break
|
||||
print("Invalid choice, try again")
|
||||
|
||||
|
||||
|
||||
|
||||
crf_range = [int(z) for z in input ("CRF range to test? Seperate with dash (eg: 15-17): ").split('-')]
|
||||
print(crf_range)
|
||||
if large_gran == True:
|
||||
while crf_range[0] <= crf_range[1]:
|
||||
crf_value = crf_range[0]
|
||||
for file in listed:
|
||||
|
||||
subprocess.run(subproc_ffmpeg(file, crf_value, output_path, output_folder_name))
|
||||
crf_range[0] += 1
|
||||
if large_gran == False:
|
||||
while crf_range[0] < crf_range[1]:
|
||||
crf_value = round(crf_range[0], 1)
|
||||
for file in listed:
|
||||
|
||||
subprocess.run(subproc_ffmpeg(file, crf_value, output_path, output_folder_name), creationflags=0x00004000)
|
||||
crf_range[0] += 0.1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
input("press enter to exit")
|
||||
144
quality_test_new_threading.py
Normal file
144
quality_test_new_threading.py
Normal file
@@ -0,0 +1,144 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
import re
|
||||
|
||||
|
||||
|
||||
max_threads=4
|
||||
i=0
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
#droppedFile = sys.argv[1]
|
||||
#droppedName = Path(droppedFile).name
|
||||
#originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
#joined = (' '.join(originalfiles))
|
||||
#re.sub (' +', ' ', joined)
|
||||
#listed = re.split(r'(.+?mkv)', joined)
|
||||
#listed = list(filter(None, listed))
|
||||
#listed = [i.lstrip() for i in listed]
|
||||
|
||||
listed= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
#arguments = droppedFile
|
||||
|
||||
#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)
|
||||
|
||||
org_count = len(listed)
|
||||
finished_count = int()
|
||||
|
||||
def subproc_ffmpeg(file="",crf_value="", output_path="", output_folder_name=""):
|
||||
basename = os.path.basename(file)
|
||||
print(basename)
|
||||
print(file)
|
||||
print("printing output path: ", output_path)
|
||||
print("printing folder_name: ", output_folder_name)
|
||||
return 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset slow -crf "{crf_value}" -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.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}crf-{crf_value}_{basename}"'.format(file=file, crf_value=crf_value, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
|
||||
|
||||
|
||||
print("CRF granuality? 1 or 0.1: ")
|
||||
while True:
|
||||
crf_gran=float(input("> "))
|
||||
if crf_gran == 1:
|
||||
large_gran = True
|
||||
print("Stepping in whole values")
|
||||
break
|
||||
if crf_gran == 0.1:
|
||||
large_gran = False
|
||||
print("stepping in decimal values")
|
||||
break
|
||||
print("Invalid choice, try again")
|
||||
|
||||
|
||||
|
||||
|
||||
crf_range = [int(z) for z in input ("CRF range to test? Seperate with dash (eg: 15-17): ").split('-')]
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
#sleep(1)
|
||||
global i
|
||||
global finished_count
|
||||
global large_gran
|
||||
global crf_range
|
||||
file=listed.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
if large_gran == True:
|
||||
while crf_range[0] <= crf_range[1]:
|
||||
crf_value = crf_range[0]
|
||||
for file in listed:
|
||||
|
||||
subprocess.run(subproc_ffmpeg(file, crf_value, output_path, output_folder_name))
|
||||
crf_range[0] += 1
|
||||
if large_gran == False:
|
||||
while crf_range[0] < crf_range[1]:
|
||||
crf_value = round(crf_range[0], 1)
|
||||
for file in listed:
|
||||
|
||||
subprocess.run(subproc_ffmpeg(file, crf_value, output_path, output_folder_name))
|
||||
crf_range[0] += 0.1
|
||||
|
||||
|
||||
#args = 'ffmpeg.exe -i "{file}" -fps_mode passthrough -map_metadata -1 -map 0:v:0 -c:v libx265 -preset slow -crf 14.5 -x265-params "no-sao=1:bframes=8:psy-rd=2:psy-rdoq=1.5:aq-mode=3:ref=6:deblock=-1,-1" -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)
|
||||
# print(args)
|
||||
#results = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
#streeamdata = results.communicate()[0]
|
||||
#data = results.wait()
|
||||
|
||||
|
||||
if data == 0:
|
||||
i=i-1
|
||||
finished_count=finished_count+1
|
||||
|
||||
|
||||
|
||||
while listed != False:
|
||||
if i < max_threads:
|
||||
global self
|
||||
|
||||
if bool(listed) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(listed) == False:
|
||||
while bool(threading.active_count() > 1):
|
||||
print("Finished",finished_count,"out of", org_count," ")
|
||||
sleep(1)
|
||||
t1.join()
|
||||
print("Completed",finished_count,"out of",org_count, "inputs Successfully")
|
||||
input("waiting")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
print("Finished ",finished_count,"out of ", org_count)
|
||||
sleep(1)
|
||||
print("continuing ")
|
||||
@@ -3,7 +3,7 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
output_folder_name = "/quality_test_out/"
|
||||
output_folder_name = "/quality_test_originals/"
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
|
||||
@@ -23,8 +23,8 @@ if not isExist:
|
||||
#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"
|
||||
#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=1.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 copy -map 0:a? -c:a copy -map 0:s? -c:s copy"
|
||||
|
||||
|
||||
number_of_segments=int(input("Number of segments: "))
|
||||
@@ -54,9 +54,9 @@ for i, file in enumerate(arguments):
|
||||
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)
|
||||
args = 'ffmpeg.exe -ss {time} -i "{file}" -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)
|
||||
run = subprocess.Popen(args, creationflags=0x00004000)
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
sauce.webm
Normal file
BIN
sauce.webm
Normal file
Binary file not shown.
@@ -44,7 +44,7 @@ for i, file in enumerate(arguments):
|
||||
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)
|
||||
args = 'ffmpeg.exe -ss {time} -itsoffset -2 -i "{file}" -frames:v 1 -q:v 1 "{output_path}{output_folder_name}{basename}{i}.jpeg"'.format(time=skip*i+time, file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename, i=i)
|
||||
print(args)
|
||||
run = subprocess.Popen(args)
|
||||
|
||||
|
||||
58
screenshot_drop_scale1080p.py
Normal file
58
screenshot_drop_scale1080p.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
output_folder_name = "/screenshots/"
|
||||
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]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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)
|
||||
|
||||
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]
|
||||
|
||||
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* 15)) / (number_of_ss -1)
|
||||
for i in range(0, number_of_ss):
|
||||
|
||||
basename = os.path.basename(file)
|
||||
args = 'ffmpeg.exe -ss {time} -i "{file}" -frames:v 1 -vf scale=1920:-1 -q:v 1 "{output_path}{output_folder_name}{basename}{i}.jpeg"'.format(time=skip*i+time, file=file, 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")
|
||||
58
screenshot_drop_scale2160p.py
Normal file
58
screenshot_drop_scale2160p.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
output_folder_name = "/screenshots/"
|
||||
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]
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
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)
|
||||
|
||||
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]
|
||||
|
||||
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* 15)) / (number_of_ss -1)
|
||||
for i in range(0, number_of_ss):
|
||||
|
||||
basename = os.path.basename(file)
|
||||
args = 'ffmpeg.exe -ss {time} -i "{file}" -frames:v 1 -vf scale=3840:-1 -q:v 1 "{output_path}{output_folder_name}{basename}{i}.jpeg"'.format(time=skip*i+time, file=file, 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")
|
||||
@@ -5,7 +5,7 @@ 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:.*")
|
||||
regex_audio = re.compile("Stream #0:\d+(\(\w*\))?: Audio:.*")
|
||||
nr_files = 0
|
||||
files_processed = []
|
||||
droppedFile = sys.argv[1]
|
||||
|
||||
99
sub_audio_remover.py
Normal file
99
sub_audio_remover.py
Normal file
@@ -0,0 +1,99 @@
|
||||
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:]
|
||||
audio_list = []
|
||||
sub_list = []
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
|
||||
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[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)
|
||||
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')
|
||||
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))
|
||||
audio_list.append(match.group(0))
|
||||
for r, match in enumerate(regex_subtitle.finditer(subprocess_err)):
|
||||
print("Subtitle Track", r,": ", match.group(0))
|
||||
sub_list.append(match.group(0))
|
||||
print('\n')
|
||||
|
||||
print("Tally for audio tracks: ", "\n")
|
||||
my_dict = {i:audio_list.count(i) for i in audio_list}
|
||||
for key, value in my_dict.items():
|
||||
print(key, ' : ', value)
|
||||
print()
|
||||
print("Tally for subtitle tracks tracks: ", "\n")
|
||||
my_dict = {i:sub_list.count(i) for i in sub_list}
|
||||
for key, value in my_dict.items():
|
||||
print(key, ' : ', value)
|
||||
|
||||
|
||||
|
||||
|
||||
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 listed:
|
||||
print("listed printing again: ", listed)
|
||||
basename = os.path.basename(file)
|
||||
|
||||
arg_list = 'ffmpeg.exe -i "{file}" -map 0:t? -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")
|
||||
35
trim.py
Normal file
35
trim.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
|
||||
|
||||
print(listed)
|
||||
for each in listed:
|
||||
arglist = ('ffprobe.exe -v error -show_entries format=duration -of csv=p=0 {each}').format(each=each)
|
||||
cmd = subprocess.Popen(arglist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
|
||||
out = cmd.communicate()[0]
|
||||
|
||||
out = out.strip()
|
||||
|
||||
duration = float(out)
|
||||
|
||||
duration -= 4
|
||||
basename = os.path.basename(each)
|
||||
trim = ('ffmpeg.exe -ss 00:00:00 -to {duration} -i {each} -c copy "trimed"{basename}').format(duration=duration, each=each, basename=basename)
|
||||
subprocess.run(trim)
|
||||
74
vp9_discord8MB.py
Normal file
74
vp9_discord8MB.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
import math
|
||||
ffmpeg_location = "D:/FFMPEG/bin/ffmpeg.exe"
|
||||
ffprobe_location = "D:/FFMPEG/bin/ffprobe.exe"
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
#total filesize allowed in kilobits
|
||||
total_max_bits = 75000
|
||||
|
||||
|
||||
|
||||
droppedFile = sys.argv[1]
|
||||
droppedName = Path(droppedFile).name
|
||||
originalfiles = sys.orig_argv[2:]
|
||||
|
||||
#long path shenanigans
|
||||
joined = (' '.join(originalfiles))
|
||||
re.sub (' +', ' ', joined)
|
||||
listed = re.split(r'(.+?mkv)', joined)
|
||||
listed = list(filter(None, listed))
|
||||
listed = [i.lstrip() for i in listed]
|
||||
|
||||
print(droppedName)
|
||||
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
#get location of input file
|
||||
inpath = os.path.split(sys.argv[1])
|
||||
outpath = inpath[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
arguments = sys.argv[1:]
|
||||
|
||||
|
||||
|
||||
for i, file in enumerate(arguments):
|
||||
|
||||
arg_list = '{ffprobe_location} -show_entries format=duration -i "{file}"'.format(ffprobe_location=ffprobe_location, 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")
|
||||
|
||||
|
||||
avg_audiorate = video_duration * 68
|
||||
max_bitrate = (total_max_bits - avg_audiorate) / video_duration
|
||||
print(max_bitrate)
|
||||
avg_bitrate = 0.7*max_bitrate
|
||||
max_bitrate = math.floor(max_bitrate)
|
||||
avg_bitrate = math.floor(avg_bitrate)
|
||||
print(avg_audiorate)
|
||||
|
||||
print(max_bitrate)
|
||||
print(avg_bitrate)
|
||||
|
||||
basename = Path(file).stem
|
||||
ffmpeg_args = '{ffmpeg_location} -i "{file}" -c:v libvpx-vp9 -vf "fps=30,scale=1280:-2" -b:v {avg_bitrate}k -maxrate {max_bitrate}k -bufsize 2M -pass 1 -threads 16 -speed 4 -row-mt 1 -tile-rows 2 -tile-columns 6 -f null NUL'.format(ffmpeg_location=ffmpeg_location, file=file, avg_bitrate=avg_bitrate, max_bitrate=max_bitrate)
|
||||
cmd = subprocess.call(ffmpeg_args)
|
||||
|
||||
ffmpeg_args = '{ffmpeg_location} -i "{file}" -c:v libvpx-vp9 -vf "fps=30,scale=1280:-2" -b:v {avg_bitrate}k -maxrate {max_bitrate}k -bufsize 2M -c:a libopus -b:a 68k -pass 2 -threads 16 -speed 4 -row-mt 1 -tile-rows 2 -tile-columns 6 -f webm "{outpath}\{basename}.webm"'.format(ffmpeg_location=ffmpeg_location, file=file, avg_bitrate=avg_bitrate, max_bitrate=max_bitrate,outpath=outpath, basename=basename)
|
||||
cmd = subprocess.call(ffmpeg_args)
|
||||
|
||||
input()
|
||||
Reference in New Issue
Block a user