I'm trying to implement key frame insertion into my video encoding process. However, I'm facing issues with it.
When calling function MFXVideoENCODE_EncodeFrameAsync (&gop_ctrl, ...), I provide on requested key-frame in structure gop_ctrl.FrameType = FRAME_I | FRAME_IDR | FRAME_REF.
However, I'm not getting I-frame on the expected position ! (Or not at all).
(Please note I'm using code similar to sample_encode or sample_videoconf)
Other parameters in mfxInfoMFX structure which I'm using, are:
VBR encoding, NumSlice=4, NumRefFrame=0 (or 1), EncodedOrder=0, GopPicSize=24, IdrInterval=0, GopOptFlag=0, GopRefDist=1 or 4
I observed the following:
1. when using SW library, no extra key frame is inserted - never !!!
2. when using HW library, and GopRefDist=1 (i.e. no B-frames), then Key Frame is inserted in expected position
3. when using HW library, and GopRefDist=4, the Key Frame is inserted but on wrong position (shifted few frames earlier)
Could you please advice what else should I check? Which other parameters may influence key frame insertion process?
Or is there something wrong with Key Frame Insetion (known bug in Intel Media SDK R2)?
It looks to me like KeyFrame Insertion works only for P frames and only in HW library. That would be a pity!