app/src/main/java/fi/finwe/orion360/sdk/pro/examples/MainMenu.java
public static Bitmap extractFrameFromVideo(Context context, String videoUri, long positionMs) {
        if (null == videoUri || videoUri.length() == 0|| positionMs < 0) return null;
        Bitmap bitmap = null;
        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        try {
            mmr.setDataSource(context, Uri.parse(videoUri));
            bitmap = mmr.getFrameAtTime(positionMs * 1000); // convert to microseconds
        } catch (IllegalArgumentException iae) {
            iae.printStackTrace();
        } catch (RuntimeException re) {
            re.printStackTrace();
        } finally {
            try { mmr.release(); } catch (RuntimeException re) { Log.e(TAG, "MMR release failed.");}
        }
        return bitmap;
    }
/**
     * Extract a frame from given video URI at given position in time.
     *
     * Note: Uses MediaMetadataRetriever, which is fairly slow in extracting frames.
     * Consider caching the frame for its next usage, and try to avoid extracting frames
     * from video files over a network connection (create a downloadable thumbnail instead).
     *
     * @param context Android Context, such as an Activity.
     * @param videoUri The URI of the video file whose frames to extract.
     * @param positionMs The video position in time (milliseconds) where to extract a frame.
     * @return A video frame as a bitmap image, or null if failed to extract a frame.
     */
Extract a frame from given video URI at given position in time.
Note: Uses MediaMetadataRetriever, which is fairly slow in extracting frames.
Consider caching the frame for its next usage, and try to avoid extracting frames
from video files over a network connection (create a downloadable thumbnail instead).

@param context Android Context, such as an Activity.
@param videoUri The URI of the video file whose frames to extract.
@param positionMs The video position in time (milliseconds) where to extract a frame.
@return A video frame as a bitmap image, or null if failed to extract a frame.
Extract a frame from given video URI at given position in time . Note : Uses MediaMetadataRetriever which is fairly slow in extracting frames . Consider caching the frame for its next usage and try to avoid extracting frames from video files over a network connection ( create a downloadable thumbnail instead ) . @param context Android Context such as an Activity . @param videoUri The URI of the video file whose frames to extract . @param positionMs The video position in time ( milliseconds ) where to extract a frame . @return A video frame as a bitmap image or null if failed to extract a frame .
public static Bitmap extractFrameFromVideo(Context context, String videoUri, long positionMs) {
        if (null == videoUri || videoUri.length() == 0|| positionMs < 0) return null;
        Bitmap bitmap = null;
        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        try {
            mmr.setDataSource(context, Uri.parse(videoUri));
            bitmap = mmr.getFrameAtTime(positionMs * 1000); 
        } catch (IllegalArgumentException iae) {
            iae.printStackTrace();
        } catch (RuntimeException re) {
            re.printStackTrace();
        } finally {
            try { mmr.release(); } catch (RuntimeException re) { Log.e(TAG, "MMR release failed.");}
        }
        return bitmap;
    }
public static Bitmap extractFrameFromVideo ( Context context , String videoUri , long positionMs ) { if ( null == videoUri || videoUri . length ( ) == 0 || positionMs < 0 ) return null ; Bitmap bitmap = null ; MediaMetadataRetriever mmr = new MediaMetadataRetriever ( ) ; try { mmr . setDataSource ( context , Uri . parse ( videoUri ) ) ; bitmap = mmr . getFrameAtTime ( positionMs * 1000 ) ; } catch ( IllegalArgumentException iae ) { iae . printStackTrace ( ) ; } catch ( RuntimeException re ) { re . printStackTrace ( ) ; } finally { try { mmr . release ( ) ; } catch ( RuntimeException re ) { Log . e ( TAG , "MMR release failed." ) ; } } return bitmap ; }
Extract a frame from given video URI at given position in time.
Extract a frame from given video URI at given position in time .
// convert to microseconds