GetFrameAtTime () returns the same frame

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.

+5
source share
1 answer

I ran into the same problem but could not find a solution using MediaMetadataRetriever.

However, I used this: https://github.com/wseemann/FFmpegMediaMetadataRetriever

Hope this helps.

+3
source

Source: https://habr.com/ru/post/1237130/


All Articles