Media Codec completely drain output buffer

Viewed 308

I am trying to completely remove output buffer from decoder output buffer of media codec, as

  while (true) {
        AMediaCodecBufferInfo info;
        auto status = AMediaCodec_dequeueOutputBuffer(codec, &info, 0);
        if (status >= 0) {
            AMediaCodec_releaseOutputBuffer(codec, status, false);
        } else {
            break;
        }
    }

For the purpose of seek, but when i start queuing input buffer, i am still getting older 1-2 frames as output. Can anyone point me the direction, Thanks,

1 Answers

If MediaCodec doesn't have enough input buffer it will not produce any output buffers unless it receives EOS. In order to drain the old frames you will either have to:

  • Start inputing frames after the from the new seek time and check the timestamp of the output buffers to discard the old frames.
  • Flush the media codec
Related