Programming Tips - Android: Reliably get video metadata (eg thumbnail)

Date: 2020jul18 OS: Android Language: Java Q. Android: Reliably get video metadata (eg thumbnail) A. Sadly, the built-in ThumbnailUtils.createVideoThumbnail() isn't reliable. It doesn't work an many devices.
// Just one line, can not be trusted Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(videoFilename, MediaStore.Video.Thumbnails.MINI_KIND);
Luckily Jcodec http://jcodec.org works on all Android devices (for me). Its is slower and you need to add it to your project.
try { final int frameNumber = 10; Picture picture = FrameGrab.getFrameFromFile(new File(videoFilename), frameNumber); Bitmap bitmap = AndroidUtil.toBitmap(picture); } catch (Exception ex) { // Handle }