[英]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.