Here you can find the source of createVideoThumbnail(String filePath, int size)
public static Bitmap createVideoThumbnail(String filePath, int size)
//package com.java2s; import android.graphics.Bitmap; import android.media.MediaMetadataRetriever; public class Main { public static Bitmap createVideoThumbnail(String filePath, int size) { Bitmap bitmap = null;// www. j a va 2 s . co m MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (IllegalArgumentException ex) { // Assume this is a corrupt video file ex.printStackTrace(); } catch (RuntimeException ex) { // Assume this is a corrupt video file. ex.printStackTrace(); } finally { try { retriever.release(); } catch (RuntimeException ex) { // Ignore failures while cleaning up. } } if (bitmap == null) return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int max = Math.max(width, height); if (max > 512) { float scale = 512f / max; int w = Math.round(scale * width); int h = Math.round(scale * height); bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true); } return bitmap; } }