Отказано в разрешении openFileDescriptor на передачу файла из SDCARD в FFmpeg
Я пытаюсь работать с файлом из Sdcard, который должен быть передан в FFmpeg, для этого я использую
Uri contentUri = ContentUris.withAppendedId(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
cursor.getLong(Integer.parseInt(BaseColumns._ID)));
String fileOpenMode = "r";
ParcelFileDescriptor parcelFd =
resolver.openFileDescriptor(contentUri, fileOpenMode);
if (parcelFd != null) {
int fd = parcelFd.detachFd();
// Pass the integer value "fd" into your native code. Remember to call
// close(2) on the file descriptor when you're done using it.
}
int pid = android.os.Process.myPid();
String mediaFile = "/proc/" + pid + "/fd/" + fd;
Toast.makeText(videoexample.this, "mediafile" + mediaFile, Toast.LENGTH_SHORT).show();
//File directoryToStore = videoexample.this.getExternalFilesDir("tempDirectory");
File directoryToStore = videoexample.this.getExternalFilesDir("tempDirectory");
if(directoryToStore != null) {
if (!directoryToStore.exists()) {
if (directoryToStore.mkdir()) ; //directory is created;
}
}
// Output path passed to FFmpeg
String outputPath = directoryToStore+"/testFile.mp4";
int rc = FFmpeg.execute("-y -i "+mediaFile+" -filter:v scale=1280:720 -c:a copy "+outputPath);
Если этот файл присутствует на SDCard, он выдает ошибку
E/mobile-ffmpeg: /proc/20124/fd/169: Permission denied
в logcat
, однако, если файл из внутреннего хранилища (телефона), он работает нормально
все разрешения даны, я пробую на Moto C android 7.0
любая помощь будет полезна