This library provides track processors for use with the Android LiveKit SDK.
implementation "io.livekit:livekit-android-track-processors:<current livekit sdk release>"See our release page for details on the current release version.
This package exposes VirtualBackgroundVideoProcessor as a pre-prepared video processor.
val processor = VirtualBackgroundVideoProcessor(eglBase).apply {
// Optionally set a background image.
// Will blur the background of the video if none is set.
val drawable = AppCompatResources.getDrawable(application, R.drawable.background) as BitmapDrawable
backgroundImage = drawable.bitmap
}
VirtualBackgroundVideoProcessor requires the use of our CameraX provider.
val imageAnalysis = ImageAnalysis.Builder().build()
.apply { setAnalyzer(Dispatchers.IO.asExecutor(), processor.imageAnalyzer) }
CameraXHelper.createCameraProvider(ProcessLifecycleOwner.get(), arrayOf(imageAnalysis)).let {
if (it.isSupported(application)) {
CameraCapturerUtils.registerCameraProvider(it)
}
}
val videoTrack = room.localParticipant.createVideoTrack(
options = LocalVideoTrackOptions(position = CameraPosition.FRONT),
videoProcessor = processor,
)
videoTrack.startCapture()
room.localParticipant.publishVideoTrack(videoTrack)
You can find an offline example of the VirtualBackgroundVideoProcessor in
use here.