Mehrdad
Mehrdad

Reputation: 180

getFrameAtTime() returns Same Frame

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 .

Upvotes: 6

Views: 1820

Answers (1)

Filip Marusca
Filip Marusca

Reputation: 166

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.

Upvotes: 3

Related Questions