From 27422ae1e2cefccf34549e030eb19e2971be7939 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 21 Nov 2023 04:01:51 -0800 Subject: [PATCH] Attempt to reduce leak of ffmpeg previews --- cista/preview.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cista/preview.py b/cista/preview.py index dbb2893..fed9c8e 100644 --- a/cista/preview.py +++ b/cista/preview.py @@ -108,11 +108,13 @@ def process_video(path, *, maxsize, quality): img = frame.to_image() del frame, stream - img.thumbnail((maxsize, maxsize)) - imgdata = io.BytesIO() - if rotation: - img = img.rotate(rotation, expand=True) - img.save(imgdata, format="webp", quality=quality, method=4) + img.thumbnail((maxsize, maxsize)) + imgdata = io.BytesIO() + if rotation: + img = img.rotate(rotation, expand=True) + img.save(imgdata, format="webp", quality=quality, method=4) + del img + ret = imgdata.getvalue() gc.collect() return ret