Skip to main content

@remotion/video-mattingv4.0.523

Separate a video into opaque base and transparent foreground layers, locally in the browser or Node.js using WebGPU.

Installation​

npx remotion add @remotion/video-matting @huggingface/transformers

Studio​

Remotion Studio offers Remove background for a selected video. It replaces the video's source with a transparent WebM. Duplicate the layer first if you want to keep the original alongside it.

For programmatic base and foreground outputs, see separateVideoLayers().

Model hosting​

We noticed that hosting the models on R2 leads to faster downloading than through Hugging Face directly.
We mirrored the models to remotion.media, keeping them byte-identical.
We also notified Hugging Face and they are investigating the issue. We may migrate back to the official hosting in the future.

APIs​

Requirements​

A GPU is needed for this. Use canUseVideoMatting() to check whether your system can use video matting.

The browser must also be able to decode the input video and encode VP9 with alpha through WebCodecs.
separateVideoLayers() checks these media capabilities for the selected input.

License​

The package is MIT licensed.
Models retain the licenses listed under getAvailableModels().