Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Storage Access Framework

Taner Sener edited this page Feb 3, 2020 · 3 revisions

If you want to use a file selected using Storage Access Framework (SAF) with MobileFFmpeg, you can use the following method to convert a Uri to a file path defined with pipe protocol.

Both input and output files can be defined with pipe protocol. But some file formats require the output to be seekable, so pipe protocol will fail with them.

String safUriToFFmpegPath(final Uri uri) {
    try {
        ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(uri, "r");
        return String.format(Locale.getDefault(), "pipe:%d", parcelFileDescriptor.getFd());
    } catch (FileNotFoundException e) {
        return "";
    }
}
Clone this wiki locally