startCameraCustomPreview API of the TXUGCRecord class to pass in custom shooting parameters, as shown below:// Custom configurationTXRecordCommon.TXUGCCustomConfig customConfig = new TXRecordCommon.TXUGCCustomConfig();customConfig.videoResolution = TXRecordCommon.VIDEO_RESOLUTION_540_960;customConfig.minDuration = mMinDuration; // Minimum durationcustomConfig.maxDuration = mMaxDuration; // Maximum durationcustomConfig.videoBitrate = mBiteRate; // Video bitratecustomConfig.videoGop = mGop; // GOP lengthcustomConfig.videoFps = mFps; // Frame rate in fpscustomConfig.isFront = mFront; // Whether to use the front cameramTXCameraRecord.startCameraCustomPreview(customConfig, mVideoView);
onRecordComplete callback after shooting ends on Android?setVideoRecordListener() API of the TXUGCRecord class to set a listener for the shooting callback.
To end shooting, you need to call the stopRecord() API of the TXUGCRecord class.// Before shootingmTXCameraRecord = TXUGCRecord.getInstance(this.getApplicationContext());mTXCameraRecord.setVideoRecordListener(this);...// End shootingmTXCameraRecord.stopRecord();
stopRecord, the video segments shot will be spliced, so after the onRecordComplete callback is received, the demo will call mTXCameraRecord.getPartsManager().deleteAllParts() to delete the segment files.mTXCameraRecord.getPartsManager().deleteAllParts().@Overridepublic void onRecordComplete(TXRecordCommon.TXRecordResult result) {TXCLog.i(TAG, "onRecordComplete, result retCode = " + result.retCode + ", descMsg = " + result.descMsg + ", videoPath + " + result.videoPath + ", coverPath = " + result.coverPath);if (mTXRecordResult.retCode < 0) {Toast.makeText(TCVideoRecordActivity.this.getApplicationContext(), "Shoot failed. Cause: " + mTXRecordResult.descMsg, Toast.LENGTH_SHORT).show();} else {mDuration = mTXCameraRecord.getPartsManager().getDuration(); // Total shooting durationif (mTXCameraRecord != null) {mTXCameraRecord.getPartsManager().deleteAllParts(); // Delete the video segments already shot}startPreview(); // Enter the preview page}
startRecord of TXUGCRecord) so that the settings can take effect. The call sequence in the code is as shown below:TXRecordCommon.TXUGCSimpleConfig simpleConfig = new TXRecordCommon.TXUGCSimpleConfig();simpleConfig.videoQuality = TXRecordCommon.VIDEO_QUALITY_MEDIUM;simpleConfig.minDuration = mMinDuration;simpleConfig.maxDuration = mMaxDuration;// 1. Start the preview firstmTXCameraRecord.startCameraSimplePreview(simpleConfig, mVideoView);// 2. Specify the path of the background music file and play the musicmBGMDuration = mTXCameraRecord.setBGM(mBGMPath);mTXCameraRecord.playBGMFromTime(0, mBGMDuration);// 3. Start shooting (`customVideoPath`: The path of the video generated. `customPartFolder`: The folder of the video segments shot. `customCoverPath`: The path of the thumbnail.)int result = mTXCameraRecord.startRecord(customVideoPath, customPartFolder, customCoverPath);
snapshot API of the TXUGCRecord class to take a photo, which will be returned asynchronously through the TXRecordCommon.ITXSnapshotListener callback. The sample code is as follows:private void snapshot() {if (mTXCameraRecord != null) {mTXCameraRecord.snapshot(new TXRecordCommon.ITXSnapshotListener() {@Overridepublic void onSnapshot(Bitmap bmp) {// Captured photosaveBitmap(bmp);}});}}
Definition | Constant in TXRecordCommon | Speed |
Ultra-slow | RECORD_SPEED_SLOWEST | 0.5x |
Slow | RECORD_SPEED_SLOW | 0.8x |
Standard | RECORD_SPEED_NORMAL | 1x |
Fast | RECORD_SPEED_FAST | 1.25x |
Ultra-fast | RECORD_SPEED_FASTEST | 1.5x |
setRecordSpeed(record) of TXUGCRecord to set the speed for shooting.mTXCameraRecord.setRecordSpeed(TXRecordCommon.RECORD_SPEED_FAST);
Resolution | Constant in TXVideoEditConstants |
360 × 640 | VIDEO_COMPRESSED_360P |
480 × 640 | VIDEO_COMPRESSED_480P |
540 × 960 | VIDEO_COMPRESSED_540P |
720 × 1280 | VIDEO_COMPRESSED_720P |
1080 × 1920 | VIDEO_COMPRESSED_1080P |
// Set the output video bitratemTXVideoEditer.setVideoBitrate(3600);// Set the output resolutionmTXVideoEditer.generateVideo(TXVideoEditConstants.VIDEO_COMPRESSED_720P, mVideoOutputPath);
// Set the original audio to 0 to remove the recorded background musicmTXVideoEditer.setVideoVolume(0.0f);// Specify the local path of the background music to useString bgmPath = getBGMPath();mTXVideoEditer.setBGM(bgmPath);// Set the volume of the background music. Value range: 0.0f-1.0fmTXVideoEditer.setBGMVolume(1.0f);
Activity window and the full screen mode to display the preview image?stopPlay first, modify the width and height of FrameLayout passed in to the SDK, call initWithPreview(parm), pass in the new FrameLayout, and call startPlay again.// Stop playbackmTXVideoEditer.stopPlay();if (isFullScreen) {// If the full screen mode is used, you can use the following code to switch to the window modeFrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1500);mVideoPlayerLayout.setLayoutParams(params);initPlayerLayout(false);isFullScreen = false;} else {// If the window mode is used, you can use the following code to switch to the full screen modeFrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);mVideoPlayerLayout.setLayoutParams(params);initPlayerLayout(false);isFullScreen = true;}// Start playbackmTXVideoEditer.startPlayFromTime(startTime, endTime);// Set the preview viewprivate void initPlayerLayout(boolean isFullScreen) {TXVideoEditConstants.TXPreviewParam param = new TXVideoEditConstants.TXPreviewParam();param.videoView = mVideoPlayerLayout;if (isFullScreen) {param.renderMode = TXVideoEditConstants.PREVIEW_RENDER_MODE_FILL_SCREEN;} else {param.renderMode = TXVideoEditConstants.PREVIEW_RENDER_MODE_FILL_EDGE;}mTXVideoEditer.initWithPreview(param);}
setCutTimeFrom) and preprocess (processVideo) a video first. Then, you can edit the clipped and preprocessed video. After editing, set the clipping duration (setCutTimeFrom) to the total duration of the edited video, and call generateVideo to generate the video. This can avoid reduced image quality caused by two compressions.// Clipping pagemTXVideoEditer = new TXVideoEditer(mContext);mTXVideoEditer.setCutFromTime(mTCVideoEditView.getSegmentFrom(), mTCVideoEditView.getSegmentTo());mTXVideoEditer.processVideo();// Set the clipping duration to the entire video duration (`setCutTimeFrom`)mTXVideoEditer.setCutFromTime(0, mVideoDuration);// Redirect to the special effects page for generationmTXVideoEditer.generateVideo(TXVideoEditConstants.VIDEO_COMPRESSED_720P, mVideoOutputPath);


abiFilters to armeabi in build.gradle in app.build.gradle of app to the name of the AAR file in /libs of your project. Then, clean your project and build it again.Feedback