I am trying to extract frames from video files that are captured by the camera. I wrote a function for this, and I use it in a loop with different times, getting frames every 100000 (microseconds):
public static Bitmap getVideoFrame(long time) { MediaMetadataRetriever mdr = new MediaMetadataRetriever(); mdr.setDataSource(path); try { return mdr.getFrameAtTime((time),MediaMetadataRetriever.OPTION_CLOSEST); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (RuntimeException ex) { ex.printStackTrace(); } finally { try { mdr.release(); } catch (RuntimeException ex) { } } return null; }
I know that the set time should be in microseconds, and I tried this. No matter what, getFrameAtTime () returns the same frame all the time.
source share