javiaf
javiaf

Reputation: 135

How to configure specific GOP size in MediaCodec with KEY_I_FRAME_INTERVAL parameter?

My issue is the next: I know MediaFormat.KEY_I_FRAME_INTERVAL is the interval in seconds (Integer) where the I-Frame is going to appear.

So if i give the value to 1, and my frame rate is 15, then the GOP size is going to be 15, and if the frame rate is 30, the GOP size is going to be 30.

So, being in the situation that the parameter MediaFormat.KEY_I_FRAME_INTERVAL is one integer (not being able to give the value 0.5 to be the gopsize 15 frames using a framerate of 30), Is there any solution to configure it to an specific GOP size?

Upvotes: 0

Views: 5014

Answers (1)

fadden
fadden

Reputation: 52303

As you note in the question, the key frames appear every KEY_I_FRAME_INTERVAL * KEY_FRAME_RATE frames. So if you want a GOP size of 15, specify an interval of 1 and a frame rate of 15, and then just send it video at 30fps.

This begs the question: what effect does lying about the frame rate have on the codec's ability to meet the bit-rate target? I know that some devices adjust the quality based on the presentation time stamps rather than a fixed notion of frames per second, which would allow everything to work out fine. It appears that not all devices work this way however.

Unfortunately, MediaCodec doesn't provide a more flexible way to specify the GOP size.

Upvotes: 3

Related Questions