产品动态
关于短视频 SDK “startPlay”接口名变更的公告

// 录制的界面mVideoView = mVideoViewFollowShotRecord;// 播放的视频mFollowShotVideoPath = intent.getStringExtra(TCConstants.VIDEO_EDITER_PATH);mFollowShotVideoDuration = (int)(intent.getFloatExtra(TCConstants.VIDEO_RECORD_DURATION, 0) * 1000);initPlayer();// 录制进度条以跟拍视频的进度为最大长度,fps 以跟拍视频的 fps 为准mMaxDuration = (int)mFollowShotVideoDuration;mFollowShotVideoFps = intent.getIntExtra(TCConstants.RECORD_CONFIG_FPS, 20);mFollowShotAudioSampleRateType = intent.getIntExtra(TCConstants.VIDEO_RECORD_AUDIO_SAMPLE_RATE_TYPE, TXRecordCommon.AUDIO_SAMPLERATE_48000);// 初始化合拍的接口mTXVideoJoiner = new TXVideoJoiner(this);mTXVideoJoiner.setVideoJoinerListener(this);
// 播放器初始化,这里使用 TXVideoEditer,也可以使用 TXVodPlayermTXVideoEditer = new TXVideoEditer(this);mTXVideoEditer.setVideoPath(mFollowShotVideoPath);TXVideoEditConstants.TXPreviewParam param = new TXVideoEditConstants.TXPreviewParam();param.videoView = mVideoViewPlay;param.renderMode = TXVideoEditConstants.PREVIEW_RENDER_MODE_FILL_EDGE;mTXVideoEditer.initWithPreview(param);
customConfig.videoFps = mFollowShotVideoFps;customConfig.audioSampleRate = mFollowShotAudioSampleRateType; // 录制的视频的音频采样率必须与跟拍的音频采样率相同customConfig.needEdit = false;mTXCameraRecord.setVideoRenderMode(TXRecordCommon.VIDEO_RENDER_MODE_ADJUST_RESOLUTION); // 设置渲染模式为自适应模式mTXCameraRecord.setMute(true); // 跟拍不从喇叭录制声音,因为跟拍的视频声音也会从喇叭发出来被麦克风录制进去,造成跟原视频声音的"二重唱"。
private void prepareToJoiner(){List<String> videoSourceList = new ArrayList<>();videoSourceList.add(mRecordVideoPath);videoSourceList.add(mFollowShotVideoPath);mTXVideoJoiner.setVideoPathList(videoSourceList);mFollowShotVideoOutputPath = getCustomVideoOutputPath("Follow_Shot_");// 以左边录制的视频宽高为基准,右边视频等比例缩放int followVideoWidth;int followVideoHeight;if ((float) followVideoInfo.width / followVideoInfo.height >= (float)recordVideoInfo.width / recordVideoInfo.height) {followVideoWidth = recordVideoInfo.width;followVideoHeight = (int) ((float)recordVideoInfo.width * followVideoInfo.height / followVideoInfo.width);} else {followVideoWidth = (int) ((float)recordVideoInfo.height * followVideoInfo.width / followVideoInfo.height);followVideoHeight = recordVideoInfo.height;}TXVideoEditConstants.TXAbsoluteRect rect1 = new TXVideoEditConstants.TXAbsoluteRect();rect1.x = 0; //第一个视频的左上角位置rect1.y = 0;rect1.width = recordVideoInfo.width; //第一个视频的宽高rect1.height = recordVideoInfo.height;TXVideoEditConstants.TXAbsoluteRect rect2 = new TXVideoEditConstants.TXAbsoluteRect();rect2.x = rect1.x + rect1.width; //第2个视频的左上角位置rect2.y = (recordVideoInfo.height - followVideoHeight) / 2;rect2.width = followVideoWidth; //第2个视频的宽高rect2.height = followVideoHeight;List<TXVideoEditConstants.TXAbsoluteRect> list = new ArrayList<>();list.add(rect1);list.add(rect2);mTXVideoJoiner.setSplitScreenList(list, recordVideoInfo.width + followVideoWidth, recordVideoInfo.height); //第2、3个 param:两个视频合成画布的宽高mTXVideoJoiner.splitJoinVideo(TXVideoEditConstants.VIDEO_COMPRESSED_540P, mFollowShotVideoOutputPath);}
@Overridepublic void onJoinComplete(TXVideoEditConstants.TXJoinerResult result) {mCompleteProgressDialog.dismiss();if(result.retCode == TXVideoEditConstants.JOIN_RESULT_OK){runOnUiThread(new Runnable() {@Overridepublic void run() {isReadyJoin = true;startEditerPreview(mFollowShotVideoOutputPath);if(mTXVideoEditer != null){mTXVideoEditer.release();mTXVideoEditer = null;}}});}else{runOnUiThread(new Runnable() {@Overridepublic void run() {Toast.makeText(TCVideoRecordActivity.this, "合成失败", Toast.LENGTH_SHORT).show();}});}}
文档反馈