From 85437a84813fcde449bf20ee2a7b6f305c49e0cf Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sun, 4 Sep 2022 00:06:46 +0000 Subject: [PATCH] removed the walrus operator to remain compatible with Python 3.7 --- video2x/decoder.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/video2x/decoder.py b/video2x/decoder.py index 7df3684..28d99a8 100755 --- a/video2x/decoder.py +++ b/video2x/decoder.py @@ -104,14 +104,11 @@ class VideoDecoder: def __iter__(self): # continue yielding while FFmpeg continues to produce output - while ( - len( - buffer := self.decoder.stdout.read( - 3 * self.input_width * self.input_height - ) - ) - > 0 - ): + # it is possible to use := for this block to be more concise + # but it is purposefully avoided to remain compatible with Python 3.7 + buffer = self.decoder.stdout.read(3 * self.input_width * self.input_height) + + while len(buffer) > 0: # convert raw bytes into image object frame = Image.frombytes( @@ -121,6 +118,9 @@ class VideoDecoder: # return this frame yield frame + # read the next frame + buffer = self.decoder.stdout.read(3 * self.input_width * self.input_height) + # automatically self-join and clean up after iterations are done self.join()