In-memory cache for @remotion/media
@remotion/media
keeps a cache of recently decoded video and audio frames.
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.
The cache is shared across all of the instances of <Video>
and <Audio>
.
Therefore, the settings for the cache are per-render, not per tag.
Default cache size
By default, the cache may grow to up to 50% of the available system memory.
Customizing the cache size
The rendering APIs allow you to customize this limit on a per-render basis:
renderMedia()
→mediaCacheSizeInBytes
renderStill()
→mediaCacheSizeInBytes
selectComposition()
→mediaCacheSizeInBytes
renderMediaOnCloudRun()
→mediaCacheSizeInBytes
renderStillOnCloudRun()
→mediaCacheSizeInBytes
getCompositionsOnLambda()
→mediaCacheSizeInBytes
renderMediaOnLambda()
→mediaCacheSizeInBytes
renderStillOnLambda()
→mediaCacheSizeInBytes
getCompositions()
→mediaCacheSizeInBytes
renderFrames()
→mediaCacheSizeInBytes
npx remotion benchmark
→--media-cache-size-in-bytes
npx remotion compositions
→--media-cache-size-in-bytes
npx remotion render
→--media-cache-size-in-bytes
npx remotion still
→--media-cache-size-in-bytes
npx remotion lambda render
→--media-cache-size-in-bytes
npx remotion lambda still
→--media-cache-size-in-bytes
npx remotion lambda compositions
→--media-cache-size-in-bytes
npx remotion cloudrun render
→--media-cache-size-in-bytes
npx remotion cloudrun still
→--media-cache-size-in-bytes
npx remotion cloudrun render
→--media-cache-size-in-bytes
- Remotion Studio: Set the cache size under the "Advanced" tab