Search code examples
androidvideoandroid-mediacodec

Android MediaCodec decoder ,carry custom info with input video frames


Decode video frame and show it on screen using Android MediaCodec

I have to indicate wether a video frame can show on screen or not on MediaCodec decode output step. So video frame must carry the information wether it can show on screen on MediaCodec frame input step.

I have tried set BufferInfo.flag some bit , but MediaCodec will overwrite this variable , I can't get flag bit which I set on input step on output step.

I have another way to indicate show or not show . Use MediaCodec.BufferInfo#flags odd or even to indicate this info.

Is there any formal way to done this work ?


Solution

  • There's no other mechanism for transporting custom info along as far as I know. What you can do, however, is to keep track of such info manually. If the timestamps are unique, you can have a map that keeps track of timestamp -> custom info. If the timestamps aren't unique, you might need to store the real timestamp in the custom info and generate new timestamps (e.g. just an incrementing number) for each frame - this should work as long as the decoder doesn't try to actually use the timestamps for anything within the decoding process.