possible fix for upscaler & removal of lib

This commit is contained in:
2023-03-16 09:42:11 +01:00
parent 459963faff
commit d12182e8c6
4 changed files with 62 additions and 6 deletions

Binary file not shown.

View File

@@ -10,8 +10,8 @@
import os
import sys
import bin.lib.ffmpeg
ffmpeg = bin.lib.ffmpeg
import bin.probe
ffmpeg = bin.probe
import configparser
import time
import shutil
@@ -69,7 +69,7 @@ class Handler:
if self.os_type == "linux":
self.command = f"wine {fsrpath} -QualityMode {quality_setting} {self.filepath} {output_path}"
elif self.os_type == "win32":
self.command = f"{fsrpath} -QualityMode {quality_setting} {self.filepath} {output_path}"
self.command = f"FidelityFX_CLI -QualityMode {quality_setting} {self.filepath} {output_path}"
else:
print("OS CURRENTLY UNSUPPORTED!")
return False
@@ -79,7 +79,7 @@ class Handler:
if self.os_type == "linux":
self.command = f"wine {fsrpath} -Scale {quality_setting} {quality_setting} {self.filepath} {output_path}"
elif self.os_type == "win32":
self.command = f"{fsrpath} -Scale {quality_setting} {quality_setting} {self.filepath} {output_path}"
self.command = f"FidelityFX_CLI -Scale {quality_setting} {quality_setting} {self.filepath} {output_path}"
else:
print("OS CURRENTLY UNSUPPORTED!")
return False
@@ -190,7 +190,7 @@ class Handler:
if self.os_type == "linux":
self.command = f"wine {fsrpath} -QualityMode {quality_setting} {self.files_handle}"
elif self.os_type == "win32":
self.command = f"{fsrpath} -QualityMode {quality_setting} {self.files_handle}"
self.command = f"FidelityFX_CLI -QualityMode {quality_setting} {self.files_handle}"
else:
print("OS CURRENTLY UNSUPPORTED!")
return False
@@ -199,7 +199,7 @@ class Handler:
if self.os_type == "linux":
self.command = f"wine {fsrpath} -Scale {quality_setting} {self.files_handle} {self.tmppath}"
elif self.os_type == "win32":
self.command = f"{fsrpath} -Scale {quality_setting} {self.files_handle} {self.tmppath}"
self.command = f"FidelityFX_CLI -Scale {quality_setting} {self.files_handle} {self.tmppath}"
else:
print("OS CURRENTLY UNSUPPORTED!")
return False

56
bin/probe.py Normal file
View File

@@ -0,0 +1,56 @@
import json
import subprocess
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
def convert_kwargs_to_cmd_line_args(kwargs):
"""Helper function to build command line arguments out of dict."""
args = []
for k in sorted(kwargs.keys()):
v = kwargs[k]
if isinstance(v, Iterable) and not isinstance(v, str):
for value in v:
args.append('-{}'.format(k))
if value is not None:
args.append('{}'.format(value))
continue
args.append('-{}'.format(k))
if v is not None:
args.append('{}'.format(v))
return args
class Error(Exception):
def __init__(self, cmd, stdout, stderr):
super(Error, self).__init__(
'{} error (see stderr output for detail)'.format(cmd)
)
self.stdout = stdout
self.stderr = stderr
def probe(filename, cmd='ffprobe', timeout=None, **kwargs):
"""Run ffprobe on the specified file and return a JSON representation of the output.
Raises:
:class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code,
an :class:`Error` is returned with a generic error message.
The stderr output can be retrieved by accessing the
``stderr`` property of the exception.
"""
args = [cmd, '-show_format', '-show_streams', '-of', 'json']
args += convert_kwargs_to_cmd_line_args(kwargs)
args += [filename]
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
communicate_kwargs = {}
if timeout is not None:
communicate_kwargs['timeout'] = timeout
out, err = p.communicate(**communicate_kwargs)
if p.returncode != 0:
raise Error('ffprobe', out, err)
return json.loads(out.decode('utf-8'))
__all__ = ['probe']