ffmpeg-kit android: how to use -f concat -i input.txt with multiple file uris?

83 Views Asked by At

I am trying to use ffmpeg-kit on Android.

It says it can convert Storage Access Framework (SAF) Uris into paths that can be read or written by FFmpegKit.

Reading a file:

Uri safUri = intent.getData();
String inputVideoPath = FFmpegKitConfig.getSafParameterForRead(requireContext(), safUri);
FFmpegKit.execute("-i " + inputVideoPath + " -c:v mpeg4 file2.mp4");

However, I am trying to use the concat mode with input.txt specifying the file list, like:

file 'frame01.png'
duration 40ms
file 'frame02.png'
duration 40ms
file 'frame03.png'
duration 40ms
file 'frame04.png'
duration 40ms

Then execute:

ffmpeg -f concat -safe 0 -i input.txt -c:v libx264 -pix_fmt yuv420p output.mp4

This worked fine if I copy/put all the files in app's local cache directory where all the files can be directly accessed by file path.

However, if I let user to pick multiple files, which Android system will return a URI for each content, after I tried to convert the URI to 'saf file path' by the FFmpegKitConfig.getSafParameterForRead() method and put the path in the input.txt, it will give me error:

[saf @ 0xb400007896b7e550] Protocol 'saf' not on whitelist 'file,crypto,data'!
[concat @ 0xb400007916b3c350] Impossible to open 'saf:1.png'

It seems the concat mode cannot recognize the file path converted from an SAF uri.

Is it a limitation of current ffmpeg-kit android impl or did I miss some parameters that should be specified?

Thanks a lot.

0

There are 0 best solutions below