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
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-04-01 17:14:08
Video shoot includes features such as adjustable-speed shoot, beauty filters, filters, sound effects, and background music configuration.

Overview of Relevant Classes

Class
Feature
TXUGCRecord
Video shoot implementation
TXUGCPartsManager
Video segment management class, which is used to shoot multiple video segments and delete existing segments
ITXVideoRecordListener
Shoot callback
TXRecordCommon
Basic parameter definition, including video shoot callback and release callback APIs

Basic Workflow

1. Configure the shoot parameters.
2. Start video image preview.
3. Set the shoot effects.
4. Complete shoot.
Basic code example for starting preview/recording(The following snippet demonstrates the core logic; implement the full code as needed):
TXUGCRecord mTXUGCRecord = TXUGCRecord.getInstance(context);

// Create a TXCloudVideoView for camera preview
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);

// 1. Configure recording parameters (using recommended TXUGCSimpleConfig)
TXRecordCommon.TXUGCSimpleConfig param = new TXRecordCommon.TXUGCSimpleConfig();
param.videoQuality = TXRecordCommon.VIDEO_QUALITY_MEDIUM;

// 2. Start camera preview
mTXUGCRecord.startCameraSimplePreview(param, mVideoView);

// 3. Set recording effects (example: add beauty filter)
mTXUGCRecord.getBeautyManager().setBeautyStyle(TXBeautyManager.TXBeautyStyleSmooth);
mTXUGCRecord.getBeautyManager().setBeautyLevel(5);

// 4. Set recording event callback listener
mTXUGCRecord.setVideoRecordListener(new ITXVideoRecordListener() {
@Override
public void onRecordEvent(int eventId, Bundle bundle) {}

@Override
public void onRecordProgress(long millisecond) {}

@Override
public void onRecordComplete(TXRecordResult result) {}
});

// Start recording
int result = mTXUGCRecord.startRecord();

// Stop recording
mTXUGCRecord.stopRecord();

Previewing Video Image

TXUGCRecord (in TXUGCRecord.java) is used for short video shoot. The preview feature needs to be implemented first, where the startCameraSimplePreview function is used to start preview. As camera and mic need to be enabled before the preview can be started, prompt windows for permission application may pop up at this point.

1. Start Preview

// Get the singleton instance of the recorder
TXUGCRecord mTXUGCRecord = TXUGCRecord.getInstance(this.getApplicationContext());

// Configure basic recording parameters
TXRecordCommon.TXUGCSimpleConfig param = new TXRecordCommon.TXUGCSimpleConfig();
param.videoQuality = TXRecordCommon.VIDEO_QUALITY_HIGH; // 720p
param.isFront = true; // Whether to use the front camera
param.minDuration = 5000; // Minimum recording duration (ms)
param.maxDuration = 60000; // Maximum recording duration (ms)
param.touchFocus = false; // false: auto-focus; true: manual focus

// Video preview view
mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);

// Start preview
mTXUGCRecord.startCameraSimplePreview(param, mVideoView);

// Stop camera preview
mTXUGCRecord.stopCameraPreview();

2. Modify Preview Parameters

After starting the camera, you can adjust the preview parameters as follows:
// Switch video recording resolution to 540p (540x960)
mTXUGCRecord.setVideoResolution(TXRecordCommon.VIDEO_RESOLUTION_540_960);

// Switch video recording bitrate to 6500 Kbps
mTXUGCRecord.setVideoBitrate(6500);

// Get the maximum zoom level supported by the camera
mTXUGCRecord.getMaxZoom();

// Set zoom level to 3. Valid range: 0 ~ getMaxZoom()
mTXUGCRecord.setZoom(3);

// Switch camera: true for front camera, false for rear camera
mTXUGCRecord.switchCamera(false);

// Toggle flash: true to turn on, false to turn off
mTXUGCRecord.toggleTorch(false);

// When param.touchFocus is true (manual focus mode), use this API to set focus position
mTXUGCRecord.setFocusPosition(eventX, eventY);

// Set custom video processing callback
mTXUGCRecord.setVideoProcessListener(this);

Photo Capture

After enabling the camera preview, you can use the photo capturing feature.
// Take a photo. Before calling this API, you must start the recording preview by calling either startCameraSimplePreview or startCameraCustomPreview
mTXUGCRecord.snapshot(new TXRecordCommon.ITXSnapshotListener() {
@Override
public void onSnapshot(Bitmap bmp) {
// Save or display the captured image
}
});

Shooting Control

The shoot can be started, paused, and resumed as follows:
// Start recording
// This method does not specify the recording file path. The path will be returned in the recording completion callback.
mTXUGCRecord.startRecord();

// Start recording with specified output video file path and cover image path
mTXUGCRecord.startRecord(videoFilePath, coverPath);

// Start recording with specified output video file path, video segments folder path, and cover image path
mTXUGCRecord.startRecord(videoFilePath, videoPartFolder, coverPath);

