This commit is contained in:
janis
2022-10-22 14:21:20 +02:00
parent 8c09ec17b9
commit 5a2005d63c
2 changed files with 18 additions and 11 deletions

View File

@@ -13,6 +13,7 @@ import sys
import ffmpeg import ffmpeg
import configparser import configparser
import time import time
import shutil
# Loading the config file to get user preferred temp path # Loading the config file to get user preferred temp path
config = configparser.ConfigParser() config = configparser.ConfigParser()
@@ -93,7 +94,7 @@ class Handler:
# Splitting video into frames # Splitting video into frames
try: try:
os.remove(self.tmppath) shutil.rmtree(self.tmppath)
except FileNotFoundError: except FileNotFoundError:
pass pass
try: try:
@@ -103,9 +104,9 @@ class Handler:
if self.os_type == "linux": if self.os_type == "linux":
print("linux") print("linux")
self.command = f"ffmpeg -i {str(self.filepath)} {self.tmppath}thumb%08d.png" self.command = f"ffmpeg -i {str(self.filepath)} {self.tmppath}ex%08d.png"
elif self.os_type == "win32": elif self.os_type == "win32":
self.command = f"{ffmpegpath} -i {str(self.filepath)} {self.tmppath}thumb%08d.png" self.command = f"{ffmpegpath} -i {str(self.filepath)} {self.tmppath}ex%08d.png"
else: else:
print("OS CURRENTLY UNSUPPORTED!") print("OS CURRENTLY UNSUPPORTED!")
return False return False
@@ -120,18 +121,17 @@ class Handler:
self.number = 0 self.number = 0
for self.file in self.filelist: for self.file in self.filelist:
self.number += 1 self.number += 1
self.files += f"{self.tmppath}{self.file} {self.tmppath}upscaled/USImage{str(self.number).zfill(8)}.png " self.files += f"{self.tmppath}{self.file} {self.tmppath}sc/ig{str(self.number).zfill(8)}.png "
self.maxlength = 32000 self.maxlength = 31900
self.pos = 1 self.pos = 1
# Refactoring of commands that are longer than 32K characters # Refactoring of commands that are longer than 32K characters
if len(self.files) > self.maxlength: if len(self.files) > self.maxlength:
self.fileout = [] self.fileout = []
while self.files[self.maxlength - self.pos:self.maxlength - self.pos + 1] != " ": while self.files[self.maxlength - self.pos:self.maxlength - self.pos + 1] != " ":
self.pos += 1 self.pos += 1
self.file_processing = self.files[:self.maxlength - self.pos] self.file_processing = self.files[:self.maxlength - self.pos]
if self.file_processing[len(self.file_processing) - 13:len(self.file_processing) - 8] == "thumb": if self.file_processing[len(self.file_processing) - 14:len(self.file_processing) - 12] == "ex":
self.pos += 5 self.pos += 5
else: else:
pass pass
@@ -151,7 +151,8 @@ class Handler:
while self.files[self.posy - self.pos:self.posy - self.pos + 1] != " ": while self.files[self.posy - self.pos:self.posy - self.pos + 1] != " ":
self.pos += 1 self.pos += 1
self.file_processing = self.files[self.posx:self.posy - self.pos] self.file_processing = self.files[self.posx:self.posy - self.pos]
if self.file_processing[len(self.file_processing) - 13:len(self.file_processing) - 8] == "thumb": print(self.file_processing[len(self.file_processing) - 14:len(self.file_processing) - 12])
if self.file_processing[len(self.file_processing) - 14:len(self.file_processing) - 12] == "ex":
self.pos += 5 self.pos += 5
else: else:
pass pass
@@ -168,7 +169,7 @@ class Handler:
self.fileout.append(self.files) self.fileout.append(self.files)
try: try:
os.mkdir(f"{self.tmppath}upscaled/") os.mkdir(f"{self.tmppath}sc/")
except FileExistsError: except FileExistsError:
pass pass
@@ -193,6 +194,7 @@ class Handler:
else: else:
print("OS CURRENTLY UNSUPPORTED!") print("OS CURRENTLY UNSUPPORTED!")
return False return False
print(self.command, "\n\n\nCOMMAND\n\n\n")
os.system(self.command) os.system(self.command)
print("Finished upscaling this section.") print("Finished upscaling this section.")
time.sleep(3) time.sleep(3)
@@ -216,9 +218,9 @@ class Handler:
# reassemble Video # reassemble Video
print("Reassembling Video... with framerate @", self.framerate) print("Reassembling Video... with framerate @", self.framerate)
if self.os_type == "linux": if self.os_type == "linux":
self.command = f"ffmpeg -framerate {self.framerate} -i {self.tmppath}upscaled/USImage%08d.png {output_path} -i {self.tmppath}audio.aac" self.command = f"ffmpeg -framerate {self.framerate} -i {self.tmppath}sc/ig%08d.png {output_path} -i {self.tmppath}audio.aac"
elif self.os_type == "win32": elif self.os_type == "win32":
self.command = f"{ffmpegpath} -framerate {self.framerate} -i {self.tmppath}upscaled/USImage%08d.png {output_path} -i {self.tmppath}audio.aac" self.command = f"{ffmpegpath} -framerate {self.framerate} -i {self.tmppath}sc/ig%08d.png {output_path} -i {self.tmppath}audio.aac"
else: else:
print("OS CURRENTLY UNSUPPORTED!") print("OS CURRENTLY UNSUPPORTED!")
return False return False

View File

@@ -250,9 +250,11 @@ class HomeWindow(Gtk.Window):
self.q = str(arg.get(self.output)) self.q = str(arg.get(self.output))
self.go = True self.go = True
if self.go: if self.go:
self.details.set_text("Starting upscaling process")
print("\n\nStarting upscaling process!\n\n") print("\n\nStarting upscaling process!\n\n")
self.info_button() self.info_button()
if self.info_response == Gtk.ResponseType.OK: if self.info_response == Gtk.ResponseType.OK:
self.details.set_text("Upscaling")
self.scaler = multiprocessing.Process(name="scaler", self.scaler = multiprocessing.Process(name="scaler",
target=handler.handler, target=handler.handler,
args=("./bin/lib/FidelityFX_CLI.exe", args=("./bin/lib/FidelityFX_CLI.exe",
@@ -263,13 +265,16 @@ class HomeWindow(Gtk.Window):
) )
self.scaler.start() self.scaler.start()
elif self.info_response == Gtk.ResponseType.CANCEL: elif self.info_response == Gtk.ResponseType.CANCEL:
self.details.set_text("Ready")
print("aborted") print("aborted")
else: else:
raise Exception raise Exception
else: else:
self.details.set_text("File-checks failed! Please check your entries!")
print("File-checks unsuccessful. Please check your entries!") print("File-checks unsuccessful. Please check your entries!")
self.checkerror() self.checkerror()
else: else:
self.details.set_text("No file specified!")
print("no file specified") print("no file specified")
self.fileerror() self.fileerror()
else: else: