0

I had done with taking video as input. Now decided to get frames with it, so I used MediaMetadataRetriever(). After using this got only first frame. So can anybody suggest me the remedy?

String STR = (String) Environment.getExternalStorageDirectory().getAbsolutePath();

MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(STR+"/vd.3gpp");

img = (ImageView) findViewById(R.id.imageView1); 
img.setImageBitmap(retriever.getFrameAtTime(1000,MediaMetadataRetriever.OPTION_NEXT_SYNC));

Thanks in advance.

berak
  • 39,159
  • 9
  • 91
  • 89
Somashekar
  • 31
  • 1
  • 8

1 Answers1

1

At this point:

img.setImageBitmap(retriever.getFrameAtTime(1000,MediaMetadataRetriever.OPTION_NEXT_SYNC));

You are retrieving exactly one frame and setting exactly one bitmap. What you need is a loop, like:

int videoLength = /* get video length from some where */
for(int i = 0; i < videoLength; i *= 1000000)
{
    img.setImageBitmap(retriever.getFrameAtTime(1000, MediaMetadataRetriever.OPTION_NEXT_SYNC));
}
Sam
  • 253
  • 1
  • 9
  • I added a loop like this before but getting the videolength is the critical one.. can you help me in getting the value of videolength. – Somashekar Jan 22 '14 at 07:29
  • @user3217889 I don't have a android system here so I can't try. But [here](http://stackoverflow.com/questions/19689553/how-to-read-length-of-video-recorded-with-mediarecorder-into-private-app-storage) are 2 solutions to your problem. – Sam Jan 22 '14 at 08:00
  • Thanks a lot.. let me check out once. – Somashekar Jan 22 '14 at 08:45