Docs / Android / LiveKit

LiveKit on Android

Beautify a LiveKit Android 2.x camera track by passing Facevity's WebRTC VideoProcessor when the track is created.

Demo app: facevity-android-demo on GitHub

LiveKit’s Android SDK is built on WebRTC, repackaged under livekit.org.webrtc. Its camera track accepts a WebRTC VideoProcessor, so the WebRTC processor works unchanged with LiveKit’s imports.

1. Requirements

  • Facevity for Android 0.3.3 set up as in the quick start
  • LiveKit Android SDK 2.x (io.livekit:livekit-android)
  • Licence feature beauty.basic

2. The processor

Copy WebRtcFacevity from the WebRTC guide and switch its imports:

import livekit.org.webrtc.JavaI420Buffer
import livekit.org.webrtc.RendererCommon
import livekit.org.webrtc.SurfaceTextureHelper
import livekit.org.webrtc.TextureBufferImpl
import livekit.org.webrtc.VideoFrame
import livekit.org.webrtc.VideoProcessor
import livekit.org.webrtc.VideoSink
import livekit.org.webrtc.YuvConverter

3. Pass it when the track is created

The processor is set when the camera track is created and can’t be added later.

suspend fun publishBeautifiedCamera(room: Room, fv: Facevity, helper: SurfaceTextureHelper) {
    val local = room.localParticipant
    val track = local.createVideoTrack(
        name = "camera",
        options = LocalVideoTrackOptions(),
        videoProcessor = WebRtcFacevity(fv, helper),   // livekit.org.webrtc imports
    )
    track.startCapture()
    local.publishVideoTrack(track)
}

Beauty settings apply to the published track live.

4. Tear down

local.unpublishTrack(track)
track.stopCapture()
fv.release()

Notes

  • A camera switch on the same track keeps the processor. Call fv.resetTracking() after switching so faces fade back in cleanly.
  • To stop beautifying without republishing, call fv.setBeautyEnabled(false): frames then pass through untouched.

Next: WebRTC on Android · all platforms

Need help with an integration? Contact the Facevity team. We answer integration questions during trials.