ffmpeg-android-java icon indicating copy to clipboard operation
ffmpeg-android-java copied to clipboard

concat - audio files using FFmpeg not working in above Android 5.1

Open MehulKK opened this issue 8 years ago • 3 comments

I am using FFmpeg to concat three Audio file combine into one

  • audio.m4a (get from assets)
  • Recorded audio.m4a (Record using MediaRecorder)
  • audio.m4a (get from assets)

its works fine in below Android 5.1 but not working on above Android 5.1, In above 5.1 recorded audio file not concat (its playing good when i play from saved internal storage its not corrupt recording).

I am using following command to concat audio files.

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 is a text file contains path of all audio which i concat

#ffmpeg.txt
file '/storage/emulated/0/AudioRecorder/radioStatic.m4a'
file '/storage/emulated/0/AudioRecorder/recordedFile.m4a'
file '/storage/emulated/0/AudioRecorder/radioStatic.m4a'

MehulKK avatar Jun 15 '16 06:06 MehulKK

How to do this without txt file?

tutysathish avatar Oct 04 '18 09:10 tutysathish

How to make the txt file in android and use this?

aliraza96 avatar May 13 '20 07:05 aliraza96

iam using this command for audio loop using textfile path. String[] commandArray ={"-f","concat","-i",path1,"-codec", "copy","-safe 0", "-y",outputFilePath}; getting Failure error ffmpeg version n3.0.1 Copyright(c)2000-2016 the FFmpeg developers build with gcc 4.8 (GCC) configuration:-target os........ please suggest how can i resolve this .

gianttlab avatar Jun 01 '20 12:06 gianttlab