Fastest way to draw a MediaCodec-decoded video frame to screen?

风格不统一 提交于 2019-12-09 11:46:58

问题


I'm looking for the fastest way to take an image frame received from the MediaCodec decoder and draw it to the Android device screen. The important constraints and explanations are:

  1. Cannot use MediaPlayer. No intermediate app allowed.

  2. Must draw output frames from the MediaCodec decoder to the screen as quickly as possible (minimize latency).

  3. The available decoder output formats are as follows:
    ColorFormat[0] 0x00000013 COLOR_FormatYUV420Planar
    ColorFormat[1] 0x00000015 COLOR_FormatYUV420SemiPlanar
    ColorFormat[2] 0x7F000001 OMX_SEC_COLOR_FormatNV12TPhysicalAddress
    ColorFormat[3] 0x7FC00002 OMX_SEC_COLOR_FormatNV12Tiled

  4. The video resolution, and thus the resolution of each output frame, is 960x720.

  5. The target platform is Galaxy Note II and the approach can be specific to that platform (e.g. take advantage of available hardware functionality). This does not need to work on other platforms or be a generic solution.

An approach that takes less than 66ms would be good. Less than 33ms would be great. My current approach takes 80-90ms, which sucks. (I won't bother describing it since I don't want to skew the answers in any particular direction.)


回答1:


Your best bet is to decode directly to a Surface. Decoding to a ByteBuffer is going to slow you down quite a bit. A number of examples on bigflake (e.g. ExtractMpegFramesTest) send the output of a decoder to an off-screen surface and examine it with GLES, but it's a simple change to make it work with an on-screen SurfaceView.

Update: Grafika has two different MediaCodec-based video players that send the output to SurfaceView and TextureView, respectively.



来源:https://stackoverflow.com/questions/20203480/fastest-way-to-draw-a-mediacodec-decoded-video-frame-to-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!