androidexceptionillegalargumentexceptionmediametadataretriever

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


I want to extract one frame from video in my app. The video is chosen from my storage device. After trying to call setDataSource I'm getting an IllegalArgumentException.

Here is the part of my code:

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

A value of imageUri is:

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

Is the path of my video in wrong format? I have also tried to use FFmpegMediaMetadataRetriever.


Solution

  • use

    med.setDataSource(context, imageUri)
    

    if it does not work use MediaStore and get MediaStore URI