2015-10-15 283 views
0

我试图使用JCodec从我的模拟器上的MP4获取所有框架。我在我的清单以下权限:jcodec权限被拒绝NIOUtils.readableFileChannel

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" /> 

通过我的adb外壳文件看起来是这样的:

[email protected]_x86_64:/sdcard/Download # pwd 
/sdcard/Download 
[email protected]_x86_64:/sdcard/Download # ls -la 
-rwxrwx--x root  sdcard_rw 19967250 2015-10-12 16:39 Hummingbird.MP4 

我试着做在chmod 777 Hummingbird.MP4,但不由于某种原因更改最后一组权限?

以下代码产生下面的异常。

String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath(); 
String fn = baseDir + "/Download/Hummingbird.MP4"; 
// test dir to make sure I'm in right place 
String dir = baseDir + "/Download"; 
File fDir = new File(dir); 
Log.i("TAG", "fDir.isDir()=" + fDir.isDirectory()); // this is true 
fileMp4 = new File(fn); 
try { 
    ch = NIOUtils.readableFileChannel(fileMp4); // line 220 in trace below 
} catch (FileNotFoundException e) { 
    e.printStackTrace(); 
} 

我也做了一个fileMp4.exists(),它返回true。

异常

10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: java.io.FileNotFoundException: /storage/1F1A-300C/Download/Hummingbird.MP4: open failed: EACCES (Permission denied) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at libcore.io.IoBridge.open(IoBridge.java:452) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at java.io.FileInputStream.<init>(FileInputStream.java:76) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at org.jcodec.common.NIOUtils.readableFileChannel(NIOUtils.java:336) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at medloh.com.mp4frames.MainActivity.onActivityResult(MainActivity.java:220) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.app.Activity.dispatchActivityResult(Activity.java:6428) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.app.ActivityThread.deliverResults(ActivityThread.java:3695) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.app.ActivityThread.-wrap16(ActivityThread.java) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.os.Handler.dispatchMessage(Handler.java:102) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.os.Looper.loop(Looper.java:148) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at android.app.ActivityThread.main(ActivityThread.java:5417) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at java.lang.reflect.Method.invoke(Native Method) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at libcore.io.Posix.open(Native Method) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  at libcore.io.IoBridge.open(IoBridge.java:438) 
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err:  ... 14 more 

查看与该代码/配置中的任何问题?

回答

0

我可以通过在/data/tmp/Hummingbird.MP4(adb push)处创建文件来获取'NIOUtils.readableFileChannel(fileMp4)'表达式。不知道它是关于/ sdcard及其符号链接的东西,或者我只是需要确保所有的目录和文件都由系统而不是root拥有。

无论如何,我现在正在解决MP4的其他问题和问题,但这是另一回事。