音频文件的 FFmpeg 命令混合出错

FFmpeg Command for Audio Files mix getting error

任务: 在 Android.

中使用 FFmpeg 混合音频文件

错误:

 [NULL @ 0xf6468400] Unable to find a suitable output format for ' -i '
 -i : Invalid argument

我的命令:

  File m1 = new File(Environment.getExternalStorageDirectory() + "/MyFolder/m1.mp3"); 
  File m2 = new File(Environment.getExternalStorageDirectory() + "/MyFolder/m2.mp3");
 //m1,m2 are mp3 files
 //File outputDirectory2 = new File(Environment.getExternalStorageDirectory() + "/MyFolder/video1.mp3");

 String[] auidoMixCmd3={" -i ",""+m1.getPath()," -i ",""+m2.getPath()," -filter_complex [0:0][1:0] amix=inputs=2:duration=first:dropout_transition=0 -codec:a libmp3lame -q:a 0:-f mp3",outputDirectory2.getPath()};


 String[] auidoMixCmd2={" -i ",""+m1.getPath()," -i ",""+m2.getPath()," -i ",""+m1.getPath()," -filter_complex","\"[0:0][1:0] amix=inputs=2:duration=longest\" -c:a libmp3lame -f mp3",outputDirectory2.getPath()};

我用不同的命令尝试了 100 多次,但我没有得到任何命令 solutions.So 许多命令在 Stack overflow 中,但得到相同的命令 error.Please 任何人都可以帮助我。

因为它是一个字符串数组,所以您不必添加 + 符号。此外,+ 符号前不需要 ""

您的命令应如下所示:

String[] auidoMixCmd3 = { "-i ", m1.getPath(), "-i ", m2.getPath(), "-filter_complex [0:a][1:a] amix=inputs=2:duration=first:dropout_transition=0 -codec:a libmp3lame -q:a 0 -f mp3", outputDirectory2.getPath()};