Skip to main content

canUseVideoMatting()v4.0.523

Checks whether a video matting model can run in the current browser or Node.js environment.

This function checks WebGPU and model-specific requirements. It does not inspect an input file or check video decoding and encoding support.

support.ts
import {canUseVideoMatting} from '@remotion/video-matting'; const result = await canUseVideoMatting({model: 'modnet'}); if (!result.supported) { throw new Error(result.detailedReason); }

Options​

model?​

The model whose requirements should be checked. Default: modnet.

Return value​

A promise resolving to a discriminated result with these properties:

supported​

true if the selected model is supported and false otherwise.

reason?​

When supported is false, one of:

  • window-undefined
  • webgpu-unavailable
  • webgpu-requires-secure-context
  • shader-f16-unavailable

In Node.js, failed native WebGPU probes return webgpu-unavailable with the ONNX Runtime error in detailedReason.

shader-f16-unavailable applies to models such as ben2-base that require 16-bit shader support.

detailedReason?​

When supported is false, a human-readable explanation of the reason.

Compatibility​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​