// Pause recording
mTXUGCRecord.pauseRecord();

// Resume recording
mTXUGCRecord.resumeRecord();

// Stop recording
mTXUGCRecord.stopRecord();
The shoot process and result will be returned through the TXRecordCommon.ITXVideoRecordListener API (defined in TXRecordCommon.java):
onRecordProgress returns the shoot progress, and the millisecond parameter indicates the shoot duration in milliseconds.
@optional
void onRecordProgress(long milliSecond);
onRecordComplete returns the shoot result, the retCode and descMsg fields of TXRecordResult indicate the error code and error message, respectively, videoPath indicates the path of the shot short video file, and coverImage indicates the short video's first-frame image that is automatically captured and will be used in video release.
@optional
void onRecordComplete(TXRecordResult result);
onRecordEvent is the shoot event callback, which contains the event ID and event-related parameters in the format of (key,value).
@optional
void onRecordEvent(final int event, final Bundle param);

Shooting Settings

1. Video Image

// Set orientation for preview
// The valid values for `rotation` are 0, 90, 180, and 270, which indicate the clockwise rotation angle.
// You must set the rotation before you call `startRecord` for the setting to take effect.
mTXUGCRecord.setRenderRotation(TXLiveConstants.RENDER_ROTATION_PORTRAIT);

// Set the aspect ratio
// VIDEO_ASPECT_RATIO_9_16: 9:16
// VIDEO_ASPECT_RATIO_3_4: 3:4
// VIDEO_ASPECT_RATIO_1_1: 1:1
// You must set the rotation before you call `startRecord` for the setting to take effect.
mTXUGCRecord.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_9_16);

2. Speed

// Set the video shoot speed
// TXRecordCommon.RECORD_SPEED_SLOWEST (ultra-slow)
// TXRecordCommon.RECORD_SPEED_SLOW (slow)
// TXRecordCommon.RECORD_SPEED_NORMAL (standard)
// TXRecordCommon.RECORD_SPEED_FAST (fast)
// TXRecordCommon.RECORD_SPEED_FASTEST (ultra-fast)
mTXUGCRecord.setRecordSpeed(TXRecordCommon.VIDEO_RECORD_SPEED_NORMAL);

3. Audio


// Set the mic volume. This is used to control the volume of the mic when background music is mixed.
// Volume. The normal volume is 1. We recommend 0-2, but you can set it to a larger value if you want louder music.
mTXUGCRecord.setMicVolume(volume);

// Mute/Unmute. The `isMute` parameter specifies whether to mute audio. Audio is unmuted by default.
mTXUGCRecord.setMute(isMute);

Effects

You can add various effects to your video during shooting.

1. Watermark

// Add a global watermark
// normalizationFrame: The normalized position of the watermark in relation to the video. The SDK calculates the watermark height based on the aspect ratio.
// Suppose the video dimensions are 540 x 960, and `frame` is set to `(0.1,0.1,0.1, 0)`.
// The actual coordinates of the watermark would be:
// (540*0.1, 960*0.1, 540*0.1, 540*0.1*waterMarkImage.size.height / waterMarkImage.size.width)
mTXUGCRecord.setWatermark(watermarkBitmap, txRect)

2. Filter

// Set the filter style
// Set the color filter: Romantic, refreshing, elegant, pink, retro, and more
// filterImage: The color lookup table, which must be in PNG format.
// The color lookup table used in the demo is in `FilterResource.bundle`.
mTXUGCRecord.setFilter(filterBitmap);

// Set the strength of filters. Value range: 0-1. Default: 0.5. The greater the value, the stronger the filter.
mTXUGCRecord.setSpecialRatio(0.5);

// Set a filter combination
// mLeftBitmap: The left filter
// leftIntensity: The strength of the left filter
// mRightBitmap: The right filter
// rightIntensity: The strength of the right filter
// leftRatio: The ratio of the width of the left picture to the video width
// You can use this API to implement "swipe to change filter".
mTXUGCRecord.setFilter(mLeftBitmap, leftIntensity, mRightBitmap, rightIntensity, leftRatio);

3. Beauty

// Access Beauty Configuration Interface
TXBeautyManager mTXBeautyManager = mTXCameraRecord.getBeautyManager();
// Set beauty style: (TXBeautyStyleSmooth: Smooth; TXBeautyStyleNature: Natural; TXBeautyStylePitu: Pitu)
mTXBeautyManager.setBeautyStyle(TXBeautyManager.TXBeautyStyleSmooth);
// Set beauty level (0-9)
mTXBeautyManager.setBeautyLevel(5);
// Set whitening level (0-9)
mTXBeautyManager.setWhitenessLevel(5);
// Set rosy level (0-9)
mTXBeautyManager.setRuddyLevel(5);

Advanced Features

도움말 및 지원

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

피드백