1

I have a couple of M4A (sound) files. I want to combine into a single sound file. Can this using ffmpeg library in android.

I tried this way.

public void myFunctionMergeAudioFiles(ShellCallback sc,List<String> mListFiles, String outPath) throws IOException, InterruptedException
    {

        ArrayList<String> cmd = new ArrayList<String>();
        cmd = new ArrayList<String>();
        cmd.add(ffmpegBin);
        cmd.add("f");
        cmd.add("concat");
        cmd.add("-i");
        for(int i=0;i<mListFiles.size();i++){
            cmd.add(new File(mListFiles.get(i)).getCanonicalPath());
        }
        cmd.add("-c");
        cmd.add("-acodec");
        cmd.add("aac");
        cmd.add("copy");
        File fileOut = new File(outPath);
        cmd.add(fileOut.getCanonicalPath());
        execFFMPEG(cmd, sc);
    }

My Log:-

01-23 15:32:17.841: D/FFMPEG(12678): /data/app-lib/com.apps.messagingapp-1/libffmpeg.so f concat -i /storage/emulated/0/MGOApp/Temp/Recording #1_0.m4a /storage/emulated/0/MGOApp/Temp/Recording #1_1.m4a /storage/emulated/0/MGOApp/Temp/Recording #1_2.m4a -c -acodec aac copy /storage/emulated/0/MGOApp/Recording #1.m4a 

But i am not getting any error. Thanks in advance.

Jagdish
  • 2,418
  • 4
  • 25
  • 51
  • Did u get any solutions? – Sivakumar S Jan 07 '16 at 18:02
  • Yes, I have done using ffmpeg and another example for merge image to audio is http://stackoverflow.com/questions/20463719/ffmpegmultiple-image-frames-1-audio-1-video/21304505#21304505 – Jagdish Jan 11 '16 at 09:00
  • I posted an answer http://stackoverflow.com/questions/20463719/ffmpegmultiple-image-frames-1-audio-1-video/21304505#21304505 – Jagdish Jan 25 '16 at 12:15

1 Answers1

1

I believe you've got to create a text file and use it as your input. The text file needs to look like this:

file 'file1.m4a'
file 'file2.m4a'

Then run the following command line should be like:

ffmpeg -f concat -i "Path\To\MyList.txt" -c copy concatOutput.m4a

That works for me. You should be able to create the list text file on the fly in your code and delete it after you've run your FFMPEG command line.

More info on this guide

AJ29
  • 1,381
  • 10
  • 10