Browse Source

修改测试问题

Pq 9 months ago
parent
commit
cbdc171cc3

+ 16 - 2
ffmpegCmd/src/main/java/com/cooleshow/ffmpegcmd/util/FFmpegUtil.java

@@ -92,6 +92,14 @@ public class FFmpegUtil {
         return insert(cutAudioCmd.split(" "), 2, inputPath, outputPath);
     }
 
+    public static String[] getAudioDuration(String input) {
+//        String cmd = "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %s";
+        String cmd = "ffmpeg -i %s -hide_banner -loglevel grep Duration | cut -d ' ' -f 4 | sed 's/,//'";
+//        String cmd = "ffmpeg -i %s";
+        cmd = String.format(Locale.getDefault(), cmd, input);
+        return cmd.split(" ");
+    }
+
     /**
      * concat all the audio together
      *
@@ -153,6 +161,12 @@ public class FFmpegUtil {
         //disableThumb:(-vn)if not disable, it may cause incorrect mixing
         int len = 8;
 //        String amix = "[1]adelay=%d|%d[b];[0][b]amix=inputs=2:duration=shortest";
+//        String amix = "";
+//        if (isShortestAligning) {
+//            amix = "[0]volume=%f,adelay=%d|%d[a];[1]volume=%f,adelay=%d|%d[b];[a][b]amix=inputs=2:duration=shortest";
+//        } else {
+//            amix = "[0]volume=%f,adelay=%d|%d[a];[1]volume=%f,adelay=%d|%d[b];[a][b]amix=inputs=2:duration=longest";
+//        }
         String amix = "[0]volume=%f,adelay=%d|%d[a];[1]volume=%f,adelay=%d|%d[b];[a][b]amix=inputs=2:duration=first";
         amix = String.format(Locale.getDefault(), amix, volume1, delay, delay, volume2, delay2, delay2);
         if (disableThumb) len += 1;
@@ -850,7 +864,7 @@ public class FFmpegUtil {
             String command = "ffmpeg -i -filter:a %s -b:a 192k";
             String format = String.format(Locale.getDefault(), command, s);
             return insert(format.split(" "), 2, inputPath, outputPath);
-        }else{
+        } else {
             String speedCmd = "ffmpeg -i -filter:a atempo=%.2f -b:a 192k";
             speedCmd = String.format(Locale.getDefault(), speedCmd, speed);
             return insert(speedCmd.split(" "), 2, inputPath, outputPath);
@@ -864,7 +878,7 @@ public class FFmpegUtil {
             String speedCmd = "ffmpeg -i -filter_complex [0:a]%s[a] -map [a]";
             String format = String.format(Locale.getDefault(), speedCmd, s);
             return insert(format.split(" "), 2, inputPath, outputPath);
-        }else{
+        } else {
             String speedCmd = "ffmpeg -i -filter_complex [0:a]atempo=%.2f[a] -map [a]";
             speedCmd = String.format(Locale.getDefault(), speedCmd, speed);
             return insert(speedCmd.split(" "), 2, inputPath, outputPath);

+ 70 - 42
musicMerge/src/main/java/com/cooleshow/musicmerge/helper/MixHelper.java

@@ -1,7 +1,6 @@
 package com.cooleshow.musicmerge.helper;
 
 import android.text.TextUtils;
-import android.util.Log;
 
 import com.cooleshow.base.data.net.RetrofitClientNoToken;
 import com.cooleshow.base.utils.EncryptUtils;
@@ -44,8 +43,9 @@ public class MixHelper {
     public static final String BASE_PATH = FileUtils.getCacheDir(Utils.getApp(), "musicmerge");
 
     public static final String videoMp3Path = BASE_PATH + File.separator + "videoBgm.wav";
-    public static final String accompanimentMp3Path = BASE_PATH + File.separator + "accompaniment_bgm.mp3";
+    public static final String accompanyAligningMp3Path = BASE_PATH + File.separator + "accompaniment_bgm.mp3";//对齐长度的伴奏文件
     public static final String accompanimentWAVPath = BASE_PATH + File.separator + "accompaniment_bgm.wav";
+    public static final String accompanimentAligningWAVPath2 = BASE_PATH + File.separator + "accompaniment_bgm_cut.wav";//对齐长度的伴奏文件
     public static final String wavToMpePath = BASE_PATH + File.separator + "accompaniment_bgm_result.mp3";
     public static final String mergeMp3Path = BASE_PATH + File.separator + "merge.mp3";
     public static final String mergeMp3PathForMP4 = BASE_PATH + File.separator + "merge.aac";//目前只能aac格式,mp3格式合成视频后,IOS原生播放器播放没有声音
@@ -415,6 +415,8 @@ public class MixHelper {
         FileUtils.delete(onlyVideoPath);
         FileUtils.delete(accompanimentWAVPath);
         FileUtils.delete(handleVideoPath);
+        FileUtils.delete(accompanyAligningMp3Path);
+        FileUtils.delete(accompanimentAligningWAVPath2);
 //        boolean b = FileUtils.deleteAllInDir(BASE_PATH);
 //        LogUtils.i(TAG, "deleteAllTempFile:" + b);
     }
@@ -430,7 +432,7 @@ public class MixHelper {
 
     public int getMp3FromWav(String wavFilePath, String outPath) {
         //ffmpeg -i video.mp4 -vn audio.mp3
-        Log.i(TAG, "getMp3FromWav start wavFilePath:" + wavFilePath + "\noutPath:" + outPath);
+        LOG.i(TAG, "getMp3FromWav start wavFilePath:" + wavFilePath + "\noutPath:" + outPath);
 //        String[] commands = new String[5];
 //        commands[0] = "ffmpeg";
 //        commands[1] = "-i";
@@ -462,7 +464,7 @@ public class MixHelper {
             String command = commands[i];
             stringBuilder.append(command).append(" ");
         }
-        Log.i(TAG, "println:" + stringBuilder.toString());
+        LOG.i(TAG, "println:" + stringBuilder.toString());
     }
 
 
@@ -496,7 +498,7 @@ public class MixHelper {
 
     public int getVideoMp3_2(String videoPath, String outPath) {
         //ffmpeg -i video.mp4 -vn audio.mp3
-        Log.i(TAG, "getVideoMp3 start videoPath:" + videoPath + "\noutPath:" + outPath);
+        LOG.i(TAG, "getVideoMp3 start videoPath:" + videoPath + "\noutPath:" + outPath);
         String[] commands = new String[5];
         commands[0] = "ffmpeg";
         commands[1] = "-i";
@@ -509,8 +511,18 @@ public class MixHelper {
         return -1;
     }
 
+    public long getAudioDuration(String inputPath) {
+        String[] audioDuration = FFmpegUtil.getAudioDuration(inputPath);
+        if (audioDuration != null) {
+            println(audioDuration);
+            String s = FFmpegCmd.executeProbeSynchronize(audioDuration);
+            LOG.i(TAG, "getAudioDuration:" + s);
+        }
+        return -1;
+    }
+
     private int getOnlyVideo(String videoPath, String out) {
-        Log.i(TAG, "extractVideo start");
+        LOG.i(TAG, "extractVideo start");
         String[] commands1 = FFmpegUtil.extractVideo(videoPath, out);
         if (commands1 != null) {
             return FFmpegCmd.executeSync(commands1);
@@ -519,7 +531,7 @@ public class MixHelper {
     }
 
     private int megreMp3AndMp4(String videoPath, String mp3Path, String outPath) {
-        Log.i(TAG, "mergeMp4 start");
+        LOG.i(TAG, "mergeMp4 start");
         String[] commands = FFmpegUtil.mediaMux(videoPath, mp3Path, true, outPath);
         println(commands);
         if (commands != null) {
@@ -529,7 +541,7 @@ public class MixHelper {
     }
 
     private int megreMp3AndMp4V2(String videoPath, String mp3Path, String outPath, float videoDelay) {
-        Log.i(TAG, "mergeMp4 start");
+        LOG.i(TAG, "mergeMp4 start");
         String[] commands = FFmpegUtil.mediaMux2(videoPath, mp3Path, true, outPath, videoDelay);
         println(commands);
         if (commands != null) {
@@ -549,7 +561,7 @@ public class MixHelper {
         return lastPath;
     }
 
-    public void startMixForMp4(String accompanimentMp3Path, String recordFilePath, int offsetValue, float volume1, float volume2, ResultCallback<String> resultCallback) {
+    public void startMixForMp4(String accompanimentMp3Path, String recordFilePath, long recordFileDuration, int offsetValue, float volume1, float volume2, ResultCallback<String> resultCallback) {
         Observable.create(new ObservableOnSubscribe<String>() {
                     @Override
                     public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
@@ -557,53 +569,62 @@ public class MixHelper {
                         int totalStep;
                         if (offsetValue > 0) {
                             //获取视频中的MP3 MP3转换为wav 获取纯视频 剪裁音频 裁剪视频 合并音频 合并最终音视频
-                            totalStep = 7;
+                            totalStep = 8;
                         } else {
                             //获取视频中的MP3 MP3转换为wav 获取纯视频  补齐视频 合并音频 合并最终音视频
                             //获取视频中的MP3 MP3转换为wav 获取纯视频  合并音频 合并最终音视频
-                            totalStep = offsetValue != 0 ? 5 : 5;
+                            totalStep = 6;
                         }
                         resetCondition(resultCallback, totalStep);
 
-                        Log.i(TAG, "转换开始:" + offsetValue);
+                        LOG.i(TAG, "转换开始:" + offsetValue);
                         int getVideoMp3Result = getVideoMp3_2(recordFilePath, videoMp3Path);
+//                        long audioDuration = getAudioDuration(videoMp3Path);
+//                        LOG.i(TAG,"audioDuration:"+audioDuration);
+
                         completed_num++;
-                        Log.i(TAG, "getVideoMp3 complete:" + getVideoMp3Result);
+                        LOG.i(TAG, "getVideoMp3 complete:" + getVideoMp3Result);
                         //mix原音和视频bgm mp3
 //                        String accompanyPath = accompanimentMp3Path;
-                        Log.i(TAG, "mp3ToWav start");
+                        LOG.i(TAG, "mp3ToWav start");
                         int i = mp3ToWav(accompanimentMp3Path, accompanimentWAVPath);
                         completed_num++;
-                        Log.i(TAG, "mp3ToWav complete:" + i);
+                        float tartSecond = recordFileDuration * 1.0f / 1000;
+                        LOG.i(TAG, "tartSecond :" + tartSecond);
+                        //将伴奏文件裁剪成和演奏文件一样长度
+                        cutAudio(accompanimentWAVPath, 0, tartSecond, accompanimentAligningWAVPath2);
+                        completed_num++;
+                        LOG.i(TAG, "mp3ToWav complete:" + i);
                         //获取纯视频
-                        Log.i(TAG, "getOnlyVideo start");
+                        LOG.i(TAG, "getOnlyVideo start");
                         int getOnlyVideoResult = getOnlyVideo(recordFilePath, onlyVideoPath);
                         completed_num++;
-                        Log.i(TAG, "getOnlyVideo complete:" + getOnlyVideoResult);
+                        LOG.i(TAG, "getOnlyVideo complete:" + getOnlyVideoResult);
                         String recordLastPath = videoMp3Path;
                         String recordVideoLastPath = onlyVideoPath;
                         int recordFileOffset = 0;
                         int accompanimentFileOffset = 0;
                         if (offsetValue > 0) {
                             float cutM = Math.abs(offsetValue) * 1.0f / 1000;
-                            Log.i(TAG, "cutAudio start");
+                            LOG.i(TAG, "cutAudio start");
                             int cutAudioResult = cutAudio(recordLastPath, cutM, 5000000, cutPath);
                             completed_num++;
-                            Log.i(TAG, "cutAudio end:" + cutAudioResult);
+                            LOG.i(TAG, "cutAudio end:" + cutAudioResult);
 
-                            Log.i(TAG, "cutVideo start");
+                            LOG.i(TAG, "cutVideo start");
                             int cutVideoResult = cutVideo(onlyVideoPath, cutM, 5000000, handleVideoPath);
                             completed_num++;
-                            Log.i(TAG, "cutVideo end:" + cutVideoResult);
+                            LOG.i(TAG, "cutVideo end:" + cutVideoResult);
                             recordLastPath = cutPath;
                             recordVideoLastPath = handleVideoPath;
                         } else {
                             recordFileOffset = Math.abs(offsetValue);
                         }
-                        Log.i(TAG, "mixMp3 start");
-                        int mixMp3Result = mixMp3(recordLastPath, accompanimentWAVPath, mergeMp3PathForMP4, recordFileOffset, accompanimentFileOffset, volume1, volume2);
+                        LOG.i(TAG, "mixMp3 start");
+                        //伴奏在前,录制在后
+                        int mixMp3Result = mixMp3(accompanimentAligningWAVPath2,recordLastPath, mergeMp3PathForMP4, accompanimentFileOffset,recordFileOffset, volume2,volume1);
                         completed_num++;
-                        Log.i(TAG, "mixMp3 complete:" + mixMp3Result);
+                        LOG.i(TAG, "mixMp3 complete:" + mixMp3Result);
                         String lastResultPath = getLastResultPath();
                         int mergeResult;
                         if (offsetValue < 0) {
@@ -612,13 +633,13 @@ public class MixHelper {
                         } else {
                             mergeResult = megreMp3AndMp4(recordVideoLastPath, mergeMp3PathForMP4, lastResultPath);
                         }
-                        Log.i(TAG, "mergeMp4 complete:" + mergeResult);
-                        Log.i(TAG, "转换完成");
+                        LOG.i(TAG, "mergeMp4 complete:" + mergeResult);
+                        LOG.i(TAG, "转换完成");
                         resetCount();
 
                         if (emitter != null) {
                             boolean isSuccess = getVideoMp3Result == 0 && mixMp3Result == 0 && getOnlyVideoResult == 0 && mergeResult == 0;
-                            Log.i(TAG, "转换是否全部isSuccess:" + isSuccess);
+                            LOG.i(TAG, "转换是否全部isSuccess:" + isSuccess);
                             if (isSuccess) {
                                 emitter.onNext(lastResultPath);
                             } else {
@@ -664,41 +685,48 @@ public class MixHelper {
         FFmpegCmd.setOnProgressCallback(mEventListener);
     }
 
-    public void startMix(String accompanimentMp3Path, String recordFilePath, int offsetValue, float volume1, float volume2, ResultCallback<String> resultCallback) {
+    public void startMix(String accompanyMp3Path, String recordFilePath, long recordFileDuration, int offsetValue, float volume1, float volume2, ResultCallback<String> resultCallback) {
         Observable.create(new ObservableOnSubscribe<String>() {
                     @Override
                     public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
-                        Log.i(TAG, "转换开始");
+                        LOG.i(TAG, "转换开始");
 //                        int getVideoMp3Result = getVideoMp3_2(videoPath, videoMp3Path);
-//                        Log.i(TAG, "getVideoMp3 complete:" + getVideoMp3Result);
-//                        Log.i(TAG, "getMp3FromWav start");
+//                        LOG.i(TAG, "getVideoMp3 complete:" + getVideoMp3Result);
+//                        LOG.i(TAG, "getMp3FromWav start");
                         deleteAllTempFile();
-                        resetCondition(resultCallback, offsetValue > 0 ? 3 : 2);
+                        resetCondition(resultCallback, offsetValue > 0 ? 4 : 3);
                         int mp3FromWav = getMp3FromWav(recordFilePath, recordFileMp3Path);
                         completed_num++;
-                        Log.i(TAG, "getMp3FromWav complete:" + mp3FromWav);
+                        LOG.i(TAG, "getMp3FromWav complete:" + mp3FromWav);
                         String recordLastPath = recordFileMp3Path;
                         int recordFileOffset = 0;
                         int accompanimentFileOffset = 0;
                         if (offsetValue > 0) {
                             float cutM = Math.abs(offsetValue) * 1.0f / 1000;
-                            Log.i(TAG, "cutAudio start");
+                            LOG.i(TAG, "cutAudio start");
                             int cutAudioResult = cutAudio(recordLastPath, cutM, 5000000, cutPath);
                             completed_num++;
-                            Log.i(TAG, "cutAudio end:" + cutAudioResult);
+                            LOG.i(TAG, "cutAudio end:" + cutAudioResult);
                             recordLastPath = cutPath;
                         } else {
                             recordFileOffset = Math.abs(offsetValue);
                         }
+                        float tartSecond = recordFileDuration * 1.0f / 1000;
+                        LOG.i(TAG, "tartSecond :" + tartSecond);
+                        //将伴奏文件裁剪成和演奏文件一样长度
+                        int aligningAccompanyResult = cutAudio(accompanyMp3Path, 0, tartSecond, accompanyAligningMp3Path);
+                        completed_num++;
+
                         //mix原音和视频bgm mp3
-                        Log.i(TAG, "mixMp3 start");
-                        int mixMp3Result = mixMp3(recordLastPath, accompanimentMp3Path, mergeMp3Path, recordFileOffset, accompanimentFileOffset, volume1, volume2);
-                        Log.i(TAG, "mixMp3 complete:" + mixMp3Result);
+                        LOG.i(TAG, "mixMp3 start");
+                        //伴奏在前,录制在后
+                        int mixMp3Result = mixMp3(accompanyAligningMp3Path,recordLastPath, mergeMp3Path, accompanimentFileOffset,recordFileOffset, volume2,volume1);
+                        LOG.i(TAG, "mixMp3 complete:" + mixMp3Result);
                         resetCount();
 
                         if (emitter != null) {
-                            boolean isSuccess = mp3FromWav == 0 && mixMp3Result == 0;
-                            Log.i(TAG, "转换是否全部isSuccess:" + isSuccess);
+                            boolean isSuccess = mp3FromWav == 0 && aligningAccompanyResult == 0 && mixMp3Result == 0;
+                            LOG.i(TAG, "转换是否全部isSuccess:" + isSuccess);
                             if (isSuccess) {
                                 emitter.onNext(mergeMp3Path);
                             } else {
@@ -746,7 +774,7 @@ public class MixHelper {
     }
 
     public int downloadM3U8FileToMp4(String url, String encryption_key, String encryption_kid, String outPath) {
-        Log.i(TAG, "downloadM3U8FileToMp4 start url:" + url + "\noutPath:" + outPath);
+        LOG.i(TAG, "downloadM3U8FileToMp4 start url:" + url + "\noutPath:" + outPath);
         String[] commands = new String[6];
         commands[0] = "ffmpeg";
         commands[1] = "-i";
@@ -789,7 +817,7 @@ public class MixHelper {
     }
 
     public int decryptionMp4(String input, String key, String output) {
-        Log.i(TAG, "encryptionMp4 start input:" + input + "\noutPath:" + output);
+        LOG.i(TAG, "encryptionMp4 start input:" + input + "\noutPath:" + output);
         String[] commands = new String[6];
         commands[0] = "ffmpeg";
         commands[1] = "-i";

+ 7 - 2
musicMerge/src/main/java/com/cooleshow/musicmerge/player/MergeTrackManager.java

@@ -459,14 +459,18 @@ public class MergeTrackManager {
         long totalDuration = getTotalDuration();
         LOG.i(TAG, "seek percent:" + percent);
         LOG.i(TAG, "seek percent:" + totalDuration);
-        int posTime = (int) (totalDuration * percent);
+        long posTime = (long) (totalDuration * percent);
+        if (posTime >= totalDuration) {
+            //这个是为了防止出现拉倒了最大进度,触发了Completed事件导致置为0的问题
+            posTime = (long) (totalDuration - 100);
+        }
         LOG.i(TAG, "seek posTime:" + posTime);
         int seekToFrame = (int) (RATE * (posTime * 1.0f / 1000));  // 转换为对应的采样帧
         LOG.i(TAG, "seek seekToFrame:" + seekToFrame);
         setReadPos(posTime);
     }
 
-    private void setReadPos(int exceptTimePos) {
+    private void setReadPos(long exceptTimePos) {
         //转换为期望的位置
         LOG.i(TAG, "setReadPos:" + exceptTimePos);
         int exceptBytePos = getLengthFromDuration(exceptTimePos);
@@ -584,6 +588,7 @@ public class MergeTrackManager {
                 mAudioTrack.flush();
             }
         }
+        reset();
         removeProgressMsg();
     }
 

+ 7 - 2
musicMerge/src/main/java/com/cooleshow/musicmerge/ui/MusicHandleActivity.java

@@ -43,6 +43,7 @@ import com.cooleshow.base.utils.NumberUtils;
 import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.TimeUtils;
 import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.UrlUtils;
 import com.cooleshow.base.utils.helper.CommonShareHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
@@ -281,6 +282,10 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
             public void toMix(int offsetValue, float volume1, float volume2, boolean isNeedNotify) {
                 MAX_STEP = 3;
                 checkCoverToUpload();
+                if (firstPlayDuration == 0) {
+                    ToastUtils.showShort("演奏文件解析失败,请重试");
+                    return;
+                }
                 if (isVideo) {
                     startMixForMp4(getAccompanyPath(), recordFilePath, offsetValue, volume1, volume2, isNeedNotify);
                 } else {
@@ -453,7 +458,7 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
         currentStep = 0;
         toSetLoadingCancelable(false);
         toShowLoading(getCurrentProgress(0), getString(R.string.video_merge_tip));
-        MixHelper.getInstance().startMixForMp4(accompanimentMp3Path, recordFilePath, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
+        MixHelper.getInstance().startMixForMp4(accompanimentMp3Path, recordFilePath,firstPlayDuration, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
             @Override
             public void onSuccess(String s) {
                 if (!checkActivityExist()) {
@@ -514,7 +519,7 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
         currentStep = 0;
         toSetLoadingCancelable(false);
         toShowLoading(getCurrentProgress(0), getString(R.string.audio_merge_tip));
-        MixHelper.getInstance().startMix(accompanimentMp3Path, recordFilePath, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
+        MixHelper.getInstance().startMix(accompanimentMp3Path, recordFilePath,firstPlayDuration, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
             @Override
             public void onSuccess(String s) {
                 if (!checkActivityExist()) {

+ 10 - 4
musicMerge/src/main/java/com/cooleshow/musicmerge/ui/MusicHandleActivity_.java

@@ -43,6 +43,7 @@ import com.cooleshow.base.utils.NumberUtils;
 import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.TimeUtils;
 import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.UrlUtils;
 import com.cooleshow.base.utils.helper.CommonShareHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
@@ -339,6 +340,10 @@ public class MusicHandleActivity_ extends BaseMVPActivity<AcMusicHandleLayoutBin
             @Override
             public void toMix(int offsetValue, float volume1, float volume2, boolean isNeedNotify) {
                 MAX_STEP = 3;
+                if (audioPlayDuration == 0) {
+                    ToastUtils.showShort("演奏文件解析失败,请重试");
+                    return;
+                }
                 checkCoverToUpload();
                 if (isVideo) {
                     startMixForMp4(getAccompanyPath(), recordFilePath, offsetValue, volume1, volume2, isNeedNotify);
@@ -538,7 +543,7 @@ public class MusicHandleActivity_ extends BaseMVPActivity<AcMusicHandleLayoutBin
         currentStep = 0;
         toSetLoadingCancelable(false);
         toShowLoading(getCurrentProgress(0), getString(R.string.video_merge_tip));
-        MixHelper.getInstance().startMixForMp4(accompanimentMp3Path, recordFilePath, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
+        MixHelper.getInstance().startMixForMp4(accompanimentMp3Path, recordFilePath, audioPlayDuration, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
             @Override
             public void onSuccess(String s) {
                 if (!checkActivityExist()) {
@@ -599,7 +604,7 @@ public class MusicHandleActivity_ extends BaseMVPActivity<AcMusicHandleLayoutBin
         currentStep = 0;
         toSetLoadingCancelable(false);
         toShowLoading(getCurrentProgress(0), getString(R.string.audio_merge_tip));
-        MixHelper.getInstance().startMix(accompanimentMp3Path, recordFilePath, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
+        MixHelper.getInstance().startMix(accompanimentMp3Path, recordFilePath, audioPlayDuration, offsetValue, recordFileVolume, accompanyFileVolume, new ResultCallback<String>() {
             @Override
             public void onSuccess(String s) {
                 if (!checkActivityExist()) {
@@ -726,9 +731,10 @@ public class MusicHandleActivity_ extends BaseMVPActivity<AcMusicHandleLayoutBin
                         if (!checkActivityExist()) {
                             return;
                         }
-                        setRecordProgress(currentPosition);
                         if (currentPosition >= getAudioTotalDuration()) {
                             handleCompletedStatus();
+                        }else{
+                            setRecordProgress(currentPosition);
                         }
                     }
                 });
@@ -793,7 +799,7 @@ public class MusicHandleActivity_ extends BaseMVPActivity<AcMusicHandleLayoutBin
         int maxProgress = viewBinding.seekPlay.getMax();
         int percent = (int) ((progress * 1.0f / getAudioTotalDuration()) * maxProgress);
 //        LOG.i("pq", "setRecordProgress percent:" + percent);
-        if(!viewBinding.seekPlay.isPressed()){
+        if (!viewBinding.seekPlay.isPressed()) {
             //拖拽的时候不更新
             viewBinding.seekPlay.setProgress(percent);
         }