GiraffeCompressor
GiraffeCompressor copied to clipboard
android 11 not working
files/ffmpeg": error=13, Permission denied
Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.
in Android 10/11
, according to new storage policy you can't save file in any public directory(as of i know for ffmpeg
),
so what i have tried is i saved output file to app specific private directory(in Android/data/app_folder/cache/output_file
) and then i moved the file to wherever i want(programmatically using InputStream
and OutputStream
), here's that code for moving file:
// file - output file converted using ffmpeg
// outputUri - new destination
private void copyCacheToOriginal(File file, Uri outputUri) {
try {
InputStream in = new FileInputStream(file);
try {
OutputStream out = getContentResolver().openOutputStream(outputUri);
try {
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
file.delete();
} finally {
out.close();
}
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "Error Copying File", Toast.LENGTH_SHORT).show();
}
}