Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getFrameAtTime() returns Same Frame

Tags:

android

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 .

like image 424
Mehrdad1373 Avatar asked Nov 30 '15 20:11

Mehrdad1373


1 Answers

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.

like image 149
Filip Marusca Avatar answered Nov 11 '22 16:11

Filip Marusca