cropsly / ffmpeg-android-java

Android java library for FFmpeg binary compiled using https://github.com/writingminds/ffmpeg-android
http://writingminds.github.io/ffmpeg-android-java
GNU General Public License v3.0
3.32k stars 831 forks source link

Cannot run program "/data/user/0/com.package.name/files/ffmpeg": error=13, Permission denied #343

Open budiardianata opened 4 years ago

budiardianata commented 4 years ago

i have error "error=13, Permission denied" while trying to run Ffmpeg in android 10 (Q).

java.io.IOException: Cannot run program "/data/user/0/com.package.name/files/ffmpeg": error=13, Permission denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050) at java.lang.Runtime.exec(Runtime.java:698) at java.lang.Runtime.exec(Runtime.java:563) at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:11) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:40) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.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.(UNIXProcess.java:133) at java.lang.ProcessImpl.start(ProcessImpl.java:141) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) at java.lang.Runtime.exec(Runtime.java:698)  at java.lang.Runtime.exec(Runtime.java:563)  at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:11)  at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:40)  at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.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) 

brisksvoronko commented 4 years ago

Hey,

1) First you need to get permissions for external storage.

if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_RQ);

                                           }

2) Pay attention to the oder - first wait for ffmpeg lib to finish loading - only then start any commands

package appsforactors.com.myselftapeapp.Mp4Tasks;

import android.content.Context; import android.util.Log;

import com.crashlytics.android.Crashlytics; import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler; import com.github.hiteshsondhi88.libffmpeg.FFmpeg; import com.github.hiteshsondhi88.libffmpeg.LoadBinaryResponseHandler; import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException; import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;

import org.bytedeco.javacpp.presets.opencv_core;

import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List;

import appsforactors.com.myselftapeapp.Utility.FileUtility; import appsforactors.com.myselftapeapp.Utility.ProcessUtils; import appsforactors.com.myselftapeapp.Utility.TimeUtilility; import io.fabric.sdk.android.services.common.Crash;

/**

riddhee commented 4 years ago

is this worked for u?

kartik1225 commented 4 years ago

Any updates on this?

st235 commented 4 years ago

I suppose its the limitation of Android Q and target api 29, as the library executes binary file. Indeed it looks really tricky

rkkalkii commented 4 years ago

Hi there, i am facing the same issue with android Q on target api 29. Taking write permission and waiting for library to load is not helping. Do anyone has any solution?? Thanks.

st235 commented 4 years ago

@rkkalkii, I would recommend you to try MediaCodec API, it really works as ffmpeg. The only limitation is api 18+.

appteamwebcontentor commented 4 years ago

Does anybody got the solution for this ? I am also stuck here

st235 commented 4 years ago

Does anybody got the solution for this ? I am also stuck here

Yeah, as I wrote below, this solution will not work anymore until authors will not recompile binary file as a static library and wrap the code with JNI methods.

The optimal solution without using any library is to use MediaCodec API provided by Android since API 18+

pezezzle commented 4 years ago

i recommend google/android to remove this scoped storage shit. Same issue...

gowthami77 commented 4 years ago

Hi............ Does anybody got the solution for this ? I am also stuck here.. Please send me reply

alexict commented 4 years ago

@gowthami77 the temporary solution is set target api < 29 or you can use MediaCodec API.

dmitriy-chernysh commented 4 years ago

I have the same issue on Android 10+ with targetsdk 29. I can confirm it works fine with targetSdk 28. But I would like to force it work with the latest sdk. And I cannot use MediaCodec API due to limited functionallity. Let me know if anybody has solved the issue. Thanks!

aliraza96 commented 4 years ago

Also stuck on this issue. If anybody found a solution except for adding targetSdk 28. Please any help will be appreaciated.

st235 commented 4 years ago

@aliraza96, if MediaCodec is not applicable for you, its still possible to compile ffmpeg from sources as shared library. Here you may found some related info about compilation for Android. Also this one repo structured very well.

gowthami77 commented 4 years ago

I found this library and it worked well on Android 10 https://github.com/tanersener/mobile-ffmpeg

androidvk commented 4 years ago

@gowthami77 is it working without any errors?? can you post a sample code over here.

ShankyPatel commented 4 years ago

@gowthami77 i tried to use library but it requires minsdk 24 so its useless.

DevMayur commented 3 years ago

@gowthami77 i tried to use library but it requires minsdk 24 so its useless. Its main releases support API 24+ but you can use LTS for minsdk 16+ i.e. use implementation 'com.arthenica:mobile-ffmpeg-full:4.4.LTS' instead of implementation 'com.arthenica:mobile-ffmpeg-full:4.4'

bilal96aslam commented 3 years ago

I found this library and it worked well on Android 10 https://github.com/tanersener/mobile-ffmpeg

can you please share how to implement this library because I can't find implementation about this library? Thanks

bilal96aslam commented 3 years ago

@gowthami77 i tried to use library but it requires minsdk 24 so its useless.

but in his documentation saying it requires API 16+

yyms3275 commented 3 years ago

I solved the same problem as below. I solved the problem by using a different library.

https://github.com/tanersener/mobile-ffmpeg

dmitriy-chernysh commented 3 years ago

I solved the same problem as below. I solved the problem by using a different library.

https://github.com/tanersener/mobile-ffmpeg

Yeah. I started using this lib too. The problem has gone. Everything works fine on Android 11.

natvar97 commented 2 years ago

Use below library, https://github.com/tanersener/ffmpeg-kit/tree/main/android

and put below packagingOptions in build.gradle:

packagingOptions { pickFirst 'lib/x86/libswscale.so' pickFirst 'lib/x86/libavcodec.so' pickFirst 'lib/x86_64/libavutil.so' pickFirst 'lib/armeabi-v7a/libswscale_neon.so' pickFirst 'lib/x86_64/libavcodec.so' pickFirst 'lib/x86_64/libswscale.so' pickFirst 'lib/x86_64/libavformat.so' pickFirst 'lib/x86/libavfilter.so' pickFirst 'lib/x86/libswresample.so' pickFirst 'lib/arm64-v8a/libavcodec.so' pickFirst 'lib/armeabi-v7a/libavfilter_neon.so' pickFirst 'lib/arm64-v8a/libavformat.so' pickFirst 'lib/x86/libavformat.so' pickFirst 'lib/arm64-v8a/libavutil.so' pickFirst 'lib/x86_64/libavdevice.so' pickFirst 'lib/arm64-v8a/libavfilter.so' pickFirst 'lib/x86_64/libswresample.so' pickFirst 'lib/arm64-v8a/libswscale.so' pickFirst 'lib/x86/libavdevice.so' pickFirst 'lib/x86/libavutil.so' pickFirst 'lib/armeabi-v7a/libavcodec_neon.so' pickFirst 'lib/x86_64/libavfilter.so' pickFirst 'lib/arm64-v8a/libswresample.so' pickFirst 'lib/arm64-v8a/libavdevice.so' }

it will solve your problem

FFmpegSession session = FFmpegKit.execute(command); if (ReturnCode.isSuccess(session.getReturnCode())) { progressbar_popup.setVisibility(View.GONE); pop_txt_progress.setVisibility(View.GONE); refreshAndroidGallery(Uri.parse(destPath)); // renameDialog.dismiss(); if (!PreferenceManager.getRemove()) { viewfullpagead(); } else { renameDialog.dismiss(); //card_pre_video.setVisibility(View.GONE); refreshwaiting(); //startActivity(new Intent(Home.this,VideoFolderList.class)); } } if (ReturnCode.isCancel(session.getReturnCode())) { }

this work for android 11 also (tested)