Question

As the title describe, I'm trying to get MediaPlayer frames (while playing) and pass them to my C++ native code (using JNI).

So, I use MediaPlayer and "setDisplay(SurfaceView)" method to draw video pixels on the SurfaceView.

During the video playback, I use the "getDrawingCache" method of the SurfaceView to get last video frame pixels. But i've read that it the Bitmap will always be black.

So my question is : Is it possible to get the last frame displayed by MediaPlayer, in order to pass it to C++ code ?

PS : I have to use API level 8

Thanks

Was it helpful?

Solution

As of Android 4.1 they added a MediaCodec Api that allows you to access pretty much everything.

And in Android 4.3 they added the possibility to get the stream from a Surface.

http://developer.android.com/reference/android/media/MediaCodec.html

Before that, you are pretty much stuck. You can try to use the ffmpeg + JNI via NDK solution. It seems pretty hard to accomplish but the good news is if you make it, your frames will already be read at the C++ level.

OTHER TIPS

Certainly not for API level 8, but for API level 19+, you could get the surface from the surface view, and pass it to ImageReader.

The ImageReader class allows direct application access to image data rendered into a Surface

You can set a listener on the ImageReader using setOnImageAvailableListener. This will get you all the frames, including the last one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top