In-memory cache for @remotion/media
@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.
All instances of <Video> and <Audio> share a cache budget per render.
When the cache exceeds the budget, Remotion releases the least recently used idle sources first. Active reads can temporarily exceed the budget.
Remotion closes a source’s reader once its cached media has been discarded and its active reads have finished. A later frame can reopen it.
Default cache size
When Remotion can measure the available system memory, the default is 50% of that memory at the start of the render, with a minimum of 500 MB and a maximum of 20 GB. When the measurement is unavailable, as in a standalone browser, the default is 1.5 GB.
Customizing the cache size
Use the mediaCacheSizeInBytes option to set the cache budget in bytes.
In Remotion Studio, set the cache size under the "Advanced" tab.