List of usage examples for android.media MediaMetadataRetriever MediaMetadataRetriever
public MediaMetadataRetriever()
From source file:Main.java
public static long getVideoDurationInMillis(String videoFile) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(videoFile);/* w w w.java2 s . c om*/ String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); long timeInmillisec = Long.parseLong(time); retriever.release(); return timeInmillisec; }
From source file:Main.java
public static Bitmap getVideoScreenShot(String filePath) { MediaMetadataRetriever media = new MediaMetadataRetriever(); media.setDataSource(filePath);//from ww w .ja v a 2s.c o m Bitmap bitmap = media.getFrameAtTime(); media.release(); return bitmap; }
From source file:Main.java
public static Bitmap getFrameAtTime(String path) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(path, new HashMap<String, String>()); return retriever.getFrameAtTime(); }
From source file:Main.java
public static Bitmap getAudioImage(String audioPath) { MediaMetadataRetriever mmr = new MediaMetadataRetriever(); Bitmap bitmap = null;/* w w w . ja v a 2 s .c o m*/ try { mmr.setDataSource(audioPath); byte[] bb = mmr.getEmbeddedPicture(); bitmap = BitmapFactory.decodeByteArray(bb, 0, bb.length); } catch (Exception e) { e.printStackTrace(); } return bitmap; }
From source file:Main.java
public static Bitmap getVideoThumbnail(String filePath) { Bitmap bitmap = null;//from ww w . ja va2s . c o m MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (RuntimeException e) { e.printStackTrace(); } finally { try { retriever.release(); } catch (RuntimeException e) { e.printStackTrace(); } } return bitmap; }
From source file:Main.java
public static Bitmap getVideoFrame(String videoPath, long frameTime) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try {/*from www .ja v a 2s. c o m*/ retriever.setDataSource(videoPath); return retriever.getFrameAtTime(frameTime, MediaMetadataRetriever.OPTION_CLOSEST); } catch (IllegalArgumentException ex) { Log.w("FFMPEG.MediaUtils", "illegal argument exception"); } catch (RuntimeException ex) { Log.w("FFMPEG.MediaUtils", "error getting video frame"); } finally { try { retriever.release(); } catch (RuntimeException ex) { } } return null; }
From source file:Main.java
public static Bitmap createVideoThumbnail(String filePath) { Bitmap bitmap = null;//www.j av a2 s.c om MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { bitmap = android.media.ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.FULL_SCREEN_KIND); } catch (IllegalArgumentException ex) { } catch (RuntimeException ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } return bitmap; }
From source file:Main.java
public static Bitmap extractFromMediaMetadataRetriever(String filePath) { Bitmap bitmap = null;// w w w . j a v a 2s . c o m MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); return bitmap; } catch (IllegalArgumentException ex) { // Assume this is a corrupt video file } catch (RuntimeException ex) { // Assume this is a corrupt video file. } finally { try { retriever.release(); } catch (RuntimeException ex) { // Ignore failures while cleaning up. } } return null; }
From source file:Main.java
public static MediaMetadataRetriever initMetadataRetriever(String URI) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); if (!URI.contains("http:") && URI.endsWith("mp3")) { try {//from w w w . j av a 2 s . c om retriever.setDataSource(URI); } catch (Exception e) { Log.d(LOG_TAG, "Failed: " + URI + " " + e.toString()); e.printStackTrace(); return null; } } else { return null; } return retriever; }
From source file:Main.java
public static Bitmap getVideoScreenshotBitmap(Context context, String videoPath) { if (TextUtils.isEmpty(videoPath) || !new File(videoPath).exists()) { return null; }/*from www . java 2 s.c o m*/ Bitmap bitmap = null; MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); mediaMetadataRetriever.setDataSource(videoPath); bitmap = mediaMetadataRetriever.getFrameAtTime(0); return bitmap; }