How to set "I Frame Interval" in Media SDK H264 Encoder Dshow filter?

How to set "I Frame Interval" in Media SDK H264 Encoder Dshow filter?

I have set

m_EncoderParams.ps_control.GopPicSize = 50;

m_EncoderParams.ps_control.GopRefDist = 0;

But the I Frame Interval was still 256.
It seems that no matter what value I set to GopPicSize,the I Frame Interval remains constant(=256).
What went wrong?

My parameters setting was like this:

void CH264EncVideoFilter::SetDefaultParams(void)

{

m_EncoderParams.level_idc = Params::LL_AUTOSELECT;

m_EncoderParams.profile_idc = Params::PF_AUTOSELECT;

m_EncoderParams.pc_control = Params::PC_FRAME;

m_EncoderParams.ps_control.GopPicSize = 50;

m_EncoderParams.ps_control.GopRefDist = 0;

m_EncoderParams.ps_control.NumSlice = 0; // autoselect

m_EncoderParams.rc_control.rc_method = IConfigureVideoEncoder::Params::RCControl::RC_VBR;

m_EncoderParams.rc_control.bitrate = 0;

m_EncoderParams.target_usage = MFX_TARGETUSAGE_BALANCED;

m_EncoderParams.preset = CodecPreset::PRESET_USER_DEFINED;

m_EncoderParams.frame_control.width = 0;

m_EncoderParams.frame_control.height = 0;

}

later,I found out that

CH264EncVideoFilter::CH264EncVideoFilter(TCHAR* tszName, LPUNKNOWN punk, HRESULT* phr) :

CEncVideoFilter(tszName, punk, FILTER_GUID, phr)

{

m_bstrFilterName = FILTER_NAME;

m_mfxParamsVideo.mfx.CodecId = MFX_CODEC_AVC;

//fill m_EncoderParams with default values

SetDefaultParams();

// Fill m_EncoderParams with values from registry if available,

// otherwise write current m_EncoderParams values to registry

// ReadParamsFromRegistry();

CopyEncoderToMFXParams(&m_EncoderParams, &m_mfxParamsVideo);

AlignFrameSizes(&m_mfxParamsVPP.vpp.Out, (mfxU16)m_EncoderParams.frame_control.width, (mfxU16)m_EncoderParams.frame_control.height);

}

ReadParamsFromRegistry() function Fill m_EncoderParams with values from registry, so I just simply cancled this statement, GraphEdit says "This graph can't play(return code:0x80004005)

(Version 3.0.774.38156)
-Patrick

5 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

I finally found out that RCControl should set to CBR. Does it mean that I cannot use the VBR capability if i want to set I frame interval myself?

Hi,

The Media SDK DShow samples are unfortunately not perfectly suited for direct manipulation of parameters. Feel free to modify the sample code to fit your needs.

But to quickly get around the issue I suggest you remove the "CodecPreset::VParamsFromPreset()" call located at the end of the function "CopyEncoderToMFXParams" in "mfx_video_enc_filter_utils.cpp". This small change will let you set the parameter values using the SetParam() function.

Regards,Petter

Thanks for you suggestion!!

Best Reply

Hi again,

let me add some clarification to avoid potential confusion. The suggestion I gave works for the case when preset is used (such as PRESET_BALANCED).

But if you do not want to use a preset then you can set preset to PRESET_USER_DEFINED and in that case the parameter values you set will be applied even without the suggested code change.

Regards,Petter

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen