added quality options and fixed bugs
This commit is contained in:
15
bin/arg_assembly.py
Normal file
15
bin/arg_assembly.py
Normal file
@@ -0,0 +1,15 @@
|
||||
class ArgAssembly:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get(self, quality):
|
||||
if quality == "2x":
|
||||
return "Performance"
|
||||
elif quality == "1.7x":
|
||||
return "Balanced"
|
||||
elif quality == "1.5x":
|
||||
return "Quality"
|
||||
elif quality == "1.3x":
|
||||
return "UltraQuality"
|
||||
else:
|
||||
raise Exception
|
||||
41
bin/checks.py
Normal file
41
bin/checks.py
Normal file
@@ -0,0 +1,41 @@
|
||||
class Checks:
|
||||
def __init__(self):
|
||||
self.custom_quality = 0.0
|
||||
self.i_file_extension = ""
|
||||
|
||||
def perform(self, quality_selection, custom_quality, input_filepath, output_filepath):
|
||||
# Call this function to perform entry checks.
|
||||
# Returns True if all checks passed, False if one or more not passed.
|
||||
if self.quality_checks(quality_selection, custom_quality) and self.file_checks(input_filepath, output_filepath):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def quality_checks(self, quality_sel, custom_q):
|
||||
if quality_sel != "Custom (will respect value below)":
|
||||
return True
|
||||
else:
|
||||
try:
|
||||
self.custom_quality = float(custom_q)
|
||||
except ValueError:
|
||||
return False
|
||||
return True
|
||||
|
||||
def file_checks(self, i_fp, o_fp):
|
||||
self.i_file_extension = str(i_fp)[len(i_fp) - 4:]
|
||||
if self.i_file_extension == ".png" or self.i_file_extension == ".jpg":
|
||||
pass
|
||||
elif self.i_file_extension == "jpeg":
|
||||
if str(i_fp)[len(i_fp) - 5:] == ".jpeg":
|
||||
pass
|
||||
else:
|
||||
return False
|
||||
elif self.i_file_extension == ".mp4" or self.i_file_extension == ".mkv":
|
||||
pass
|
||||
else:
|
||||
return False
|
||||
|
||||
if str(i_fp)[len(i_fp) - 4:] == str(o_fp)[len(o_fp) - 4:]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -47,7 +47,7 @@ class Handler:
|
||||
if str(filepath)[len(filepath) - 4:] == ".mp4" or str(filepath)[len(filepath) - 4:] == ".mkv":
|
||||
print("upscaling video")
|
||||
self.video_scaling(ffmpegpath, fsrpath, filepath, quality_mode, quality_setting, output_path)
|
||||
elif str(filepath)[len(filepath) - 4:] == ".JPG" or str(filepath)[len(filepath) - 4:] == ".png" or str(filepath)[len(filepath) - 4:] == ".jpg":
|
||||
elif str(filepath)[len(filepath) - 4:] == ".JPG" or str(filepath)[len(filepath) - 4:] == ".png" or str(filepath)[len(filepath) - 4:] == ".jpg" or str(filepath)[len(filepath) - 5:] == ".jpeg":
|
||||
print("upscaling image")
|
||||
self.photo_scaling(fsrpath, filepath, quality_mode, quality_setting, output_path)
|
||||
else:
|
||||
@@ -192,8 +192,11 @@ class Handler:
|
||||
|
||||
# get Video's audio
|
||||
print("Retrieving Video's audio to append")
|
||||
os.remove(f"{self.tmppath}audio.aac")
|
||||
os.remove(f"{output_path}")
|
||||
try:
|
||||
os.remove(f"{self.tmppath}audio.aac")
|
||||
os.remove(f"{output_path}")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
if self.os_type == "linux":
|
||||
self.command = f"ffmpeg -i {self.filepath} -vn -acodec copy {self.tmppath}audio.aac"
|
||||
elif self.os_type == "win32":
|
||||
|
||||
Reference in New Issue
Block a user