权限被拒绝使用 Android Q ffmpeg":错误=13,权限被拒绝 [英] permission is denied using Android Q ffmpeg": error=13, Permission denied

查看:129
本文介绍了权限被拒绝使用 Android Q ffmpeg":错误=13,权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 ffmpeg 从 RTSP 视频中获取帧.但是对于上面的 android 10,我收到如下错误.

I want to get the frames from the RTSP video using ffmpeg. But for android 10 above I am getting error as below.

 E/FFmpeg: Exception while trying to run: [Ljava.lang.String;@55e447f
java.io.IOException: Cannot run program "/data/user/0/com.example.downloadimagefromurl/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:10)
    at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38)
    at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)
    at android.os.AsyncTask$3.call(AsyncTask.java:378)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
    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)

正如@Saurabh Thorat 提供的答案,Google 不允许应用运行来自/data/user 目录的二进制文件.

As the answer provided by @Saurabh Thorat, Google doesn't allow apps to run binary files from /data/user directory.

我知道的一个糟糕的解决方案是将 compileSdkVersion 和 targetSdkVersion 更改为 28 或更低,然后重新发布我不推荐的应用程序.

One bad solution that I know is to change compileSdkVersion and targetSdkVersion to 28 or below and re-release my application which is not recommended.

因此,我也在为未来的版本寻找更可行的解决方案.

Hence, I am looking for more viable solutions for future releases as well.

任何提示、链接或建议将不胜感激.提前致谢.

Any hint, links or suggestion would be highly appreciated. Thanks in advance.

推荐答案

从 Android Q 开始,您无法在应用的私有数据目录中执行二进制文件.

From Android Q onwards, you cannot execute binaries in your app's private data directory.

来自问题跟踪器:https://issuetracker.google.com/issues/128554619

在 targetAPI 的应用程序数据文件上阻止 exec() 的更改 >=Q 正在按预期工作.请参见https://android-review.googlesource.com/c/platform/system/sepolicy/+/804149有关此更改的背景.在可写应用程序上调用 exec()文件是 W^X (https://en.wikipedia.org/wiki/W%5EX) 违规和代表一种不安全的应用实践.可执行代码应该始终从应用程序 APK 加载.

The change to block exec() on application data files for targetAPI >= Q is working-as-intended. Please see https://android-review.googlesource.com/c/platform/system/sepolicy/+/804149 for background on this change. Calling exec() on writable application files is a W^X (https://en.wikipedia.org/wiki/W%5EX) violation and represents an unsafe application practice. Executable code should always be loaded from the application APK.

虽然 exec() 不再适用于应用程序主页中的文件目录,它继续支持只读中的文件/data/app 目录.特别是,应该可以打包将二进制文件放入应用程序的本机 libs 目录并启用android:extractNativeLibs=true,然后在/data/app上调用exec()文物.使用 wrap.sh 功能完成了类似的方法,记录在https://developer.android.com/ndk/guides/wrap-script#packaging_wrapsh.

While exec() no longer works on files within the application home directory, it continues to be supported for files within the read-only /data/app directory. In particular, it should be possible to package the binaries into your application's native libs directory and enable android:extractNativeLibs=true, and then call exec() on the /data/app artifacts. A similar approach is done with the wrap.sh functionality, documented at https://developer.android.com/ndk/guides/wrap-script#packaging_wrapsh .

另外,请注意通过 exec() 执行的可执行文件是不按照Android进程生命周期管理,一般说起来,Android 应用程序不鼓励 exec().虽然不是安卓文档,使用exec()";使用 NDK详细介绍了这一点.依赖 exec() 可能有问题未来的 Android 版本.

Additionally, please be aware that executables executed via exec() are not managed according to the Android process lifecycle, and generally speaking, exec() is discouraged from Android applications. While not Android documentation, Using "exec()" with NDK covers this in some detail. Relying on exec() may be problematic in future Android versions.

这篇关于权限被拒绝使用 Android Q ffmpeg":错误=13,权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