I want to extract frames from video file stored on the device. Every solution i found is to use FFmpegMediaMetadataRetriever or MediaMetadaraRetriever, but as I wrote here it's not working for me. Is there any other way to extract frames from video?
1 Answer
I admit I haven't used this method for a while, but if it still works with the current Android API, it should do the trick.
Please let me know if it still works. If not - I will delete this answer.
public static Bitmap getVideoFrame(Context context, Uri uri, long time) { Bitmap bitmap = null; MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(context, uri); bitmap = retriever.getFrameAtTime(time); } catch (RuntimeException ex) { ex.printStackTrace(); } finally { try { retriever.release(); } catch (RuntimeException ex) { ex.printStackTrace(); } } return bitmap; } Hope this helps.
1 Comment
Androidew1267
It's not working for me, but it works when I use setDataSource(context, Uri) instead of setDataSource(path).