I am trying to get a frame from the video (thumbnail) and convert it to base64. I have used the following code but sometimes it doesn't work:
Uri selectedVideo = Uri.parse(intent.getStringExtra("trimmedVideo"));
MediaMetadataRetriever mMMR = new MediaMetadataRetriever();
mMMR.setDataSource(this, selectedVideo);
Bitmap thumbnail = mMMR.getFrameAtTime();
Log.d(Global.getTag(), "thumbnail: "+thumbnail);
Also I get this error in logcast:
E/MediaMetadataRetrieverJNI: getFrameAtTime: videoFrame is a NULL pointer
And thumbnail is null. Thanks in advance.
Note: I also try to use the next code but it doesn't work.
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MICRO_KIND);