FFMPEG commands isn't working in Android Q

匆匆过客 提交于 2020-06-08 05:26: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.


回答1:


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




回答2:


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..!




回答3:


There is No Official Documentation.

https://www.reddit.com/r/androiddev/comments/b2inbu/psa_android_q_blocks_executing_binaries_in_your/

But You Can Use Below Method to Test You App

It looks like both linux DAC and SE-Android are blocking your application's process from accessing the 'su' executable.

Check if your system is running in enforced mode, meaning that SE-Android is enabled. If this is indeed the case, you can temporarily disable it by running:

adb root

   adb shell setenforce 0

This will disable SE-Android and will not block the apps process from executing 'su'.

So you can execute ffmpeg

Additionally, your app might not have the DAC permissions necessary to launch 'su' as root. You can execute the following command:

adb shell ps

For a list of all running processes on your device. locate your app (by searching for its package name), and check its group and uid. Most probably neither are root.

Please note that building a custom userdebug image is not quite like rooting a standard Android device. The debug version is meant to allow access to the device's internals while still simulating a real functioning device with all of its default security mechanisms enabled.



来源:https://stackoverflow.com/questions/58143381/ffmpeg-commands-isnt-working-in-android-q

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!