Skip to content

Commit

Permalink
1. 修复分段录制失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
aaatttcccc committed Dec 30, 2021
1 parent abaeaca commit d4d929e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,15 @@ public void onProgress(int progress, long progressTime) {
@Override
public void onCancel() {
Log.d(TAG, "onCancel");
// 重置按钮
mViewHolder.pvLayout.getViewHolder().btnConfirm.reset();
}

@Override
public void onError(@NotNull String message) {
Log.d(TAG, "onError" + message);
// 重置按钮
mViewHolder.pvLayout.getViewHolder().btnConfirm.reset();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public Boolean onBackPressed() {

@Override
public boolean onActivityResult(int resultCode) {
return true;
// 返回false处理视频
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

import com.zhongjh.common.coordinator.VideoEditCoordinator;
import com.zhongjh.common.listener.VideoEditListener;

import io.microshow.rxffmpeg.RxFFmpegInvoke;
import io.microshow.rxffmpeg.RxFFmpegSubscriber;

/**
* 视频编辑管理
*
* @author zhongjh
*/
public class VideoEditManager implements VideoEditCoordinator {
Expand All @@ -34,15 +36,25 @@ public void setVideoCompressListener(VideoEditListener videoCompressListener) {
}

@Override
public void merge(String newPath, ArrayList<String> paths,String txtPath) {
public void merge(String newPath, ArrayList<String> paths, String txtPath) {
boolean isMerge = false;
// 创建文本文件
File file = new File(txtPath);
if (!file.exists()) {
if (file.getParent() != null) {
File dir = new File(file.getParent());
isMerge = dir.mkdirs();
if (isMerge) {
// 判断父目录是否存在
if (!dir.exists()) {
isMerge = dir.mkdirs();
if (isMerge) {
try {
isMerge = file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
// 如果存在直接创建文件
try {
isMerge = file.createNewFile();
} catch (IOException e) {
Expand All @@ -52,7 +64,10 @@ public void merge(String newPath, ArrayList<String> paths,String txtPath) {
}
}

mMyRxFfmpegMergeSubscriber = new MyRxFfmpegSubscriber(mVideoMergeListener);

if (!isMerge && !file.exists()) {
mMyRxFfmpegMergeSubscriber.onCancel();
return;
}

Expand All @@ -72,7 +87,6 @@ public void merge(String newPath, ArrayList<String> paths,String txtPath) {

String commands = "ffmpeg -y -f concat -safe 0 -i " + file.getPath() + " -c copy " + newPath;

mMyRxFfmpegMergeSubscriber = new MyRxFfmpegSubscriber(mVideoMergeListener);

// 开始执行FFmpeg命令
RxFFmpegInvoke.getInstance()
Expand All @@ -81,7 +95,7 @@ public void merge(String newPath, ArrayList<String> paths,String txtPath) {
}

@Override
public void compress(String oldPath,String compressPath) {
public void compress(String oldPath, String compressPath) {
String commands = "ffmpeg -y -i " + oldPath + " -b 2097k -r 30 -vcodec libx264 -preset superfast " + compressPath;

mMyRxFfmpegCompressSubscriber = new MyRxFfmpegSubscriber(mVideoCompressListener);
Expand Down Expand Up @@ -123,8 +137,6 @@ public void onCompressDispose() {
}




public static class MyRxFfmpegSubscriber extends RxFFmpegSubscriber {

private final WeakReference<VideoEditListener> mWeakReference;
Expand Down

0 comments on commit d4d929e

Please sign in to comment.