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:09
The TXVideoJoiner can merge multiple videos either by sequentially concatenating them or by combining their frames in a split-screen layout.

1. Basic Video Concatenation

To simply concatenate multiple video files sequentially, refer to the following code:
mTXVideoJoiner = new TXVideoJoiner(mContext);

// Set the video source list. A return value < 0 indicates invalid or unsupported formats in the input files.
if (mTXVideoJoiner.setVideoPathList(videoSourceList) < 0) {
return;
}

// Set a listener to track concatenation progress and completion.
mTXVideoJoiner.setVideoJoinerListener(new TXVideoJoinerListener() {
@Override
public void onJoinProgress(float progress) {}

@Override
public void onJoinComplete(TXJoinerResult result) {}
});

// Start concatenation. Specify the output resolution and path.
// Note: If all input videos share the same format and resolution, concatenation is fast.
// Otherwise, re-encoding is required, which slows the process.
mTXVideoJoiner.joinVideo(TXVideoEditConstants.VIDEO_COMPRESSED_540P, mOutputPath);

2. Preview Before Concatenation

To preview the concatenated videos before merging, use the following code:
mTXVideoJoiner = new TXVideoJoiner(mContext);

// Set the video source list.
if (mTXVideoJoiner.setVideoPathList(videoSourceList) < 0) {
return;
}

// Set a listener for preview progress and completion.
mTXVideoJoiner.setTXVideoPreviewListener(new TXVideoPreviewListener() {
@Override
public void onPreviewProgress(int time) {}

@Override
public void onPreviewFinished() {}
});

// Prepare the preview view.
TXVideoEditConstants.TXPreviewParam param = new TXVideoEditConstants.TXPreviewParam();
param.videoView = mVideoView;
param.renderMode = TXVideoEditConstants.PREVIEW_RENDER_MODE_FILL_EDGE;
mTXVideoJoiner.initWithPreview(param);

// Start preview.
mTXVideoJoiner.startPlay();
Control playback with:
startPlay: Start preview
pausePlay: Pause preview
resumePlay: Resume preview

3. Split-Screen Video Merging

TXVideoJoiner also supports merging multiple videos into a split-screen layout. Example code:
mTXVideoJoiner = new TXVideoJoiner(mContext);

// Set the video source list.
if (mTXVideoJoiner.setVideoPathList(videoSourceList) < 0) {
return;
}

// Set a listener for split-screen merging progress and completion.
mTXVideoJoiner.setVideoJoinerListener(new TXVideoJoinerListener() {
@Override
public void onJoinProgress(float progress) {}

@Override
public void onJoinComplete(TXJoinerResult result) {}
});

// Configure split-screen layout parameters.
SplitScreenParam splitScreenParam = new SplitScreenParam();
splitScreenParam.canvasWidth = 720; // Canvas width during split-screen joining
splitScreenParam.canvasHeight = 1280; // Canvas height
splitScreenParam.durationControlMode = DurationControlMode.ALIGNS_TO_LONGEST; // Duration matches the longest video

// Define positions and sizes for each video on the canvas.
TXAbsoluteRect rect1 = new TXAbsoluteRect();
TXAbsoluteRect rect2 = new TXAbsoluteRect();
splitScreenParam.rects.add(rect1);
splitScreenParam.rects.add(rect2);
mTXVideoJoiner.setSplitScreenList(splitScreenParam);

// Set audio mixing weights for each video (e.g., video1: 100% volume, video2: 0%).
List<Float> volumes = new LinkedList<>();
volumes.add(1.0f);
volumes.add(0.0f);
mTXVideoJoiner.setVideoVolumes(volumes);

// Start split-screen merging.
// If input videos differ in format or resolution, re-encoding is required, which may slow the process.
mTXVideoJoiner.splitJoinVideo(TXVideoEditConstants.VIDEO_COMPRESSED_540P, mOutputPath);
When configuring split-screen layout parameters via setSplitScreenList and audio mixing ratios via setVideoVolumes, these settings apply to ​both the final video output (generated by splitJoinVideo) ​andthe live preview during editing.



도움말 및 지원

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

피드백