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

时间:2019-05-13 20:06:38

标签: android audio ffmpeg android-ffmpeg

任务:       在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多次,但没有得到任何解决方案。堆栈溢出时有很多命令但出现相同的错误。请任何人在这里帮助我。

1 个答案:

答案 0 :(得分:2)

由于它是一个字符串数组,因此不必添加+符号。另外,无需在""符号前加上+

您的命令应如下所示:

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()};