|
|
@ -31,7 +31,7 @@ import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_FINISH; |
|
|
|
public class AudioHandleActivity extends BaseActivity { |
|
|
|
public class AudioHandleActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
|
|
|
private final static String PATH = Environment.getExternalStorageDirectory().getPath(); |
|
|
|
private final static String PATH = Environment.getExternalStorageDirectory().getPath(); |
|
|
|
private String appendFile = PATH + File.separator + "test.mp3"; |
|
|
|
private String appendFile = PATH + File.separator + "heart.m4a"; |
|
|
|
|
|
|
|
|
|
|
|
private ProgressBar progressAudio; |
|
|
|
private ProgressBar progressAudio; |
|
|
|
private LinearLayout layoutAudioHandle; |
|
|
|
private LinearLayout layoutAudioHandle; |
|
|
@ -142,12 +142,14 @@ public class AudioHandleActivity extends BaseActivity { |
|
|
|
if (!FileUtil.checkFileExist(appendFile)) { |
|
|
|
if (!FileUtil.checkFileExist(appendFile)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> fileList = new ArrayList<>(); |
|
|
|
// List<String> fileList = new ArrayList<>();
|
|
|
|
fileList.add(srcFile); |
|
|
|
// fileList.add(srcFile);
|
|
|
|
fileList.add(appendFile); |
|
|
|
// fileList.add(appendFile);
|
|
|
|
String concatFile = PATH + File.separator + "concat.mp3"; |
|
|
|
// String concatFile = PATH + File.separator + "concat.mp3";
|
|
|
|
commandLine = FFmpegUtil.concatAudio(fileList, concatFile); |
|
|
|
// commandLine = FFmpegUtil.concatAudio(fileList, concatFile);
|
|
|
|
break; |
|
|
|
// break;
|
|
|
|
|
|
|
|
concatAudio(srcFile); |
|
|
|
|
|
|
|
return; |
|
|
|
case R.id.btn_mix://mix audio
|
|
|
|
case R.id.btn_mix://mix audio
|
|
|
|
if (!FileUtil.checkFileExist(appendFile)) { |
|
|
|
if (!FileUtil.checkFileExist(appendFile)) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -204,6 +206,26 @@ public class AudioHandleActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void concatAudio(String selectedPath) { |
|
|
|
|
|
|
|
if (ffmpegHandler == null || selectedPath.isEmpty() || appendFile.isEmpty()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String outputPath1 = PATH + File.separator + "output1.mp3"; |
|
|
|
|
|
|
|
String outputPath2 = PATH + File.separator + "output2.mp3"; |
|
|
|
|
|
|
|
String targetPath = PATH + File.separator + "concatAudio.mp3"; |
|
|
|
|
|
|
|
String[] transformCmd1 = FFmpegUtil.transformAudio(selectedPath, "libmp3lame", outputPath1); |
|
|
|
|
|
|
|
String[] transformCmd2 = FFmpegUtil.transformAudio(appendFile, "libmp3lame", outputPath2); |
|
|
|
|
|
|
|
List<String> fileList = new ArrayList<>(); |
|
|
|
|
|
|
|
fileList.add(outputPath1); |
|
|
|
|
|
|
|
fileList.add(outputPath2); |
|
|
|
|
|
|
|
String[] jointVideoCmd = FFmpegUtil.concatAudio(fileList, targetPath); |
|
|
|
|
|
|
|
List<String[]> commandList = new ArrayList<>(); |
|
|
|
|
|
|
|
commandList.add(transformCmd1); |
|
|
|
|
|
|
|
commandList.add(transformCmd2); |
|
|
|
|
|
|
|
commandList.add(jointVideoCmd); |
|
|
|
|
|
|
|
ffmpegHandler.executeFFmpegCmds(commandList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onDestroy() { |
|
|
|
protected void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
super.onDestroy(); |
|
|
|