polite-oil-10264
08/13/2025, 2:15 PMtall-airline-16756
08/13/2025, 2:15 PMtall-airline-16756
08/13/2025, 2:16 PMconst blur = BackgroundBlur(10);
, or on Android, try processor.updateBlurRadius(16f);
.
• Downscale Factor: You might want to reduce the video resolution before blurring by tweaking the downscaleFactor
. A smaller factor keeps more detail but could use more resources.
• Smooth Edge Detection: To get a nice, natural blend between blurred and clear areas, adjust the edge detection in your shader. For example, in compositeShader.ts
, bump up the edge softness like this: const edgeSoftness = 2.0;
.
• High-Quality Segmentation: For better accuracy, turn on high-quality segmentation by initializing the background blur processor with `highQuality`: const processor = new BackgroundTransformer({ highQuality: true });
.
Just a heads-up—bumping up the blur radius or quality might affect performance a bit, so it’s a good idea to test these tweaks on your devices to find what works best for you.polite-oil-10264
08/13/2025, 2:18 PMtall-airline-16756
08/13/2025, 2:18 PMBackgroundBlur
in your Next.js app, here are some friendly tips you can try:
• Make Sure It’s Set Up Right: Use the BackgroundBlur
processor from @livekit/track-processors
and apply it to your video track. Here’s a quick example:
import { BackgroundBlur } from '@livekit/track-processors';
import { useLocalParticipant } from '@livekit/components-react';
function Stage() {
const localParticipant = useLocalParticipant();
const cameraTrack = localParticipant?.localParticipant?.getTrackPublication(Track.Source.Camera)?.track;
const [blurEnabled, setBlurEnabled] = React.useState(false);
React.useEffect(() => {
const blur = new BackgroundBlur();
if (cameraTrack) {
if (blurEnabled && !cameraTrack.getProcessor()) {
cameraTrack.setProcessor(blur);
} else if (!blurEnabled) {
cameraTrack.stopProcessor();
}
}
}, [blurEnabled, cameraTrack]);
return (
);
}
• Keep an Eye on CPU Usage: If the CPU gets a bit overwhelmed, you can detect that and adjust the video quality on the fly. Here’s how:
const handleCpuConstrained = async (track) => {
console.warn('CPU constrained');
track.stopProcessor();
track.prioritizePerformance();
};
room.localParticipant.on(ParticipantEvent.LocalTrackCpuConstrained, handleCpuConstrained);
• Tweak Video Quality: Lower the resolution and frame rate when needed to keep things running smoothly.
• Go for High-Quality Segmentation: For sharper results, initialize the processor with the highQuality
option.
• Make It Responsive: Use components like GridLayout
to make sure your app looks great on all screen sizes.
Trying these out should help your background blur run better and look nicer in your Next.js app. If you want to chat more or need a hand, just let me know!polite-oil-10264
08/13/2025, 2:20 PMtall-airline-16756
08/13/2025, 2:21 PMhighQuality
option in BackgroundBlur
, you can easily turn it on when you set things up. Here’s a quick example:
• In Swift: Just create your BackgroundBlurVideoProcessor
like this, setting highQuality
to `true`:
let backgroundBlur = BackgroundBlurVideoProcessor(highQuality: true)
This will give you better, more detailed segmentation, though it might slow things down a bit.
For JavaScript, the highQuality
option isn’t available directly, but if you want, I’m here to help you explore other ways to get similar results!polite-oil-10264
08/13/2025, 2:23 PMpolite-oil-10264
08/13/2025, 2:23 PMtall-airline-16756
08/13/2025, 2:24 PMpolite-oil-10264
08/13/2025, 2:25 PMtall-airline-16756
08/13/2025, 2:26 PM