extract all video frames in Android
android, camera, frame, photo, video
Solution
I faced the same problem before and the Android's `MediaMetadataRetriever` seems not appropriated for this task since it doesn't have a good precision. I used a library called `"FFmpegMediaMetadataRetriever"` in android studio:
Add this line in your build.graddle under module app:
`compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'`
Rebuild your project.
Use the `FFmpegMediaMetadataRetriever` class to grab frames with higher precision:
FFmpegMediaMetadataRetriever med = new FFmpegMediaMetadataRetriever();
med.setDataSource("your data source");
and in your loop you can grab frame using:
Bitmap bmp = med.getFrameAtTime(i*1000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST);
Problem
I recorded a Video for limited time. Now i want to fetch all frames of video. I am using the below code and by using it i am able to get frames but i am not getting all video frames. 3 to 4 frames are repeated then i got a different frame. But as we all know we can get 25- 30 frames in a second to display smooth video. How to get all frames. ``` for (int i = 0; i < 30; i++) { Bitmap bArray = mediaMetadataRetriever.getFrameAtTime( 1000000 * i, MediaMetadataRetriever.OPTION_CLOSEST); savebitmap(bArray, 33333 * i); } ``` I don't want to use NDK. I got this link don't know what should be the value for "argb8888". I am getting error here. Can anyone explain how to do it. Getting frames from Video Image in Android