flutter_banuba_ar
A Flutter plugin for the Banuba augmented reality SDK. Provides camera capture, AR effect loading/switching, and a stream of AR-processed frames ready for live streaming, recording, or preview.
Features
- 📸 Camera capture via Banuba's native CameraDevice (Android & iOS)
- 🎠Load/unload AR effects by name
- 🔄 Switch between front and back camera
- 📡 Stream AR-processed frames as byte arrays (RGBA on Android, BGRA on iOS)
- âš¡ Hidden SurfaceView pipeline (Android) for headless rendering
- 🎯 PixelBuffer output (iOS) for efficient frame delivery
Getting Started
1. Get a Banuba Client Token
Sign up at banuba.com and create a project to get your client token.
2. Install
dependencies:
flutter_banuba_ar: ^0.1.0
3. Platform Setup
Android
Add camera permission to your AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
The Banuba SDK is pulled automatically via Maven. No manual SDK download needed.
iOS
Add camera permission to your Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for AR effects</string>
Important: Add the Banuba CocoaPods source to the top of your app's Podfile:
source 'https://github.com/sdk-banuba/banuba-sdk-podspecs.git'
source 'https://cdn.cocoapods.org/'
4. Usage
import 'package:flutter_banuba_ar/flutter_banuba_ar.dart';
final banuba = BanubaARController();
// Initialize with your client token
await banuba.initialize(token: 'YOUR_BANUBA_CLIENT_TOKEN');
// Start camera capture
await banuba.startCapture();
// Listen to processed frames
banuba.frameStream.listen((frame) {
// frame.data — Uint8List of pixel data
// frame.width, frame.height — dimensions
// frame.format — 'rgba' or 'bgra'
// frame.timestamp — milliseconds since epoch
});
// Load an AR effect
await banuba.loadEffect('TrollGrandma');
// Clear effect
await banuba.clearEffect();
// Switch camera
await banuba.switchCamera();
// Cleanup when done
await banuba.dispose();
Agora Integration
For direct integration with Agora live streaming, see the companion package flutter_banuba_agora_ar, which provides a one-liner bridge to pipe AR-processed frames into Agora's external video source.
Effect Files
Place Banuba effect folders in your app's assets directory:
assets/effects/
├── TrollGrandma/
├── Beauty/
└── Glasses/
Declare them in pubspec.yaml:
flutter:
assets:
- assets/effects/
License
MIT License. See LICENSE for details.
Banuba SDK is subject to Banuba's licensing terms.
Libraries
- flutter_banuba_ar
- Flutter plugin for the Banuba augmented reality SDK.