Skip to main content
SDK 2.0.0. Dart only sets beauty parameters. Every video frame stays on the native GL thread via FacebetterPlugin.processTexture.
Do not call processFile / processImageBytes / processImageFile / processImageToUiImage on this engine. Those APIs need externalContext: false and a separate instance.

Prerequisites

  • tencent_trtc_cloud (or native TRTC) already in the app
  • facebetter_flutter: ^2.0.0
  • Valid appId / appKey or licenseTokenLicense & Auth
When enabling TRTC custom preprocess, use Texture2D + Texture buffer, not YUV / PixelBuffer.

1. Create the engine in Dart

Create before turning on custom video process. externalContext defaults to true and must stay true for TRTC.
Slider callbacks can call the sync setters directly:
Then enable TRTC custom process (API name depends on your TRTC Flutter plugin version):

2. iOS — feed textures in onProcessVideoFrame

If you use tencent_trtc_cloud’s ITXCustomBeautyProcesser, keep Texture2D / Texture and call the same processTexture inside onProcessVideoFrame. Register the factory after GeneratedPluginRegistrant.register(with:).

3. Android — same callback, Kotlin

processTexture must run on the current GL thread. Never hop to the UI isolate.

4. Tear down

  1. enableCustomVideoProcess(false) (or leave the room)
  2. engine.dispose()

Photos vs live video

Do not

  • Push pixels or texture ids from Dart every frame — Flutter and TRTC do not share a GL context with Dart.
  • Call processTexture off the GL thread.
  • Treat FBEngine as a process-wide singleton. Create it with FBEngine.create and dispose() when the call ends.