tencent cloud

User Generated Short Video SDK

뉴스 및 공지사항
Release Notes
The “startPlay” API of the UGSV SDK Renamed
제품소개
Overview
Features
Use Cases
Concepts
구매 가이드
Pricing Overview
Refund Policy
라이선스 가이드
Adding and Renewing a License
Configuring and Viewing a License
SDK 다운로드
SDK Download
Release Notes (App)
UI 통합 솔루션 포함
UGSV Demo App
Source Code Description (iOS)
Source Code Description (Android)
UI 통합 솔루션 없음
SDK Integration
Capturing and Shoot
Preview, Clipping, and Splicing
Upload and Playback
Tencent Effect SDK
Advanced Features and Special Effects
API 문서
Editing
Shooting
기술적 지원
Error Codes
Feature FAQs
일반적인 문제
Upload
Android Compilation
Android
iOS
License
UGSV 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약

Android

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2022-11-14 18:18:58

Step 1. Replace resources

1. Download the UGSV demo which has been integrated with the Tencent Effect SDK. This demo is built based on the Tencent Effect SDK S1-04 edition.
2. Replace resources: As the SDK edition used by the demo project may be different from the SDK edition you actually use, you need to replace the different SDK files in the demo with the files in the SDK edition you actually use as follows:
In the build.gradle file of the xmagickit module, find the following:
api 'com.tencent.mediacloud:TencentEffect_S1-04:latest.release'
Replace it with the SDK edition you purchased as described in Integrating the Tencent Effect SDK (Android).
If your edition contains animated effects and filters, you need to download the corresponding resources on the Tencent Effect SDK download page and put them in the following directories of the xmagickit module respectively:
Animated effects: ../assets/MotionRes.
Filters: ../assets/lut.
3. Import the xmagickit module from the demo into your actual project.

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

Replace the applicationId with the package name under the obtained trial license.

Step 3. Integrate the SDK APIs

You can refer to the UGCKitVideoRecord class of the demo.
1. Authorize:
// For details about authentication and error codes, see https://www.tencentcloud.com/document/product/1143/45385#.E6.AD.A5.E9.AA.A4.E4.B8.80.EF.BC.9A.E9.89.B4.E6.9D.83
XMagicImpl.checkAuth(new TELicenseCheck.TELicenseCheckListener() {
@Override
public void onLicenseCheckFinish(int errorCode, String msg) {
if (errorCode == TELicenseCheck.ERROR_OK) {
loadXmagicRes();
} else {
Log.e("TAG", "auth fail, please check auth url and key" + errorCode + " " + msg);
}
}
});
2. Initialize the material:
private void loadXmagicRes() {
if (XMagicImpl.isLoadedRes) {
XmagicResParser.parseRes(mActivity.getApplicationContext());
initXMagic();
return;
}
new Thread(new Runnable() {
@Override
public void run() {
XmagicResParser.copyRes(mActivity.getApplicationContext());
XmagicResParser.parseRes(mActivity.getApplicationContext());
XMagicImpl.isLoadedRes = true;
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
initXMagic();
}
});
}
}).start();
}
3. Bind beauty filters to UGSV:
private void initBeauty() {
TXUGCRecord instance = TXUGCRecord.getInstance(UGCKit.getAppContext());
instance.setVideoProcessListener(new TXUGCRecord.VideoCustomProcessListener() {
@Override
public int onTextureCustomProcess(int textureId, int width, int height) {
if (xmagicState == XMagicImpl.XmagicState.STARTED && mXMagic != null) {
return mXMagic.process(textureId, width, height);
}
return textureId;
}

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

@Override
public void onTextureDestroyed() {
if (Looper.getMainLooper() != Looper.myLooper()) { // Not the main thread
boolean stopped = xmagicState == XMagicImpl.XmagicState.STOPPED;
if (stopped || xmagicState == XMagicImpl.XmagicState.DESTROYED) {
if (mXMagic != null) {
mXMagic.onDestroy();
}
}
if (xmagicState == XMagicImpl.XmagicState.DESTROYED) {
TXUGCRecord.getInstance(UGCKit.getAppContext()).setVideoProcessListener(null);
}
}
}
});
}
4. Pause/Terminate the SDK:
onPause() is used to pause the beauty filter effect, which can be executed in the Activity/Fragment lifecycle method. The onDestroy method needs to be called in the GL thread (the onDestroy() of the XMagicImpl object can be called in the onTextureDestroyed method). For more information, see the onTextureDestroyed method in the sample code.
@Override
public void onTextureDestroyed() {
if (Looper.getMainLooper() != Looper.myLooper()) { // Not the main thread
boolean stopped = xmagicState == XMagicImpl.XmagicState.STOPPED;
if (stopped || xmagicState == XMagicImpl.XmagicState.DESTROYED) {
if (mXMagic != null) {
mXMagic.onDestroy();
}
}
if (xmagicState == XMagicImpl.XmagicState.DESTROYED) {
TXUGCRecord.getInstance(UGCKit.getAppContext()).setVideoProcessListener(null);
}
}
}
5. Add the beauty filter panel to the layout:
<RelativeLayout
android:id="@+id/panel_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"/>
6. Create a beauty filter object and add the beauty filter panel.
private void initXMagic() {
if (mXMagic == null) {
mXMagic = new XMagicImpl(mActivity, getBeautyPanel());
} else {
mXMagic.onResume();
}
}
For detailed directions, see the UGCKitVideoRecord class of the demo.

도움말 및 지원

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

피드백