0

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.

George
  • 3,727
  • 9
  • 31
  • 47

2 Answers2

1

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

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
0

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

Community
  • 1
  • 1
Reno
  • 33,594
  • 11
  • 89
  • 102