Liang Ma
Liang Ma

Reputation: 41

mediacodec intra-refresh-period & i-frame-interval

Recently I wanted to make a low-latency video call on Android phones, using the mediacodec class for codecs(e.g. video/avc).

In order to achieve a low-latency video stream, I want to call intra refresh(IR) technology. When I configure the h264 encoder with parameters, I found the parameters which i setting do not work. details as follows:

  1. i-frame-interval When I set this parameter to 0, the analysis of h264 stream is not all I-frame.
  2. intra-refresh-period

This parameter has no effect after setting, as can be seen from the results of the bitstream, the encoder did not achieve intra refresh.

Can you give me some guidance? I use linphone-android, the device is Samsung s8(SM-G9500, Android 7.0, API 24), and from the mediacodec.xml file we can see that this device supports intra refresh, Thanks in advance for your help!

Code:

AMediaFormat_setInt32(format, "i-frame-interval", 0);
AMediaFormat_setInt32(format, "bitrate-mode", 1);
AMediaFormat_setInt32(format, "profile", 1); // AVCProfileBaseline
AMediaFormat_setInt32(format, "level", 1024); // AVCLevel32
if(ms_get_android_sdk_version() >= 24)
        AMediaFormat_setInt32(format, "intra-refresh-period", 10);//7 0118

Upvotes: 4

Views: 2390

Answers (1)

Tomer Nuni
Tomer Nuni

Reputation: 189

You need to use a negative value for I_FRAME_INTERVAL.

See here: https://developer.android.com/reference/android/media/MediaFormat.html#KEY_I_FRAME_INTERVAL

What does the "OutputFormat" contain?

Upvotes: 2

Related Questions