tencent cloud


Last updated: 2022-01-26 10:13:11

    Can I customize the shooting resolution of short videos? What custom resolutions can I use?

    The customizable parameters of short video shooting include frame rate (number of frames per second), GOP length (number of seconds between key I frames), video bitrate (volume of audio/video data generated by the encoder per second), and maximum/minimum shooting duration. We offer 4 shooting resolutions as constants for your choice: 360 × 640, 540 × 960, 720 × 1280, and 1080 × 1920.

    The following describes why the shooting resolution is set through a constant instead of a variable:

    • The 4 constants are mainstream shooting resolutions.
    • Android phones may not support non-mainstream resolutions, the use of which may lead to problems such as green screen and pixelation.

    You can call the startCameraCustomPreview API of the TXUGCRecord class to pass in custom shooting parameters, as shown below:

    // Custom configuration
    TXRecordCommon.TXUGCCustomConfig customConfig = new TXRecordCommon.TXUGCCustomConfig();
    customConfig.videoResolution =  TXRecordCommon.VIDEO_RESOLUTION_540_960;
    customConfig.minDuration = mMinDuration;  // Minimum duration
    customConfig.maxDuration = mMaxDuration;  // Maximum duration
    customConfig.videoBitrate = mBiteRate;    // Video bitrate
    customConfig.videoGop = mGop;             // GOP length
    customConfig.videoFps = mFps;             // Frame rate in fps
    customConfig.isFront = mFront;            // Whether to use the front camera
    mTXCameraRecord.startCameraCustomPreview(customConfig, mVideoView);

    Why can’t I receive the onRecordComplete callback after shooting ends on Android?

    Before shooting a short video, please call the 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 shooting
    mTXCameraRecord = TXUGCRecord.getInstance(this.getApplicationContext());


    // Ending shooting

    How do I resume shooting from where I stopped last time?

    The demo will call mTXCameraRecord.getPartsManager().deleteAllParts() after the onRecordComplete callback to clear segment files because stopRecord has composed the segment files.

    To resume shooting from where you stopped, you do not need to call mTXCameraRecord.getPartsManager().deleteAllParts() to delete the segments.

    public 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 duration
          if (mTXCameraRecord != null) {
              mTXCameraRecord.getPartsManager().deleteAllParts();  // Delete multiple shot segment files
          startPreview(); // Enter the preview page

    Why are background music settings for shooting not working?

    You must set the background music before calling the shooting API (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 first
    mTXCameraRecord.startCameraSimplePreview(simpleConfig, mVideoView);
    // 2. Set the path of the background music file and play back the music
    mBGMDuration = mTXCameraRecord.setBGM(mBGMPath);
    mTXCameraRecord.playBGMFromTime(0, mBGMDuration);
    // 3. Start shooting (`customVideoPath`: path of the shot video; `customPartFolder`: folder of the shot video; `customCoverPath`: path of the shot video cover)
    int result = mTXCameraRecord.startRecord(customVideoPath, customPartFolder, customCoverPath);

    Does UGSV support photo taking?

    You can call the 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() {
              public void onSnapshot(Bitmap bmp) {
                  // Captured photo

    What speed changing options can I use during shooting?

    You cannot customize speed for shooting.

    Definition Constant in TXRecordCommon Speed
    Ultra-slow RECORD_SPEED_SLOWEST 0.5x
    Fast RECORD_SPEED_FAST 1.25x
    Ultra-fast RECORD_SPEED_FASTEST 1.5x

    You can call setRecordSpeed(record) of TXUGCRecord to set the speed for shooting.


    What formats are supported for video importing? Can I import videos with a resolution higher than 720p (such as 2K and 4K)? Is there an upper limit on the size of imported videos?

    Currently, you can import only MP4 video files on Android. There are no limits on the resolution or size of imported files.

    • The resolution of imported videos is not limited. The maximum video resolution after preprocessing is 720p, no matter how high the original video resolution is.
    • To speed up video import, the SDK allows you to skip preprocessing since v4.7, but some features, such as reversed playback and frame-specific preview, become unavailable. For videos whose resolution is higher than 720p, you are not advised to skip preprocessing. Preview requires the decoding of every frame. On phones with poor performance, it may take a long time for a frame to be decoded and rendered, resulting in stutter.

    What background music formats are supported during short video editing?

    Currently, only MP3 and M4A files are supported.

    What custom outputs does short video editing support?

    Editing supports custom video bitrate (in SDK 4.5 or later) and audio bitrate (in SDK 4.7 or later), and offers resolutions as constants for your choice: 360 × 640, 480 × 640, 540 × 960, 720 × 1280, and 1080 × 1920.

    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 bitrate
    // Set the output resolution
    mTXVideoEditer.generateVideo(TXVideoEditConstants.VIDEO_COMPRESSED_720P, mVideoOutputPath);

    Can I separate audio from the videos shot?

    Currently, the SDK does not support recording background music and human voice at the same time. Therefore, to change background music during editing, just set the volume of the original audio to 0. See the code below for detailed directions:

    // Set the original audio to 0 to remove the recorded background music
    // Specify the local path of the background music to use
    String bgmPath = getBGMPath();
    // Set the volume of the background music. Value range: 0.0f-1.0f

    How do I switch between the Activity window and the full screen mode to display the preview image?

    You need to dynamically modify the dimensions of the parent layout for the video preview view passed in to the SDK. The SDK will internally adjust the video dimensions dynamically according to the video width and height and the parent layout dimensions.
    The APIs of the SDK need to be called in the following sequence:
    Call stopPlay first, modify the width and height of FrameLayout passed in to the SDK, call initWithPreview(parm), pass in the layout that loads the playback component of the new FrameLayout, and call startPlay again.

    // Stop playback
    if (isFullScreen) {
      // If the full screen mode is used, you can use the following code to switch to the window mode
      FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1500);
      isFullScreen = false;
    } else {
      // If the window mode is used, you can use the following code to switch to the full screen mode
      FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      isFullScreen = true;
    // Start playback
    mTXVideoEditer.startPlayFromTime(startTime, endTime);
    // Set the preview view
    private 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;

    The UGSV demo places features such as "clipping" and "filters" on the same page for short video editing, but how can I place "clipping" and "filters" on different pages?

    You can clip (setCutTimeFrom) and preprocess (processVideo) a video at the same time first, and a clipped and preprocessed video will be generated. Then, you can perform various editing operations and clip the video with the entire video duration as the clipping duration (setCutTimeFrom). Finally, call generateVideo to generate the video to avoid reduced image quality caused by two rounds of compression.


    If a video has been clipped during preprocessing, during the final generation, you must set the clipping duration to the entire video duration. Otherwise, the video will be clipped again.

    // Clipping page
    mTXVideoEditer = new TXVideoEditer(mContext);
    mTXVideoEditer.setCutFromTime(mTCVideoEditView.getSegmentFrom(), mTCVideoEditView.getSegmentTo());

    // Set the clipping duration to the entire video duration (`setCutTimeFrom`)
    mTXVideoEditer.setCutFromTime(0, mVideoDuration);
    // Redirect to the special effects page for generation
    mTXVideoEditer.generateVideo(TXVideoEditConstants.VIDEO_COMPRESSED_720P, mVideoOutputPath);
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support