Attempt to reduce leak of ffmpeg previews
This commit is contained in:
parent
e2a9a6903c
commit
c3d6aecffd
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import gc
|
||||||
import io
|
import io
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
@ -105,10 +106,13 @@ def process_video(path, *, maxsize, quality):
|
||||||
container.seek(container.duration // 8)
|
container.seek(container.duration // 8)
|
||||||
frame = next(container.decode(stream))
|
frame = next(container.decode(stream))
|
||||||
img = frame.to_image()
|
img = frame.to_image()
|
||||||
|
del frame, stream
|
||||||
|
|
||||||
img.thumbnail((maxsize, maxsize))
|
img.thumbnail((maxsize, maxsize))
|
||||||
imgdata = io.BytesIO()
|
imgdata = io.BytesIO()
|
||||||
if rotation:
|
if rotation:
|
||||||
img = img.rotate(rotation, expand=True)
|
img = img.rotate(rotation, expand=True)
|
||||||
img.save(imgdata, format="webp", quality=quality, method=4)
|
img.save(imgdata, format="webp", quality=quality, method=4)
|
||||||
return imgdata.getvalue()
|
ret = imgdata.getvalue()
|
||||||
|
gc.collect()
|
||||||
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue
Block a user