11

Try this command for merge two audio files, but its not working in Android 10.0(Q) while targeting sdk 29. But, this command is completely working on targeting sdk 24 to 28.

I am using this library of FFMPEG implementation 'nl.bravobit:android-ffmpeg:1.1.7'

"-y", "-i", path1, "-i", path2, "-filter_complex", "[0:0][1:0] amix=inputs=2:duration=longest", "-c:a", "libmp3lame", savedPath

my Error log:
2019-09-28 13:48:32.037 16041-16166/com.merger.cut E/FFmpeg: Exception while trying to run: [/data/user/0/com..merger.cut/files/ffmpeg, -y, -i, /storage/emulated/0/Music/song1.mp3, -i, /storage/emulated/0/Music/song2.mp3, -filter_complex, [0:0][1:0] amix=inputs=2:duration=longest, -c:a, libmp3lame, /storage/emulated/0/merger/Merge_1569658695254.mp3]
    java.io.IOException: Cannot run program "/data/user/0/com.merger.cut/files/ffmpeg": error=13, Permission denied
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
        at nl.bravobit.ffmpeg.ShellCommand.run(ShellCommand.java:15)
        at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:43)
        at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:12)
        at android.os.AsyncTask$3.call(AsyncTask.java:378)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.io.IOException: error=13, Permission denied
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
        at java.lang.ProcessImpl.start(ProcessImpl.java:141)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        at nl.bravobit.ffmpeg.ShellCommand.run(ShellCommand.java:15) 
        at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:43) 
        at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:12) 
        at android.os.AsyncTask$3.call(AsyncTask.java:378) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 
2019-09-28 13:48:32.146 16041-16041/com.merger.cut E/FFMPEG :: on finish

Give me solution for above problem.

Krupali Shingala
  • 192
  • 2
  • 14

4 Answers4

8

Now If You Guys Looking For FFMPEG for ANDROID Q Here is link use below FFMPEG Build. Include this to your app/build.gradle

Min SDK 24

  dependencies {
        implementation 'com.arthenica:mobile-ffmpeg-full:4.3'
    }

Min SDK 16

dependencies {
    implementation 'com.arthenica:mobile-ffmpeg-full:4.2.2.LTS'
}

tested in OnePlus 7T
Android Q

Vinesh Chauhan
  • 1,288
  • 11
  • 27
  • 1
    library size is too large. – Tushar Lathiya Apr 22 '20 at 06:44
  • @TusharLathiya You can you aab File for apk . – Vinesh Chauhan Jun 05 '20 at 05:15
  • Currently, we don't have alternative for this. – Vinesh Chauhan Jun 05 '20 at 05:16
  • 1
    instead of `-full`, you can use one of the [smaller packages](https://github.com/tanersener/mobile-ffmpeg/wiki/Packages) – Alex Cohn Aug 08 '20 at 13:46
  • I'm using 'com.arthenica:mobile-ffmpeg-full:4.2.2.LTS' But I get this error in build time ' Manifest merger failed : Attribute application@appComponentFactory value=(androidx) from AndroidManifest.xml:10:9-47 is also present at [androidx.core:core:1.3.2] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:9:5-26:19 to override.' – Morteza Khodaie Nov 05 '20 at 09:19
  • tools:replace="android:appComponentFactory" add this lien to manifest file.in application tag – Vinesh Chauhan Nov 05 '20 at 09:38
0

For this library is only support maximum sdk 28 see the below link:

https://github.com/bravobit/FFmpeg-Android/blob/master/android-ffmpeg/build.gradle

So,In this library not run in SDK 29 because the targetSdkVersion 28 and compileSdkVersion 28 . If you want to change this thing, it'll work for you. I hope it will help you..!

Viral Patel
  • 1,296
  • 1
  • 11
  • 24
0

Use this instead link

implementation 'com.arthenica:ffmpeg-kit-video:5.1.LTS'
Timchang Wuyep
  • 629
  • 7
  • 10
0

Please use this library

implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.2.2.LTS'

It works great. If there is any doubt please let me know. Thanks

This is how i have used it

private class CompressVideo extends AsyncTask<String, String, Integer> {

    String oldPath;
    File newFile;
    int videoLength;

    CompressVideo(String oldPath, File newFile, int VideoLength) {
        this.newFile = newFile;
        this.oldPath = oldPath;
        this.videoLength = VideoLength;
        rvProgressBar.setVisibility(View.VISIBLE);
        tvProgressPercentage.setVisibility(View.VISIBLE);
        Config.enableStatisticsCallback(statistics -> {
            runOnUiThread(() -> tvProgressPercentage.setText((statistics.getTime() * 100) / videoLength + "%"));
        });
    }

    @Override
    protected void onPreExecute() {
        setClickable(rlMainLayout, false);
        super.onPreExecute();
    }

    @Override
    protected Integer doInBackground(String... strings) {
        String cmd = "-y -i " + oldPath + " -c:a copy -r 30 -vcodec libx264 -crf 28 -preset ultrafast " + newFile.getPath();
        int rc = FFmpeg.execute(cmd);
        return rc;
    }

    @Override
    protected void onPostExecute(Integer rc) {
        setClickable(rlMainLayout, true);
        if (rc == RETURN_CODE_SUCCESS) {
            videoCount++;
            path.add(newFile.getPath());
            mediaType.add(Constants.TAG_VIDEO);
            al.add(Uri.fromFile(newFile));
            vehicleNewImageAdapter.notifyDataSetChanged();
            rvProgressBar.setVisibility(View.GONE);
            tvProgressPercentage.setVisibility(View.GONE);
        } else if (rc == RETURN_CODE_CANCEL) {
            rvProgressBar.setVisibility(View.GONE);
            tvProgressPercentage.setVisibility(View.GONE);
            Toast.makeText(getApplicationContext(), getString(R.string.oops_something_went_wrong), Toast.LENGTH_SHORT).show();
        } else {
            rvProgressBar.setVisibility(View.GONE);
            tvProgressPercentage.setVisibility(View.GONE);
            Toast.makeText(getApplicationContext(), getString(R.string.oops_something_went_wrong), Toast.LENGTH_SHORT).show();
        }
        super.onPostExecute(rc);
    }
}
Priyanka Singhal
  • 243
  • 1
  • 4
  • 20