get Video Frame - Android Media

Android examples for Media:Video

Description

get Video Frame

Demo Code


//package com.java2s;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.util.Log;

public class Main {
    public static Bitmap getVideoFrame(String videoPath, long frameTime) {
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        try {/*w w w  .  j  a  v  a2  s. c o  m*/
            retriever.setDataSource(videoPath);
            return retriever.getFrameAtTime(frameTime,
                    MediaMetadataRetriever.OPTION_CLOSEST);
        } catch (IllegalArgumentException ex) {
            Log.e("MediaUtils", "error getting video frame", ex);

        } catch (RuntimeException ex) {
            Log.e("MediaUtils", "error getting video frame", ex);
        } finally {
            try {
                retriever.release();
            } catch (RuntimeException ex) {
            }
        }
        return null;
    }
}

Related Tutorials