Attempt to reduce leak of ffmpeg previews
This commit is contained in:
		| @@ -10,7 +10,6 @@ from wsgiref.handlers import format_date_time | |||||||
| import av | import av | ||||||
| import av.datasets | import av.datasets | ||||||
| import fitz  # PyMuPDF | import fitz  # PyMuPDF | ||||||
| from av.streams import SideData |  | ||||||
| from PIL import Image | from PIL import Image | ||||||
| from sanic import Blueprint, empty, raw | from sanic import Blueprint, empty, raw | ||||||
| from sanic.exceptions import NotFound | from sanic.exceptions import NotFound | ||||||
| @@ -19,6 +18,8 @@ from sanic.log import logger | |||||||
| from cista import config | from cista import config | ||||||
| from cista.util.filename import sanitize | from cista.util.filename import sanitize | ||||||
|  |  | ||||||
|  | DISPLAYMATRIX = av.streams.SideData.DISPLAYMATRIX | ||||||
|  |  | ||||||
| bp = Blueprint("preview", url_prefix="/preview") | bp = Blueprint("preview", url_prefix="/preview") | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -100,7 +101,7 @@ def process_video(path, *, maxsize, quality): | |||||||
|         stream = container.streams.video[0] |         stream = container.streams.video[0] | ||||||
|         stream.codec_context.skip_frame = "NONKEY" |         stream.codec_context.skip_frame = "NONKEY" | ||||||
|         stream.codec_context.threads = 1 |         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) |         container.seek(container.duration // 8) | ||||||
|         img = next(container.decode(stream)).to_image() |         img = next(container.decode(stream)).to_image() | ||||||
|         del stream |         del stream | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Leo Vasanko
					Leo Vasanko