Skip to main content

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.ts
import {downloadVideoMattingModel} from '@remotion/video-matting'; const {alreadyDownloaded} = await downloadVideoMattingModel({ 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​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​