Skip to main content

downloadVideoMattingModel()v4.0.528

Downloads a video matting model from remotion.media into the browser cache without initializing WebGPU. Call loadVideoMattingModel() or separateVideoLayers() afterwards.

The browser Cache API 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().

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

BrowsersEnvironments
Chrome
Firefox
Safari

See also