Closed nums closed 8 months ago
Hi! That's currently not possible, but would be a nice improvement! If that's something you would like to contribute, let me know.
Thanks, how were you planning to call that update function?
For example when you want to change the background image or to switch between blur to image background. The update is more quick than a complete destroy and re initialization of transformer
Sorry, should have clarified what I mean:
Did you test these changes? I think the update function is currently not exposed from the VirtualBackground
processor, which makes it impossible to use this API for users of the package.
Sorry, I did not understand.
But yes, I made few tests and it is working great, below is an example of use. (after 5 secondes, the background switch from blur to background image)
let localVideoTrack = new LocalVideoTrack(videoTrack);
let backgroundTransformer = new BackgroundTransformer({
blurRadius: 50
});
let pipeline = new ProcessorPipeline([backgroundTransformer], 'virtualbackground');
await localVideoTrack.setProcessor(pipeline);
setTimeout(() => {
backgroundTransformer.update({
imagePath: './samantha-gades-BlIhVfXbi9s-unsplash.jpg'
});
}, 5000);
Got it, but the pipeline
in your example is what's currently exposed to users, which does not expose this update method. Ideally we'd want to have a way for users to call that function directly in there, or, alternatively return the updateBackground
method somehow additionally on the VirtualBackground processor pipeline
I would also be interested in any progress on this. Changing the background images without tearing down the whole transformer would be great!
https://github.com/livekit/track-processors-js/pull/32 implements this by allowing you to do
const virtualB = VirtualBackground(imagePath);
virtualB.updateTransformerOptions({ imagePath: newImagePath });
I don't see how we can change the background image of the BackgroundTransformer without creating a destory. The idea would be to be able to update the background image in real time without having to reset it all.