I'm using the LiveKit track processor to apply a b...
# ask-ai
p
I'm using the LiveKit track processor to apply a blur background, but the background corners are still showing and the performance is not good. Is there a segmentation option or something similar that I can use?
t
Thanks for reaching out, Yassine. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! LiveKit's track processor uses some pretty cool segmentation technology powered by MediaPipe's Selfie Segmenter model to help separate the person in the video from the background. This is what makes features like background blur and virtual backgrounds possible. To help you get the best performance and quality from the blur effect, here are a few friendly tips: • Make sure you're using the latest version of the
@livekit/track-processors
package. • You can adjust the blur intensity with the
blurRadius
parameter, and it’s easy to update dynamically using the
switchTo()
method. • It’s a good idea to check if your browser supports modern background processors by using `supportsModernBackgroundProcessors()`—this can really boost performance. • If you’re on a lower-powered device and notice any slowdowns, you might want to disable some CPU-heavy features. The SDK can even detect CPU constraints through the
LocalTrackCpuConstrained
event to help with this. If you’d like, I’m here to guide you through implementing or optimizing these features—just let me know! Sources: example/sample.ts | Sources/LiveKit/VideoProcessors/BackgroundBlurVideoProcessor.swift | JavaScript/TypeScript SDK | livekit/livekit_composite | DeepWiki | Optimizing Video Calls for Low-Powered Devices in LiveKit (JS SDK ≥ v2.14.0... | examples/nextjs/pages/processors.tsx
p
When using backgroundBlur() there is option i can pass that will hide the corner ,? In my case the corner around my face is visible
t
I'm glad you're exploring the background blur feature in LiveKit! You can adjust the blur intensity using the
blurRadius
parameter, which gives you some control over the effect. However, there aren't specific options to modify or hide the visibility of corners around the face in the segmentation effect just yet. Sometimes, the visibility of those corners can be related to how well the segmentation is working. Here are a few friendly tips to help improve it: • Make sure you're using the latest version of the
@livekit/track-processors
package to benefit from the newest improvements. • Check your device’s performance and browser compatibility, since segmentation quality can vary depending on your hardware and browser. • Try adjusting the lighting and background in your video feed—better lighting can really help the segmentation work more accurately. If you have any more questions or a specific scenario you're working with, please don’t hesitate to reach out. I’m here to help you every step of the way! Sources: src/index.ts | lib/CameraSettings.tsx | livekit-compose-components/src/main/java/io/livekit/android/compose/ui/BarV... | Bringing Zoom's end-to-end optimizations to WebRTC
p
For example i see an option which is assetspath this option for what?
t
The
assetPaths
option in LiveKit's track processors is a handy way to customize where your background processing models and resources are loaded from. It has two key properties: • `tasksVisionFileSet`: This lets you specify the path to the MediaPipe tasks-vision WASM files. • `modelAssetPath`: This is where you set the path to the selfie segmentation model used for background processing. Usually, these assets load from CDN-hosted locations, but with
assetPaths
, you can point to custom paths—like hosting assets locally or on your own server. This can be really helpful if CDN access is limited or if you’re working with custom models. Just a quick heads-up: if you update
assetPaths
, you’ll need to restart the processor for the changes to take effect. If you’d like, I’m here to help you set this up or answer any other questions you might have! Sources: example/sample.ts
p
So changing the assetspath maybe will correct the corner issue?
t
Thanks for reaching out! Changing the
assetPaths
option to use custom paths for the segmentation model or WASM files probably won’t directly fix the corner visibility issue. This option mainly helps specify where the segmentation assets are loaded from, like a local server or private CDN, but it doesn’t change how the segmentation behaves or its quality. The corner visibility challenge is more likely tied to the segmentation model’s accuracy or the conditions of your video feed—things like lighting and background contrast play a big role. Here are a few tips that might help improve the segmentation quality: • Make sure you have good lighting and a clear contrast between the subject and the background. • Use the latest version of the
@livekit/track-processors
package to take advantage of any updates or improvements. • Try testing on a device with stronger hardware, as segmentation performance can vary depending on the device. If you have a specific scenario you’re working with or want more help, just let me know—I’m here to guide you through it!
p
const blur = BackgroundBlur(25, { modelAssetPath: "/hair_segmentation.tflite" }); when i use it like this there is no background being applied
t
I'm sorry to hear you're having trouble with the background blur not applying when using a custom
modelAssetPath
. Let’s walk through some common reasons this might happen and see if we can get it working together: • Model Compatibility: It’s important that your custom
.tflite
file is compatible with MediaPipe's ImageSegmenter API. Make sure it’s a TensorFlow Lite model specifically trained for image segmentation and follows the expected format. • CORS Configuration: Sometimes, the server hosting your model might not have the right CORS headers. Double-check that it includes
Access-Control-Allow-Origin
headers to allow access. • Path Accessibility: Let’s verify that the
modelAssetPath
you’re using is correct and accessible. You can try opening the URL directly in a browser or use a tool like
curl
to test it. • Browser Security: Browsers block local file paths like
file://
. So, it’s best to serve your model over HTTPS, even during development, to avoid this issue. • Default Model Test: A helpful step is to test your setup without specifying
modelAssetPath
to see if the default model works fine. This can help us figure out if the problem lies with the custom model or the overall setup. If you want, you can also check the browser’s DevTools console or network tab for any error messages that might give us more clues. And please feel free to reach out if you’d like me to help you verify your model or guide you through setting up the right configuration—I’m here to help! Sources: example/sample.ts