I took code from example as a base and got a memory leak. Reason: there is no close
method for the container.
I verified on small video: 2sec, 360:
Simplified code:
import av
import av.datasets
import psutil
current_process = psutil.Process()
get_mem_uss = lambda: current_process.memory_full_info().uss
PATH = '...'
def read_frames(path):
container = av.open(path)
return [frame.to_ndarray(format='yuv420p') for frame in container.decode(video=0)]
started_with = get_mem_uss()
for i in range(15000):
read_frames(PATH)
if i % 50:
print(f'Used memory {(get_mem_uss() - started_with) / 1024 / 1024}')