Back to Remotion

In-memory cache for @remotion/media

packages/docs/docs/media/cache.mdx

4.0.5083.3 KB
Original Source

@remotion/media keeps an in-memory cache for video and audio decoding.

Mechanism

Video streams consist of key frames and delta frames.
In order to decode a delta frame, the last keyframe and all the delta frames since the last keyframe also need to be decoded.

Due to Remotion's multithreaded rendering and each frame being independent, it is not guaranteed that video frames are needed in their natural order.

Decoded media is cached across all instances of <Video> and <Audio>. Therefore, the decoded media cache is per-render, not per tag.

Default cache size

By default, the decoded media cache may grow to up to 50% of the available system memory. A minimum of 500MB and a maximum of 20GB is enforced.

Customizing the cache size

The rendering APIs allow you to customize the decoded media cache budget on a per-render basis. The same value determines the read cache size for each source: