0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AndroidアプリにAmazon IVSとTencent Beauty SDKを組み合わせて美顔付き配信を実装する

Posted at

🎯 導入の背景

iOS/Androidアプリで低遅延配信をAmazon IVSで実現しつつ、ローカル映像にリアルタイム美顔処理を適用するニーズが増えています。

本記事では、AndroidアプリでAmazon IVSとTencent Beauty SDKを組み合わせる方法を紹介します。


💡 構成イメージ

[カメラ映像]
   ↓
[Beauty SDK]
   ↓
[IVS Broadcaster]
   ↓
[Amazon IVS]
   ↓
[視聴者]

📦 開発環境

項目 内容
言語 Kotlin
Android SDK API Level 23以上
SDK Amazon IVS Broadcast + Tencent Beauty SDK

🔧 SDK導入

1. build.gradle

repositories {
    google()
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    implementation 'com.amazonaws:ivs-broadcast:1.12.0'
    implementation(name: 'LiteAVSDK_TRTC', ext: 'aar')
}

🚀 実装ステップ

1. Beauty SDK初期化

val trtcCloud = TRTCCloud.sharedInstance(context)
val beautyManager = trtcCloud.beautyManager

beautyManager.setBeautyStyle(TRTCBeautyStyle.SMOOTH)
beautyManager.setBeautyLevel(5f)
beautyManager.setWhitenessLevel(3f)

2. Amazon IVS Broadcaster初期化

val broadcaster = AmazonIVSBroadcastSession(
    context,
    BroadcastConfiguration(context),
    object : BroadcastSession.Listener {
        override fun onStateChanged(state: BroadcastSession.State) {
            Log.d("IVS", "状態変化: $state")
        }
    }
)

🌟 サンプル:CameraXとBeauty SDKを組み合わせる

val cameraProviderFuture = ProcessCameraProvider.getInstance(context)

cameraProviderFuture.addListener({
    val cameraProvider = cameraProviderFuture.get()
    val preview = Preview.Builder().build()
    val analysis = ImageAnalysis.Builder()
        .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
        .build()

    analysis.setAnalyzer(executor, { imageProxy ->
        val buffer = imageProxy.planes[0].buffer
        val data = ByteArray(buffer.remaining())
        buffer.get(data)

        // Beauty SDKで処理
        val beautyFrame = beautyManager.processVideoFrame(data, imageProxy.width, imageProxy.height)

        // IVSへ送信
        broadcaster.input.sendVideoFrame(beautyFrame)

        imageProxy.close()
    })

    cameraProvider.bindToLifecycle(lifecycleOwner, CameraSelector.DEFAULT_FRONT_CAMERA, preview, analysis)
}, ContextCompat.getMainExecutor(context))

3. 配信開始/停止

broadcaster.start("rtmps://xxx.ivs.aws-region.amazonaws.com:443/app/stream-key")
// ...
broadcaster.stop()

✅ テスト結果

項目 結果
遅延 約1秒(IVS推奨設定)
フレームレート 30fps安定
発熱 Pixel5で許容範囲
安定性 Beauty SDK併用でもクラッシュなし

📝 まとめ

Tencent Beauty SDK + Amazon IVSで以下が実現可能:

  • 高品質な美顔フィルタ
  • 安定した低遅延配信
  • 柔軟なカメラ・UI構成

今後の改善:

  • TFLiteで顔検出を統合
  • GPU処理の最適化
  • Flutter対応サンプル作成

🔗 参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?