Docs / Flutter / flutter_webrtc

flutter_webrtc

Beautify a flutter_webrtc camera track with one call. The frames are processed natively on the capturer's thread before they reach the encoder.

Demo app: facevity-flutter-demo on GitHub

flutter_webrtc 0.9.36 and later expose an external processing API on local video tracks. Facevity uses it to process camera frames natively on the capturer’s thread: an OES texture on Android, an RTCCVPixelBuffer on iOS.

1. Requirements

  • facevity_flutter set up as in the quick start
  • flutter_webrtc 0.9.36 or later
  • iOS: 'flutter_webrtc' in $FacevityRtcHooks in the Podfile. Android detects it automatically.

2. Attach to the camera track

final fv = await Facevity.initialize(licenseAsset: 'assets/facevity/license.fvl', params: BeautyParams.natural);

final stream = await navigator.mediaDevices.getUserMedia({
  'audio': true,
  'video': {'facingMode': 'user'},
});
final video = stream.getVideoTracks().first;
await fv.rtc.webrtc.attachTrack(video.id!);

peerConnection.addTrack(video, stream);
stream.getAudioTracks().forEach((t) => peerConnection.addTrack(t, stream));
localRenderer.srcObject = stream;

RTCVideoView and the encoder both read the processed frames.

3. Tear down

await fv.rtc.webrtc.detach();
await stream.dispose();

Notes

  • Attach again if you replace the track (a new getUserMedia).
  • On Android, non-camera frames (screen sharing) go through the I420 buffer path and need the buffer.path licence feature; on iOS they pass through unchanged.

Next: all platforms · API reference

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