Use MediaCodec and MediaExtractor to decode and code video

Viewed 8902

I need to decode a video into a sequence of bitmaps, such that I am able to modify them, and then compress them back to a video file in android.

I plan to manage this by using getFrameAtTime and saving it to an image sequence. Then I can modify images in the sequence and code it back to a movie. But I have two problem with this:

  • First, as I read it, the getFrameAtTime is for creating thumbnails and will not guarantee returning the correct frame. This makes the video laggy.
  • Secondly, saving the images and reading it back takes a long time.

I read that the proper way of doing the decode is with MediaExtractor, this is fine, but I only have examples to render it directly to a surfaceView. Is there any way for me to convert the outputBuffer to a bitmap?

I would need it to get it working with an api level of 16 and above.

2 Answers
Related