Is there a way to step through a video file frame by frame? I've tried using a VideoView and I've had minor success. I can get the video the step through key frames but not individual frames. I figured this would be the default settings, especially with the way video compression works. Is there a way to override this default behavior or a configuration I can change?
Asked
Active
Viewed 5,850 times
2 Answers
5
The default behaviour in stagefright media framework is always to seek to key frame. (As opposed to the earlier framework's - opencore whose default seeking behaviour was to seek to time.)
You cannot do frame by frame seeking by using the MediaPlayer API's provided by Android.
If you really want implement frame by frame seeking then you will have to use a 3rd party multimedia framework like FFMPEG or you will need to implement your own.

bluefalcon
- 4,225
- 1
- 32
- 41
-
I guess I will implement my own and share it. – Spidy Aug 26 '11 at 18:01
-
Yeah I ran into this problem too with video cameras and showing and frames when processing objects on screan, eventually we went to MJPG since we had tighter control of time and framerates. – JPM Aug 26 '11 at 19:04
-
What if I record the video in such a way, that every frame is a key frame ? ;) – Moonlit Feb 10 '15 at 15:23
-
Unless you are writing your own encoder then its not possible, plus it defeats the whole purpose of encoding a video file, you might as well just zip the raw video frames! – bluefalcon Feb 10 '15 at 17:51
0
Have you looked at MediaMetadataRetriever ? There you can use getFrameAtTime(long timeUs, int option)
and return a Bitmap
.
Depending of the use, maybe it's what you need.

Tom Siwik
- 992
- 9
- 22
-
I'll have to give it a try. Will only work for local media (not url based media) but it's a step in the right direction if it works. – Spidy Aug 23 '11 at 23:12
-
In case you didn't know yet [MediaPlayer Sourcecode](http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=media/java/android/media/MediaPlayer.java;hb=HEAD) . `getFrameAt` is unused and deprecated. It's a good source to watch the MediaPlayer implementation. As Ravi said: you may implement your own. – Tom Siwik Aug 24 '11 at 22:47
-
In my experience `getFrameAtTime(long timeUs, int option)` performs very poorly. I have not found a solution myself, but this does not seem like it. – Jeremy Stucki Apr 17 '19 at 06:03