tencent cloud

User Generated Short Video SDK

Android

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-10-09 15:53:50
AI 번역

Developer Environment Requirements

Devices with Android 7.0 (SDK API Level 24) or above are recommended. Android Studio 3.5 or above.

Integrate the SDK

The Tencent Effect SDK has been published to the mavenCentral repository. You can configure gradle to automatically download and update it.
1. Add the beauty effect SDK dependency in dependencies.
dependencies {
//For example: the S1-04 package is as follows:
implementation 'com.tencent.mediacloud:TencentEffect_S1-04:version number'
//The "version number" can be seen on the official website's "SDK Download / Version History" page, for example 3.0.0.13. The "version number" can also use "latest.release",
//But please note: this will keep the SDK you use always at the latest version, which may not meet your expectations on some versions with major changes. Please use "latest.release" with caution
}
2. In defaultConfig, specify the CPU architecture used by the App.
defaultConfig {
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
Note:
Currently the effect SDK supports armeabi-v7a and arm64-v8a.
3. Click
img

Sync Now to automatically download the SDK and integrate it into the project.
Maven addresses corresponding to each package
Version
Maven Address
A1 - 01
implementation 'com.tencent.mediacloud:TencentEffect_A1-01:version number'
A1 - 02
implementation 'com.tencent.mediacloud:TencentEffect_A1-02:version number'
A1 - 03
implementation 'com.tencent.mediacloud:TencentEffect_A1-03:version number'
A1 - 04
implementation 'com.tencent.mediacloud:TencentEffect_A1-04:version number'
A1 - 05
implementation 'com.tencent.mediacloud:TencentEffect_A1-05:version number'
A1 - 06
implementation 'com.tencent.mediacloud:TencentEffect_A1-06:version number'
S1 - 00
implementation 'com.tencent.mediacloud:TencentEffect_S1-00:version number'
S1 - 01
implementation 'com.tencent.mediacloud:TencentEffect_S1-01:version number'
S1 - 02
implementation 'com.tencent.mediacloud:TencentEffect_S1-02:version number'
S1 - 03
implementation 'com.tencent.mediacloud:TencentEffect_S1-03:version number'
S1 - 04
implementation 'com.tencent.mediacloud:TencentEffect_S1-04:version number'
S1 - 05
implementation 'com.tencent.mediacloud:TencentEffect_S1-05:version number'
S1 - 06
implementation 'com.tencent.mediacloud:TencentEffect_S1-06:version number'
S1 - 07
implementation 'com.tencent.mediacloud:TencentEffect_S1-07:version number'
Attention:
For more resources configurations, refer to effect resources usage guide.

Integrate Effect Resources

If your package includes dynamic effect and filter features, you need to download the corresponding resources from the SDK Download Page and place the dynamic effect and filter materials in the following directories under your project:
Dynamic effect: ../assets/MotionRes
Filter: ../assets/lut
For more resources configurations, refer to effect resources usage guide.

SDK Usage Flow

Step 1: Authentication

1. Apply for authorization to obtain the license URL and license key. Please refer to the License Guide.
2. Set the URL and KEY in the initialization code of the relevant business module, to trigger the License download and avoid downloading it temporarily right before use. For example, our demo project triggers the download in the Application's onCreate method, but in your project it is not recommended to trigger it here, because there may be no network permission or a high network failure rate at this time. Please choose a more appropriate time to trigger the license download.
//If it is only to trigger downloading or updating the license, without caring about the authentication result, pass null for the 4th parameter.
TELicenseCheck.getInstance().setTELicense(context, URL, KEY, null);
3. Then, before actually using the beauty function, perform the authentication:
TELicenseCheck.getInstance().setTELicense(context, URL, KEY, new TELicenseCheckListener() {

@Override
public void onLicenseCheckFinish(int errorCode, String msg) {
//Note: this callback is not necessarily on the calling thread
if (errorCode == TELicenseCheck.ERROR_OK) {
//Authentication succeeded
} else {
//Authentication failed
}
}
});
Authentication error code description:
Error Code
Description
0
Success.
-1
Invalid input parameters, such as empty URL or KEY.
-3
Download failure. Please check your network settings.
-4
TE authorization information read locally is empty, possibly due to I/O failure.
-5
Content of the VCUBE TEMP license file is empty, possibly due to I/O failure.
-6
JSON fields in the v_cube.license file are incorrect. Please contact the Tencent Cloud team to deal with it.
-7
Signature verification failed. Please contact the Tencent Cloud team to deal with it.
-8
Decryption failed. Please contact the Tencent Cloud team to deal with it.
-9
JSON fields in the TELicense field are incorrect. Please contact the Tencent Cloud team to deal with it.
-10
The TE authorization information parsed from the network is empty. Please contact the Tencent Cloud team to deal with it.
-11
Failed to write TE authorization information to a local file, possibly due to I/O failure.
-12
Download failed, and parsing local assets also failed.
-13
Authentication failed. Please check if the .so file is in the package or if the .so path is set correctly.
3004/3005
Invalid authorization. Please contact the Tencent Cloud team to deal with it.
3015
Bundle ID/Package Name mismatch. Check if the Bundle ID/Package Name used by your app is consistent with the applied one, and ensure you are using the correct license file.
3018
The license file has expired. You need to apply for a renewal from Tencent Cloud.
Others
Please contact the Tencent Cloud team to deal with it.

Step 2: Resource Copying

The resource files referred to here include two parts:
The SDK model files, located in the assets directory of the SDK's aar package.
The filter and effect resource files, located in the assets directory of the demo project, named lut and MotionRes respectively.
Before using beauty, you need to copy the above resources to the app's private directory. When the SDK version has not been updated, you only need to copy them once. After the copy succeeds, you can record it in the App's SharedPreferences, and you won't need to copy again next time. For details, please refer to TEMenuActivity.java in the demo project.
String resPath = new File(getFilesDir(), AppConfig.getInstance().getBeautyFileDirName()).getAbsolutePath();
if (!resPath.endsWith(File.separator)) {
resPath = resPath + File.separator;
}
AppConfig.resPathForSDK = resPath;
AppConfig.lutFilterPath = resPath + "light_material/lut";
AppConfig.motionResPath = resPath + "MotionRes";
new Thread(() -> {
Context context = getApplicationContext();
int addResult = XmagicApi.addAiModeFilesFromAssets(context, AppConfig.resPathForSDK);
Log.d(TAG, "copyRes, add ai model files result = " + addResult);
String lutDirNameInAsset = "lut";
boolean result = FileUtil.copyAssets(context, lutDirNameInAsset, AppConfig.lutFilterPath);
Log.d(TAG, "copyRes, copy lut, result = " + result);
String motionResDirNameInAsset = "MotionRes";
boolean result2 = FileUtil.copyAssets(context, motionResDirNameInAsset, AppConfig.motionResPath);
Log.d(TAG, "copyRes, copy motion res, result = " + result2);
}).start();

Step 3: SDK Initialization and Usage

1. Initialization.
XmagicApi xmagicApi = new XmagicApi(context, effectMode, mResPath, (errorMsg, code) -> {
LogUtils.e(TAG, "createXMagicApi errorMsg = " + errorMsg + " code = " + code);
});
2. Call the setVideoProcessListener method of TXUGCRecord to set the preprocessing callback interface.
TXUGCRecord instance = TXUGCRecord.getInstance(UGCKit.getAppContext());
instance.setVideoProcessListener(new TXUGCRecord.VideoCustomProcessListener() {
@Override
public int onTextureCustomProcess(int textureId, int width, int height) {
if (xmagicApi != null) {
return xmagicApi.process(textureId, width, height);
}
return textureId;
}

@Override
public void onDetectFacePoints(float[] floats) {
}

@Override
public void onTextureDestroyed() {
if (Looper.getMainLooper() != Looper.myLooper()) { //non-main thread
xmagicApi.onDestroy()
}
}
});
3. Set beauty properties. For specific parameters, please refer to Beauty parameter description.
xmagicApi.seteffect();
4. Destroy. Note that you need to judge in onTextureDestroyed that it is the GL thread before destroying.
xmagicApi.onDestroy()

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백