mirror of
https://github.com/k4yt3x/video2x.git
synced 2024-12-28 23:19:11 +00:00
removed the walrus operator to remain compatible with Python 3.7
This commit is contained in:
parent
176ae90bbb
commit
85437a8481
@ -104,14 +104,11 @@ class VideoDecoder:
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
|
||||||
# continue yielding while FFmpeg continues to produce output
|
# continue yielding while FFmpeg continues to produce output
|
||||||
while (
|
# it is possible to use := for this block to be more concise
|
||||||
len(
|
# but it is purposefully avoided to remain compatible with Python 3.7
|
||||||
buffer := self.decoder.stdout.read(
|
buffer = self.decoder.stdout.read(3 * self.input_width * self.input_height)
|
||||||
3 * self.input_width * self.input_height
|
|
||||||
)
|
while len(buffer) > 0:
|
||||||
)
|
|
||||||
> 0
|
|
||||||
):
|
|
||||||
|
|
||||||
# convert raw bytes into image object
|
# convert raw bytes into image object
|
||||||
frame = Image.frombytes(
|
frame = Image.frombytes(
|
||||||
@ -121,6 +118,9 @@ class VideoDecoder:
|
|||||||
# return this frame
|
# return this frame
|
||||||
yield 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
|
# automatically self-join and clean up after iterations are done
|
||||||
self.join()
|
self.join()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user