From e43a4f6546d1a6e5a2319eea33d6178d6da6417f Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 28 Mar 2023 15:12:15 +0200 Subject: [PATCH] debug code + nicer look --- bin/__pycache__/handler.cpython-310.pyc | Bin 6891 -> 7098 bytes bin/handler.py | 38 +++++++++++++----------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/bin/__pycache__/handler.cpython-310.pyc b/bin/__pycache__/handler.cpython-310.pyc index 03b6c83eb251674913aaa92ea9de40b6886dba67..1b8e39fd11573debaba6ac3dcd2eec9be56c56e1 100644 GIT binary patch delta 1951 zcmaJ?O>7%Q6rNfCtvB{MvGe0NPBL|Voy2LX76NS(Dq4ctAXJFbD6OdFdNzsk<8{}Y zB3m0-s>KBfDPqb2ML{-aI6y#1TuRTJ5E6$7A@zXxJtJ`d@!mL%5){RjX6L>4y}xhX z&i?V-*OR~B^^@BNbCpO1g0f9Fx#G;L~Xn$3%+o|Gqo`@N9&5)J$cFvrE|nqr+7 zw|t}Yb@9+Q(0j>takWY*;r=<|kX6DJK)l9X4&5PK6F>Qq^q%<9*CqPY1PzE8^{)6r zO|+FGGSAHw(>B>=p_t9A8(jRL-eEnENL4hNpc;)+RdG{I8HRmA?gNUL_n%h+9`UY! zu`=K$c2nslCHS`$$nUOsxVKKL)FJ7B9ppZ&&Gv&Oz=^Hnvr4%dCGRMmM544slBaJI zz#_`awWCsUPq;A2Y0Ttz8AoEimk*#%BkVdVs3RF1=f%LI{nI z;7cik!P^2UZ*$~YgOtc2mY#B;;6rI>7s!Ga0>9let>ArJ>=lzUxb~I}n=M(H4a3UV#%~JTd*u$i zdvE2qVKTl6>YSNpx#C5(PmARU+GY@+H8=CN)R%pY2uH09!+}-5$jWXub91iTf}Y~B z9_whAm-|)A00?J1XBk=Bv`XS<{iSe=v^A0!3+p+XiHT5hxJh2r^RkJu&g>O%=0$dS zYD&{A7Z&}7M2K8yXciK^Y1mfIcz``OVr4dY&cuE*g@TdinpXBp)p#b8Er(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rXzd=OYI zZWhWrw)L`#8H>IJ=pLyp+>QnHw~?E;Lcq%ejI5MPtHrg-vQ;fumYd}o8Q&#wL*4A3 LflH--f#3WOVz-J` diff --git a/bin/handler.py b/bin/handler.py index fb11fb2..631cdeb 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -60,10 +60,10 @@ class Handler: # Determining filetype if str(filepath)[len(filepath) - 4:] == ".mp4" or str(filepath)[len(filepath) - 4:] == ".mkv" or str(filepath)[len(filepath) - 4:] == ".MP4": - print("upscaling video") + print( '\n\n==> Upscaling video' ) self.video_scaling(fsrpath, filepath, quality_mode, quality_setting, output_path, threads) 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") + print( '\n==>upscaling image' ) self.photo_scaling(fsrpath, filepath, quality_mode, quality_setting, output_path) else: print("not supported") @@ -79,8 +79,6 @@ class Handler: else: print("OS CURRENTLY UNSUPPORTED!") return False - os.system(self.command) - print("photo upscaled") else: if self.os_type == "linux": self.command = f"wine {fsrpath} -Scale {quality_setting} {quality_setting} {self.filepath} {output_path}" @@ -88,25 +86,31 @@ class Handler: self.command = f"FidelityFX_CLI -Scale {quality_setting} {quality_setting} {self.filepath} {output_path}" else: print("OS CURRENTLY UNSUPPORTED!") - return False - os.system(self.command) - print("photo upscaled") + return False + + os.system(self.command) + print( '\n\n==>Photo upscaled' ); def video_scaling(self, fsrpath, filepath, quality_mode, quality_setting, output_path, threads): # DO NOT CALL THIS! Use Handler().handler() instead! self.videometa = ffmpeg.probe(str(filepath))["streams"].pop(0) # Retrieving Video metadata - self.duration = self.videometa.get("duration") - self.frames = self.videometa.get("nb_frames") + self.duration = self.videometa.get( 'duration' ) + self.frames = self.videometa.get( 'nb_frames' ) try: self.framerate = round(float(self.frames) / float(self.duration), 1) except TypeError: - self.infos = str(self.videometa.get("r_frame_rate")) + self.infos = str( self.videometa.get("r_frame_rate") ) + print( '\n\n=> using fallback method to get framerate' ) self.framerate = float(self.infos[:len(self.infos) - 2]) - print( '\n\nframe rate is: ', self.framerate, '\n\n' ) - print( '\n\nRunning with ', threads, ' threads\n\n' ) + print( '==> Video duration is: ', self.duration, 's' ) + print( '==> Framecount is: ', self.duration, ' frames' ) + print( '==> Frame rate is: ', self.framerate, ' FPS' ) + print( '==> Running with ', threads, ' threads\n\n' ) + + time.sleep( 2 ); # Splitting video into frames try: @@ -118,7 +122,7 @@ class Handler: except FileExistsError: pass - print("created dir") + print( '\n==> Created directory' ) if self.os_type == "linux": self.command = f"ffmpeg -i {str(self.filepath)} {self.tmppath}ex%08d.png" @@ -129,7 +133,7 @@ class Handler: return False os.system( self.command ) - print( 'video split' ) + print( '\n==> Video split ' ) # Locate Images and assemble FSR-Command self.file_list = [] @@ -165,7 +169,7 @@ class Handler: if ( threads > multiprocessing.cpu_count() ): self.threads = multiprocessing.cpu_count(); - print( f'\n\nUsing { self.threads } threads\n\n' ); + print( f'\n\n==>Using { self.threads } threads <==\n\n' ); time.sleep( 2 ); @@ -188,7 +192,7 @@ class Handler: # get Video's audio - print( 'Finished Upscaling individual images. \n\n\nRetrieving Video audio to append' ) + print( '\n\n==>Finished Upscaling individual images. \n==>Retrieving Video audio to append\n\n' ) time.sleep( 2 ); try: os.remove(f"{self.tmppath}audio.aac") @@ -205,7 +209,7 @@ class Handler: os.system( self.command ) # reassemble Video - print( 'Reassembling Video... with framerate @', self.framerate ) + print( '\n\n==>Reassembling Video... with framerate @', self.framerate, '\n\n' ) if self.os_type == 'linux': 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':