tencent cloud

Tencent Effect SDK

Release Notes and Announcements
Release Notes
Tencent Effect SDK V3.5 Version Released
Tencent Effects SDK V3.0 Version Related API and Material Changes
Product Introduction
Overview
Features
Basic Concepts
Strengths
Use Cases
Purchase Guide
Pricing Overview
Purchase Guide
Payment Overdue and Refund
Tutorial
Demos
Free Trial License
Licenses
Adding and Renewing a License (Mobile)
Adding and Renewing a License (Desktop)
Adding and Renewing a License (Web)
FAQs
SDK Download
Features
SDK Download
Version History
SDK Integration Guide(No UI)
General Integration of Tencent Effect
Integrating Capabilities
SDK Integration Guide(Including UI)
General Integration of Tencent Effect
Integrating Tencent Effect into MLVB SDK
Integrating Tencent Effect into TRTC SDK
Integrating Tencent Effect into UGSV SDK
Virtual Avatars
API Documentation
iOS
Android
Flutter
Web
Feature Guide
Reducing SDK Size
SDK Integration Issue Troubleshooting
Performance Fine-Tuning
Effect Fine-Tuning
Material Usage
Effect Parameters
Recommended Parameters in Beautification Scenarios
UGSV Enterprise Edition Migration Guide
Integrating Tencent Effect for Third-Party Publishers (Flutter)
Integrating Beauty AR Web into Mini Programs
Tencent Effect Studio Usage
Beauty AR Web
Overview
Quick Start
SDK Integration
Parameters and APIs
Console Guide
Demos
Preset Effect List
Practical Tutorial
FAQs
FAQs
General
Technical
License
Legacy Documentation
Recommended Parameters in Beautification Scenarios
Beauty Parameters Table
One-Minute Integration of TRTC
One-Minute Integration of Live Streaming
TE SDK Policy
Privacy Policy
Data Processing And Security Agreement
Contact Us

Android(3.3.0 and prior)

PDF
Focus Mode
Font Size
Last updated: 2024-07-05 12:35:44

Step 1. Replace resources

1. Download the TRTC demo which has integrated the Tencent Effect SDK. This demo is built based on the Tencent Effect SDK S1-04 edition.
2. Replace the SDK files in the demo with the files for the SDK you actually use. Specifically, follow the steps below:
Replace the .aar file in the libs directory of the Xmagic module with the .aar file in libs of your SDK.
Replace all the files in ../src/main/assets of the Xmagic module with those in assets/ of your SDK. If there are files in the MotionRes folder of your SDK package, also copy them to the ../src/main/assets directory.
Replace all the .so files in ../src/main/jniLibs of the Xmagic module with the .so files in jniLibs of your SDK package (you need to decompress the ZIP files in the jinLibs folder to get the .so files for arm64-v8a and armeabi-v7a).
3. Import the Xmagic module in the demo into your project.

Step 2. Open build.gradle in app and do the following:

1. Set applicationId to the package name bound to the trial license.
2. Add Gson dependency settings.
configurations{
all*.exclude group:'com.google.code.gson'
}

Step 3. Integrate the SDK APIs

You can refer to the ThirdBeautyActivity class of the demo.
1. Authorize:
// For authentication precautions and error codes, see https://www.tencentcloud.com/document/product/1143/45385#step-1.-authenticate
XMagicImpl.checkAuth((errorCode, msg) -> {
if (errorCode == TELicenseCheck.ERROR_OK) {
showLoadResourceView();
} else {
TXCLog.e(TAG, "Authentication failed. Check the authentication URL and key" + errorCode + " " + msg);
}
});
2. Initialize the material:
private void showLoadResourceView() {
if (XmagicLoadAssetsView.isCopyedRes) {
XmagicResParser.parseRes(getApplicationContext());
initXMagic();
} else {
loadAssetsView = new XmagicLoadAssetsView(this);
loadAssetsView.setOnAssetsLoadFinishListener(() -> {
XmagicResParser.parseRes(getApplicationContext());
initXMagic();
});
}
}
3. Enable push settings:
mTRTCCloud.setLocalVideoProcessListener(TRTCCloudDef.TRTC_VIDEO_PIXEL_FORMAT_Texture_2D, TRTCCloudDef.TRTC_VIDEO_BUFFER_TYPE_TEXTURE, new TRTCCloudListener.TRTCVideoFrameListener() {
@Override
public void onGLContextCreated() {
}
@Override
public int onProcessVideoFrame(TRTCCloudDef.TRTCVideoFrame srcFrame, TRTCCloudDef.TRTCVideoFrame dstFrame) {
}
@Override
public void onGLContextDestory() {
}
});
4. Pass textureId to the SDK for rendering: In the onProcessVideoFrame(TRTCCloudDef.TRTCVideoFrame srcFrame, TRTCCloudDef.TRTCVideoFrame dstFrame) method of the TRTCVideoFrameListener API, add the following code:
dstFrame.texture.textureId = mXMagic.process(srcFrame.texture.textureId, srcFrame.width, srcFrame.height);
5. Pause/Terminate the SDK: onPause() is used to pause beauty filter effects, which can be implemented in the Activity/Fragment method. The onDestroy method needs to be called in the GL thread (you can call onDestroy() of the XMagicImpl object in onTextureDestroyed). For more information, see the demo.
mXMagic.onPause(); // Pause, which is bound to the `onPause` method of `Activity`
mXMagic.onDestroy(); // Terminate, which needs to be called in the GL thread
6. Add the SDK beauty filter panel to the layout:
<RelativeLayout
android:layout_above="@+id/ll_edit_info"
android:id="@+id/livepusher_bp_beauty_pannel"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
7. Initialize the panel:
private void initXMagic() {
if (mXMagic == null) {
mXMagic = new XMagicImpl(this, mBeautyPanelView);
}else {
mXMagic.onResume();
}
}
See the ThirdBeautyActivity.initXMagic(); method of the demo for details.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback