GOP and TimeStamp

GOP and TimeStamp

Hi Guys,I am trying encode raw data using Media SDK.1) I want to configure the encoder such that i will get one IDR for 25 frames and remaining 24 frames as Slice frames(non IDR frames). What are the values I should set forGopPicSize,GopRefDist,GopOptFlag,IdrInterval.I was bit confused with the reference manual.2) Also I have obseved that the media SDK is doingOR operation with MFX_FRAMETYPE_REF for eachFrameType(e.g MFX_FRAMETYPE_REF|MFX_FRAMETYPE_P)..Is there any reason for this?3) I am gettingTimeStamp as zero once I encode the frame.How do I get valid time stamp ?
If you guys can help in solving these issues that will be great.Thank you soo much..Kind Regards,Venki

11 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Venki,

See answers below:1) "GopPicSize" is used to set distance between I frames."GopRefDist" is used to set I and P frames. For instance it it is set to 1 there will be no B frame encoded."IdrInterval" is used to specify the frequency of IDR (such as erery I frame, every other I frame etc...)

The Media SDK manual also specifies this behavior in details. If it is still unclear I suggest you experiment with different options to get a better understanding of how this works.

Media SDK also supports manual control of frame type via mfxEncodeCtrl. Please find more info on this topic in the manual.

2) Can you explain a bit more on what you mean? Are you referring to a generated stream or something specified in the SDK documentation?

3) Media SDK handles timestamps transparently. Whatever timestamp is specified as input to encoder (or decoder) is also delivered as the output for that frame.
Please make sure you have specified the input time stamp.

Regards,Petter

Hi Petter,Thank you for the quick response.1) I wil test GOP parameters.2) RegardingMFX_FRAMETYPE_REF, i have observed this in the output bit stream when we encode the raw image into a h264 compressed image (in mfxBitstream ->FrameType) and also I have observed this in the SDK reference manual (version 1.3) example 11,page no 108.3) Regarding the time stamp, I have set the time stamp in the input stream (mfxFrameSurface1->mfxFrameData->TimeStamp)while encoding the image but I received the output time stamp as zero(in the output mfxBitstream).Can you please guide me which parameter I should set for the methodEncodeFrameAsync to get a valid timestamp.
Kind Reagrds,Venki

Hi Venki,

2) The frame type selection algorithm in the manual is a simplification. All frames do not have to be a reference frame. For instance, if you specify GopOptFlag to CLOSED and STRICT, a frame at the end of the GOP will not become a reference.

3) You need to call SyncOperation to be able to access the complete compressed data for the frame in the bit stream object. Please refer to the Media SDK encoder sample for an example.

Regards,Petter

Hi Petter,Thank you for the response.3) I am callingSyncOperation to access thecomplete compressed data and I am able to get the compressed data also,but the problem is that I am not getting the time stamp as specified above.Kind Regards,Venki

Hi Venki,

That is certainly odd, this feature does work. What version of Media SDK are you using and are you using HW or SW encode?

I suggest referring back to the Media SDK encode sample code and add setting timestamp on the surface before encode and then verifying that the same timestamp is received in output bit stream after SyncOperation (for the specific task). After you've established that baseline, you can try to replicate similar behavior in your code.
Regards,Petter

Hi Petter,Thank you.I am using SW encode and the version is 1.3(Media SDK 2012)I have tested the enode sample code also but the issue is same.Kind Regards,Venki

Hi Venki,

Unfortunately I'm not sure how to resolve your issue.As a sanity check I did verify the timestamp behavior on my side using the Media SDK 2012 release and I do not see any issues. The timestamp is transferred as expected.
Could you please provide the exact set of parameters you used as an input to sample_encode?

Regards,Petter

Hi Petter,Thank you.Please find the input parameters I am passing tosample_encodeh264 -i TEST_720x576.raw -o TEST_720x576.cmp -w 720 -h 576 -f 25 -u quality
and the time stamp I gave as input is0xA3B4F37A and it is incremented by 4000 for every frame(hardcoded before calling EncodeFrameAsyncas pSurf->Data.TimeStamp=gTimeStamp)
Kind Regards,Venki

Hi Venki,I tested that same setup here on my side but do not see any issues. Timestamp is written to bit stream as expected.

Not sure what the problem may be. Could you try with a unmodified Media SDK encode sample to make sure that you did not introduce any side effects when modifying the code?

Regards,Petter

Thank you Petter.Kind Regards,Venki

Leave a Comment

Please sign in to add a comment. Not a member? Join today