Skip to content

🎥 Make videos programmatically with React

Merge remote-tracking branch 'origin/main' into codex/studio-remove-background

Jonny Burgerd5f4168680e1
diff --cc packages/docs/docs/video-matting/index.mdx
index 99ebf59540,eb15eae894..9e4172a8b2
--- a/packages/docs/docs/video-matting/index.mdx
+++ b/packages/docs/docs/video-matting/index.mdx
@@@ -16,31 -16,26 +16,21 @@@ import {TableOfContents} from './table-
## Example
-```ts twoslash title="separate-video.ts"
-import {downloadVideoMattingModel, separateVideoLayers} from '@remotion/video-matting';
+```ts twoslash title="remove-video-background.ts"
- import {
- downloadVideoMattingModel,
- loadVideoMattingModel,
- removeVideoBackground,
- } from '@remotion/video-matting';
++import {downloadVideoMattingModel, removeVideoBackground} from '@remotion/video-matting';
export const matteVideo = async (file: File) => {
- const model = 'modnet';
await downloadVideoMattingModel({
- model,
+ model: 'modnet',
onProgress: ({progress}) => console.log('Downloading model:', progress),
});
- await using modelHandle = await loadVideoMattingModel({
- model,
- });
- console.log('Model already in memory:', modelHandle.alreadyLoaded);
-
- await using layers = await separateVideoLayers({
+ await using result = await removeVideoBackground({
src: file,
- model,
+ model: 'modnet',
- onProgress: ({progress}) => console.log('Separating layers:', progress),
+ onProgress: ({progress}) => console.log('Removing background:', progress),
});
- const [baseBlob, foregroundBlob] = await Promise.all([
- layers.base.getBlob(),
- layers.foreground.getBlob(),
- ]);
-
- return {baseBlob, foregroundBlob};
+ return result.video.getBlob();
};
```