Cricketer
Cricketer

Reputation: 2421

Getting video frames from a video in Android

I'm writing an app that captures a video from the camera of the Android device. I'm trying to get all the frames of a video without repeating frames and store them in some kind of list. By "without repeating frames", I mean this:

If I call MediaMetadataRetriever.getFrameAtTime(time, OPTION), there is a chance that two calls to this method can return the same frame if time hasn't changed much. I want to increment time enough before the next call to getFrameAtTime() such that I don't get the same frame again.

Obviously, I also want to make sure I don't miss any frames.

One way to do this is to get the frames per second of the video and increment time by the frequency of frame capture. But how would I get the frames per second of the video I captured?

Or how else would I accomplish this?

Upvotes: 1

Views: 3220

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57173

You can register a PreviewCallback handler. This interface declares onPreviewCallback() method which is called exactly as you want: once for every distinct video frame. The parameter is the raw camera image.

Upvotes: 1

Related Questions