I`m trying to retrieve frames from video files which are captured by camera. I wrote a function to do so and i use it in a loop with different times ,receiving frames every 100000(micro sec) :
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 given time must be in microseconds and i tried that.No matter what , getFrameAtTime() returns same frame all the time .
Answer
I ran into the same problem but I could not find a solution using the MediaMetadataRetriever.
However, I did using this: https://github.com/wseemann/FFmpegMediaMetadataRetriever
Hope it helps.