Update fsrimagevideoupscaler-cli.py

Possible fix for crash on Windows
This commit is contained in:
Janis Hutz
2023-03-28 08:29:37 +02:00
committed by GitHub
parent b3a83fdbad
commit 0f05d650f0

View File

@@ -10,7 +10,7 @@
import argparse import argparse
import bin.handler import bin.handler
import os import os
import time import multiprocessing
ap = argparse.ArgumentParser( description='FSRImageVideoUpscaler - CLI' ) ap = argparse.ArgumentParser( description='FSRImageVideoUpscaler - CLI' )
ap.add_argument( 'inputfile', help='File path for the video / image to be upscaled' ) ap.add_argument( 'inputfile', help='File path for the video / image to be upscaled' )
@@ -23,25 +23,27 @@ handler = bin.handler.Handler()
go = True; go = True;
if ( os.path.exists( args.outputfile ) ): if __name__ == '__main__':
if ( input( 'File already exists. Do you want to replace it? (y/n) ' ).lower() == 'y' ): multiprocessing.freeze_support();
go = True if ( os.path.exists( args.outputfile ) ):
os.remove( args.outputfile ); if ( input( 'File already exists. Do you want to replace it? (y/n) ' ).lower() == 'y' ):
else: go = True
print( '\nRefusing to Upscale video. Please delete the file or specify another filepath!') os.remove( args.outputfile );
go = False else:
print( '\nRefusing to Upscale video. Please delete the file or specify another filepath!')
go = False
if ( go ): if ( go ):
if ( args.scalefactor ): if ( args.scalefactor ):
if ( args.scalefactor[ len(args.scalefactor) -1: ] == 'x' ): if ( args.scalefactor[ len(args.scalefactor) -1: ] == 'x' ):
if ( args.threads != None ): if ( args.threads != None ):
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile, threads=int( args.threads ) ); handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile, threads=int( args.threads ) );
else:
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile );
else: else:
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', args.scalefactor, args.outputfile ); raise NameError( 'Argument Scale does require to be of form 2x! (it has to end in x)' )
else: else:
raise NameError( 'Argument Scale does require to be of form 2x! (it has to end in x)' ) if ( args.threads != None ):
else: handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile, threads=int( args.threads ) );
if ( args.threads != None ): else:
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile, threads=int( args.threads ) ); handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile )
else:
handler.handler( 'bin/lib/FidelityFX_CLI.exe', args.inputfile, 'custom', '2x', args.outputfile )