Skip to main content

Posts

Showing posts from April, 2014

How to create a thumbnail from a video in Android

Recently i had create a thumbnail from a video recorded in an Android Phone. I found out an easy way to create thumbnail using the ThumbNailUtils class. Code for creating a thumbnail of a Video and saving it in a folder named "online" in the sdcard, in Android: String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/online"; File mediaFile = new File(path); if(!mediaFile.exists()){ mediaFile.mkdir(); } File file = new File(mediaFile, "/IMG_"+timeStamp+".PNG".toString()); Bitmap thumbnail1 = ThumbnailUtils.createVideoThumbnail( selectedvideopath,MediaStore.Video.Thumbnails.MINI_KIND ); if (file.exists()) file.delete(); try { FileOutputStream out = new FileOutputStream(file); thumbnail1.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } String fileimg=file.getAbsolutePath().toString(); //fileimg has the path of thethubnail created Byt