downloadVideoMattingModel()v4.0.528
Downloads a video matting model from remotion.media into the browser or Node.js filesystem cache. Call loadVideoMattingModel() or separateVideoLayers() afterwards.
The browser Cache API, Node.js filesystem cache, or a Transformers.js custom cache must be enabled.
download-model.tsimport {downloadVideoMattingModel } from '@remotion/video-matting'; const {alreadyDownloaded } = awaitdownloadVideoMattingModel ({model : 'modnet',onProgress : ({progress }) =>console .log (progress ), });console .log (alreadyDownloaded );
Options
model
One of the names returned by getAvailableModels().
signal?v4.0.528
An AbortSignal used to cancel downloading. Aborting rejects with the signal's reason and removes incomplete files. Already downloaded files remain cached for the next attempt.
onProgress?
Called as files download. Default: no callback. The callback receives:
file
The file being downloaded, or null for aggregate progress.
progress
Aggregate progress between 0 and 1.
loadedBytes
Bytes downloaded in this call.
totalBytes
Estimated total model size in bytes.
Return value
alreadyDownloaded
true if all files were already cached before this call.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||