Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

300GB of diskcache #64

Open
trungnt13 opened this issue Jun 16, 2024 · 3 comments
Open

300GB of diskcache #64

trungnt13 opened this issue Jun 16, 2024 · 3 comments

Comments

@trungnt13
Copy link

the Composition layer never calls cull method to enforce the size limit for diskcache.
There is also no mechanism to clean up the cache after a long development which often results in hundred of GB of diskcache locally.

@FronkonGames
Copy link

+1

@robinkarlberg
Copy link

robinkarlberg commented Nov 11, 2024

+1 Also having this problem.

@abdalrohman
Copy link

Cache Size Control Solution

When creating a composition, you can override the default cache behavior to control both the cache directory location and size limit. This helps prevent excessive disk space usage during video rendering.

Solution

from diskcache import Cache

composition = mv.layer.Composition(size=(width, height), duration=duration)
composition._cache = Cache(
    size_limit=1024 * 1024 * 1024,  # 1GB limit
    directory="custom_cache_dir"
)

Usage Example

class VideoScene:
    def __init__(self):
        self.cache_dir = "cache"
        self.cache_size = 1024 * 1024 * 1024  # 1GB
    
    def cleanup(self):
        # Clean up cache after rendering
        if os.path.exists(self.cache_dir):
            shutil.rmtree(self.cache_dir)
    
    def render(self):
        try:
            composition = mv.layer.Composition(...)
            composition._cache = Cache(
                size_limit=self.cache_size,
                directory=self.cache_dir
            )
            # ... render video ...
        finally:
            self.cleanup()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants