1

I am trying to use ffmpeg library for mixing two MP3 or wav audio files using the commands available that I searched over Internet like given below:

ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex amerge -c:a libmp3lame -q:a 4 output.mp3

From link How to overlay two audio files using ffmpeg

Also, tried some many other solutions given on the different forms.

But none of them is working for the the library downloaded from link: https://github.com/hiteshsondhi88/ffmpeg-android-java.

But when I am trying to run the commands available on the intener, in some commands I am getting different different error like,

-- Unable to find suitable output format for 'ffmpeg' ffmpeg: Invalid argument

And I also tried one more command,

 String res = "ffmpeg -y -i " + a.getAbsolutePath() + " -i " + b.getAbsolutePath() + " -filter_complex '[0:0][1:0] amix=inputs=2:duration=longest' -c:a libmp3lame " + c.getAbsolutePath();

It's giving error, No such filter:" Error configuring filters.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Ashok Singhal
  • 520
  • 1
  • 5
  • 10

3 Answers3

0

What is your version of FFmpeg? I believe it's old and that's why it's not working.

First setp download newest version from official site try if your command it's working if yes than find another (or build your own) compiled for android executable file

Karol Żygłowicz
  • 2,442
  • 2
  • 26
  • 35
0

Well First check your FFmpeg version. The way you have used the amix filter have to be changed. amix filter mix audios. So following is what I'm suggesting.

ffmpeg -i input_audio1 -i input_audio2 -filter_complex "aevalsrc=0:d=10[s1];
[s1][1:a]concat=n=2:v=0:a=1[ac1];
[0:a][ac1]amix[aout]" -map [aout] -c:a libmp3lame output_audio

you can append a silent audio which duration is same as the first audio and them use amix over them. So the original audio's will not overlap. aevalsrc will create a silent audio with a duration of 10 sec. Also you need to select appropriate codec for your output accordingly. You can find those codec here.

Hope this helps!

Chamath
  • 2,016
  • 2
  • 21
  • 30
0

I know it's been some time since this question was posted, but I think your main problem is that you shouldn't include "ffmpeg" on your string.

So your cmd line would be:

String res = "-y -i " + a.getAbsolutePath() + " -i " + b.getAbsolutePath() + " -filter_complex '[0:0][1:0] amix=inputs=2:duration=longest' -c:a libmp3lame " + c.getAbsolutePath();