使用 MediaMetadataRetriever 从存储设备的视频中提取帧 - IllegalArgumentException at setDataSource()

Extracting frame from video from storage device using MediaMetadataRetriever - IllegalArgumentException at setDataSource()

我想从我的应用中的视频中提取一帧。该视频是从我的存储设备中选择的。尝试调用 setDataSource 后,我收到 IllegalArgumentException。

这是我的部分代码:

MediaMetadataRetriever med = new MediaMetadataRetriever();
med.setDataSource(imageUri.toString());

imageUri 的值为:

content://com.android.providers.media.documents/document/video%3A59728

我的视频路径格式有误吗? 我也尝试过使用 FFmpegMediaMetadataRetriever。

使用

med.setDataSource(context, imageUri)

如果它不起作用,请使用 MediaStore 并获取 MediaStore URI