I have extracted frames from a video using MetadataRetriever, and have stored all images in an ArrayList. I want to store all of them on an SD car
@Navneet Krishna
Videos have key-frames (sometimes called "sync" frames). The issue might be that: the first frame is the closest sync frame when you use OPTION_CLOSEST_SYNC...
Try replacing this line:
Bitmap bitmap=retriever.getFrameAtTime(i,OPTION_CLOSEST_SYNC);
with this (which gets closest-available frame to the given time):
Bitmap bitmap=retriever.getFrameAtTime(i,OPTION_CLOSEST);
Read about: CLOSEST & CLOSEST_SYNC.
Code below is untested, but is a general idea of "how to...", so let me now if it helps you...
Result should be one picture per second of video duration. Test with a short video.
//Create a new Media Player
MediaPlayer mp = MediaPlayer.create(getBaseContext(), videoFileUri);
int millis = mp.getDuration();
for (int i = 0; i < millis; i += 1000)
{
Bitmap bmp = retriever.getFrameAtTime( i * 1000, MediaMetadataRetriever.OPTION_CLOSEST );
if (bmp != null) { rev.add( bmp ); }
}
retriever.release ();