I wanna get number of frames from video.. I m using following code:
package com.vidualtest;
import java.io.File;
import java.io.FileDescriptor;
import android.app.Activity;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;
public class VidualTestActivity extends Activity {
/** Called when the activity is first created. */
File file;
ImageView img;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
img = (ImageView) findViewById(R.id.img);
File sdcard = Environment.getExternalStorageDirectory();
file = new File(sdcard, "myvid.mp4");
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try {
retriever.setDataSource(file.getAbsolutePath());
img.setImageBitmap(retriever.getFrameAtTime(10000,MediaMetadataRetriever.OPTION_CLOSEST));
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
} catch (RuntimeException ex) {
ex.printStackTrace();
} finally {
try {
retriever.release();
} catch (RuntimeException ex) {
}
}
}
}
here in getFrameAtTime() i m passing different static time like 10000,20000, etc. in milliseconds , but still i'm getting same frame from video within different time. My aim is to get different frames with different time interval.
Please get me your possible help.
Thanks
The time offset parameter is in microseconds, not milliseconds. So multiply your time offset by 1000, and it should work correctly.
Thank you Google for NOT specifying this in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With