Skip to content

Commit

Permalink
Update movis.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Jul 5, 2024
1 parent 3d3483e commit 63241ee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions vstransitions/libs/movis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from fractions import Fraction
from threading import Lock
from typing import Any

import numpy as np
Expand Down Expand Up @@ -118,6 +119,8 @@ def __init__(self, scene: Composition, fps: Fraction | None = None) -> None:
self.width = self.scene.size[0]
self.height = self.scene.size[1]

self.mutex = Lock()

if fps is None:
for layer in self.scene._layers:
if isinstance(layer, LayerItem):
Expand Down Expand Up @@ -149,9 +152,10 @@ def _to_node(self, n: int, plane: int, dst: PyPluginNumpy.DT) -> None:

np.copyto(dst, frame[:, :, plane])

if len(self.scene._cache) > core.num_threads * 2:
for k in list(self.scene._cache.keys())[:core.num_threads]:
del self.scene._cache[k]
with self.mutex:
if len(self.scene._cache) > core.num_threads * 2:
for k in list(self.scene._cache.keys())[:core.num_threads]:
del self.scene._cache[k]

@cachedproperty
def video(self) -> vs.VideoNode:
Expand Down

0 comments on commit 63241ee

Please sign in to comment.