MediaMetadataRetrieverJNI(14060): getFrameAtTime: videoFrame is a NULL pointer(Android)

懵懂的女人 提交于 2019-12-01 19:18:27

Try using MediaMetadataRetriever.OPTION_CLOSEST_SYNC instead of MediaMetadataRetriever.OPTION_NEXT_SYNC.

If that doesn't work, then you should try using FFmpegMediaMetadataRetriever library, since MediaMetadataRetriever is not compatible with all API's.

EDIT:

Try this for SD card files:

FFmpegMediaMetadataRetriever retriever = new  FFmpegMediaMetadataRetriever();
try {
retriever.setDataSource("mnt/sdcard/video.mp4"); //file's path
Bitmap bitmap = retriever.getFrameAtTime(100000,FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC );
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
i.setImageDrawable(drawable);

} catch (Exception e) {
e.printStackTrace();
}
finally{
retriever.release();
}

In my experience, the built in MediaMetadataRetriver rarely works in general. Try something like this instead.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!