George
George

Reputation: 3807

Android::get a frame of a Video?

I have a video, and I need to get some of its frames.

I used to do the following: Create a standart bitmap with the size of the video in question, create a canvas and set it to draw on a bitmap.

I use a SurfaceView and a surfaceHolder. A mediaPlayer is drawing on the surfaceView, and I have a method that calls surfaceView.draw(canvas), which draws on the canvas, which draws to the bitmap, which I eventually take and use...

My problem is that 60% of the time I get black frames. The mediaplayer plays its content in a separete thread, and I do not know when the video has started, and when - not, so I believe this is what is getting my black screens.

I need a workaround, a fix, or another method to get the video frame.

Thanks in advance.

Upvotes: 0

Views: 4508

Answers (2)

Reno
Reno

Reputation: 33792

How about using MediaMetadataRetriever's getFrameAtTime(). For lower API versions use this

Upvotes: 0

Chris Stratton
Chris Stratton

Reputation: 40357

You might try looking at the source of the gallery app or wherever its video thumbnails come from if they are externally created

Upvotes: 1

Related Questions