possible fix for windows

This commit is contained in:
2023-03-28 14:56:54 +02:00
parent 3ed9781d27
commit be74be1bf7
2 changed files with 74 additions and 73 deletions

View File

@@ -17,6 +17,7 @@ import time
import shutil
import subprocess
import multiprocessing
import itertools
# Loading the config file to get user preferred temp path
@@ -168,7 +169,7 @@ class Handler:
time.sleep( 2 );
self.proc_list = [];
self.command_list = [];
self.file_list_length = len( self.file_list );
for i in range( self.threads ):
self.files = '';
@@ -178,13 +179,13 @@ class Handler:
if ( i == self.threads - 1 ):
for element in self.file_list:
self.files += element;
proc = multiprocessing.Process( name=i, target=self.upscalerEngine, args=( quality_mode, self.files, fsrpath, quality_setting, i, ) );
proc.start();
self.proc_list.append( proc );
self.command_list.append( ( quality_mode, self.files, fsrpath, quality_setting, i, self.maxlength, self.os_type ) )
self.pool = multiprocessing.Pool( self.threads )
self.pool.starmap( upscalerEngine, self.command_list );
self.pool.close();
self.pool.join();
# await completion of all jobs
for proc in self.proc_list:
proc.join();
# get Video's audio
print( 'Finished Upscaling individual images. \n\n\nRetrieving Video audio to append' )
@@ -217,31 +218,31 @@ class Handler:
print( '\n\n---------------------------------------------------------------------------------\n\nDONE \n\nFSRImageVideoUpscalerFrontend V1.1.0\n\nCopyright 2023 FSRImageVideoUpscalerFrontend contributors\nThis application comes with absolutely no warranty to the extent permitted by applicable law\n\n' )
def upscalerEngine ( self, quality_mode, files, fsrpath, quality_setting, number ):
def upscalerEngine ( quality_mode, files, fsrpath, quality_setting, number, maxlength, os_type ):
files = files;
# Refactoring of commands that are longer than 32K characters
fileout = [];
pos = 0;
if len( files ) > self.maxlength:
while files[self.maxlength - pos:self.maxlength - pos + 1] != ' ':
if len( files ) > maxlength:
while files[maxlength - pos:maxlength - pos + 1] != ' ':
pos += 1
file_processing = files[:self.maxlength - pos]
file_processing = files[:maxlength - pos]
if file_processing[len(file_processing) - 14:len(file_processing) - 12] == 'ex':
pos += 5
else:
pass
while files[self.maxlength - pos:self.maxlength - pos + 1] != ' ':
while files[maxlength - pos:maxlength - pos + 1] != ' ':
pos += 1
fileout.append(files[:self.maxlength - pos])
filesopt = files[self.maxlength - pos:]
fileout.append(files[:maxlength - pos])
filesopt = files[maxlength - pos:]
posx = 0
posy = self.maxlength
posy = maxlength
# Command refactoring for commands that are longer than 64K characters
if len(filesopt) > self.maxlength:
while len(filesopt) > self.maxlength:
posx += self.maxlength - pos
posy += self.maxlength - pos
if len(filesopt) > maxlength:
while len(filesopt) > maxlength:
posx += maxlength - pos
posy += maxlength - pos
pos = 1
while files[posy - pos:posy - pos + 1] != ' ':
pos += 1
@@ -258,7 +259,7 @@ class Handler:
filesopt = files[posy - pos:]
fileout.append(filesopt)
else:
fileout.append(files[self.maxlength - pos:])
fileout.append(files[maxlength - pos:])
else:
fileout.append(files)
@@ -268,17 +269,17 @@ class Handler:
while len( fileout ) > 0:
files_handle = fileout.pop(0)
if quality_mode == 'default':
if self.os_type == 'linux':
if os_type == 'linux':
command_us = f'wine {fsrpath} -QualityMode {quality_setting} {files_handle}'
elif self.os_type == 'win32':
elif os_type == 'win32':
command_us = f'FidelityFX_CLI -QualityMode {quality_setting} {files_handle}'
else:
print( 'OS CURRENTLY UNSUPPORTED!' )
return False
else:
if self.os_type == "linux":
if os_type == "linux":
command_us = f'wine {fsrpath} -Scale {quality_setting} {quality_setting} {files_handle}'
elif self.os_type == "win32":
elif os_type == "win32":
command_us = f'FidelityFX_CLI -Scale {quality_setting} {quality_setting} {files_handle}'
else:
print( 'OS CURRENTLY UNSUPPORTED!' )