MPEG2 encoder GOP control

MPEG2 encoder GOP control

Hi
I'm trying to control sample MPEG2 encoder output GOP structure.
Found that mfxInfoMFX fields GopPicSize, GopRefDist and GopOptFlag are the ones that i need to tune.
But it seems that result is not always what i expect.
For example, I set:
GopPicSize = 15, GopRefDist = 2 and GopOptFlag = MFX_GOP_CLOSED | MFX_GOP_STRICT
and would expect closed GOP of 15 frames fixed size with maximum of2 B-frames in sequence.
Unfortunately what i get is 72% of GOPs having 30 frames, rest either 15 or 16.

Are there any other parameters i need to check in order to get the expected results?
Regards
Piotr

6 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

Hi Piotr,
Your setting looks absolutely correct except that you should expect 1 B frame if you set GopRefDist=2 (0 - undefined, 1 - no B frames). Could you share which version of Media SDK you are using, sw or hw library, which sample and what the other values of mfxVideoParam structure being passed to the encoder are?
You may also do a quick check if encoder had accepted the parameters by calling GetVideoParam function after Init.
Thanks,Nina

Hi Nina,

Of course, you are correct about number of B-frames.
That's another anomaly i'm seeing.
The 30 frame GOPs look like this: IPPBBPPBBPPBBPPBBPPBBPPBBPPBBP
while 15 frame ones: IBPBPBPBPBPBPBP.
There are also 16 and 24 frame GOPs present.
All GOPs seem to be closed but their length and structure change.

I'm using example direct show mpeg2 video encoder filter from SDK 2.0.12.24071 with sw library.
As for parameter checking, I belive that CEncVideoFilter::SetParam already does that using MFXVideoENCODE_Query function.

Below is a dump of my mfxVideoParam:

mfxmfxInfoMFX
-FrameInfomfxFrameInfo
FourCC842094158unsigned int
Width544unsigned short
Height480unsigned short
CropX0unsigned short
CropY0unsigned short
CropW544unsigned short
CropH480unsigned short
FrameRateExtN30000unsigned int
FrameRateExtD1001unsigned int
reserved30unsigned short
AspectRatioW60unsigned short
AspectRatioH51unsigned short
PicStruct1unsigned short
ChromaFormat1unsigned short
reserved20unsigned short

CodecId843534413unsigned int
CodecProfile64unsigned short
CodecLevel8unsigned short
NumThread0unsigned short
TargetUsage0unsigned short
GopPicSize15unsigned short
GopRefDist2unsigned short
GopOptFlag0x0003unsigned short
IdrInterval0unsigned short
RateControlMethod2unsigned short
InitialDelayInKB0unsigned short
QPI0unsigned short
BufferSizeInKB768unsigned short
TargetKbps4000unsigned short
QPP4000unsigned short
MaxKbps4000unsigned short
QPB4000unsigned short
NumSlice0unsigned short
NumRefFrame0unsigned short
EncodedOrder0unsigned short
DecodedOrder0unsigned short
ExtendedPicStruct12unsigned short

Kind regards
Piotr

Thanks for the full info, I will investigate.Nina

Hi Piotr,
I checked that these GOP settings work fine in both sample_encode and DShow encoder filter. I think you just put the code in the wrong place. If you set GOP parameters in SetParams function (my guess) then it would not take effect. This method belongs to the IConfigureEncoder interface and must be explicitly called by the application. For instance, it is called by property pages when parameters are changed. In simplest scenario of building and running the graph with GraphEdit without touching the property pages the method won't be called.
Please try placing the parameter setting within the constructor of CMPEG2EncVideoFilter class, right after parameters are read from the registry. This is the proper place to do this. Together with this please fix the issue I just found in our samples. Delete the lines
if (MFX_ERR_NONE != CodecPreset::VParamsFromPreset(*pParam1, pParam2->preset)) return ;
in file mpeg2_enc_filter.cpp line 279. This is a mistake and causes parameters being overwritten.
Please let me know if you find any other problems.
Regards,Nina

Hi Nina

thanks for your answer, i will try that

Kind regards,
Piotr

发表评论

登录添加评论。还不是成员?立即加入