Using MediaCodec, how can I generate key i-frames with interval less than 1 second?

MediaFormat.KEY_I_FRAME_INTERVAL only takes an integer value, and I assume this is what controls how frequent the encoder generates an I-frame right? So does that mean if I am using MediaCodec I cannot possibly generate I-frames more frequently?


I finally found a workaround for this issue!

Insert the following code before a key frame is needed, then it will generate a key frame on the next available frame.

        Bundle b = new Bundle();
        b.putInt(MediaCodec.PARAMETER_KEY_REQUEST_SYNC_FRAME, 0);