npm add @livekit/track-processors
This package exposes BackgroundBlur
and VirtualBackground
as pre-prepared processor pipelines.
BackgroundBlur(blurRadius)
VirtualBackground(imagePath)
import { BackgroundBlur } from '@livekit/track-processors';
const videoTrack = await createLocalVideoTrack();
const blur = BackgroundBlur(10);
await videoTrack.setProcessor(blur);
room.localParticipant.publishTrack(videoTrack);
async function disableBackgroundBlur() {
await videoTrack.stopProcessor();
}
async updateBlurRadius(radius) {
return blur.updateTransformerOptions({blurRadius: blur})
}
A track processor is instantiated with a Transformer.
// src/index.ts
export const VirtualBackground = (imagePath: string) => {
const pipeline = new ProcessorWrapper(new BackgroundTransformer({ imagePath }));
return pipeline;
};
- BackgroundTransformer (can blur background or use a virtual background);