[英]concat - audio files using FFmpeg not working in above Android 5.1
我正在使用FFmpeg将三个音频文件结合成一个
它在Android 5.1以下工作正常,但不能在Android 5.1以上工作,在5.1以上录制的音频文件不能连续(当我从保存的内部存储器播放时它的播放效果不好而不是损坏的录音)。
我使用以下命令来连接音频文件。
File mergedFile = new File(cacheDir + "/" + String.format("merged_file_%s.m4a", System.currentTimeMillis()));
final String[] ffmpegCommand = new String[]{ /* this concat only 1st audio*/
"ffmpeg",
"-f",
"concat",
"-i",
list, /* text file which contains full path of audio files*/
"-c",
"copy",
mergedFile.toString()};
final String[] ffmpegCommand = new String[]{ /*its working but not concat recorded file*/
"-y",
"-i",
"concat:" + getStaticFilePath() + "|" + getRecordedFilePath() + "|" + getStaticFilePath(),
"-c",
"copy",
mergedFile.toString()};
FFmpeg ffmpeg = FFmpeg.getInstance(this);
try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
showUnsupportedExceptionDialog();
}
});
} catch (FFmpegNotSupportedException e) {
showUnsupportedExceptionDialog();
}
try {
ffmpeg.execute(ffmpegCommand, new FFmpegExecuteResponseHandler() {
@Override
public void onFailure(String s) {
Log.d(TAG, "FAILED with output : " + s);
}
@Override
public void onSuccess(String s) {
Log.d(TAG, "SUCCESS with output : " + s);
}
@Override
public void onProgress(String s) {
Log.d(TAG, "Started command : ffmpeg " + ffmpegCommand);
}
@Override
public void onStart() {
Log.d(TAG, "Started command : ffmpeg " + ffmpegCommand);
Log.d(TAG, "Processing...");
}
@Override
public void onFinish() {
Log.d(TAG, "Finished command : ffmpeg " + ffmpegCommand);
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// do nothing for now
}
list是一个文本文件,包含我连接的所有音频的路径
#ffmpeg.txt
file '/storage/emulated/0/AudioRecorder/radioStatic.m4a'
file '/storage/emulated/0/AudioRecorder/recordedFile.m4a'
file '/storage/emulated/0/AudioRecorder/radioStatic.m4a'
这对我有用
val cmd = arrayOf("-y", "-i", audio1!!.path, "-i", audio2!!.path, "-filter_complex","
[0:a] [1:a] concat=n=2:v=0:a=1 [a]","-map","[a]", "-c:a","mp3", outputLocation.path)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.