Skip to content

Storage Access Framework

Taner Şener edited this page Dec 30, 2021 · 2 revisions

If you want to use a file selected using Storage Access Framework (SAF) with FFmpegKit, you can use the following methods to convert a Uri to a file path defined with FFmpegKit's saf: protocol. That path can be safely used as input or output in FFmpegKit and FFprobeKit commands.

Input
Uri uri = intent.getData();
String inputPath = FFmpegKitConfig.getSafParameterForRead(requireContext(), uri);
FFmpegKit.execute("-i " + inputPath + " ... output.mp4");
Output
Uri uri = intent.getData();
String outputPath = FFmpegKitConfig.getSafParameterForWrite(requireContext(), uri);
FFmpegKit.execute("-i input.mp4 ... " + outputPath);
Both Input and Output
Uri uri = intent.getData();
String path = FFmpegKitConfig.getSafParameter(requireContext(), uri, "rw");
FFmpegKit.execute("-i input.mp4 ... " + path);
Clone this wiki locally