From 728cd47dcaca138a193fda2d2b223756dc24032a Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 21 Nov 2023 12:27:38 +0000 Subject: [PATCH] Attempt to reduce leak of ffmpeg previews --- cista/preview.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cista/preview.py b/cista/preview.py index bf9eb2d..2b20a97 100644 --- a/cista/preview.py +++ b/cista/preview.py @@ -10,7 +10,6 @@ from wsgiref.handlers import format_date_time import av import av.datasets import fitz # PyMuPDF -from av.streams import SideData from PIL import Image from sanic import Blueprint, empty, raw from sanic.exceptions import NotFound @@ -19,6 +18,8 @@ from sanic.log import logger from cista import config from cista.util.filename import sanitize +DISPLAYMATRIX = av.streams.SideData.DISPLAYMATRIX + bp = Blueprint("preview", url_prefix="/preview") @@ -100,7 +101,7 @@ def process_video(path, *, maxsize, quality): stream = container.streams.video[0] stream.codec_context.skip_frame = "NONKEY" stream.codec_context.threads = 1 - rot = stream.side_data and stream.side_data.get(SideData.DISPLAYMATRIX) or 0 + rot = stream.side_data and stream.side_data.get(DISPLAYMATRIX) or 0 container.seek(container.duration // 8) img = next(container.decode(stream)).to_image() del stream