Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

GOP and TimeStamp

venky999
Beginner
1,264 Views
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 for
GopPicSize,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
0 Kudos
10 Replies
Petter_L_Intel
Employee
1,264 Views
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
0 Kudos
venky999
Beginner
1,264 Views
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
0 Kudos
Petter_L_Intel
Employee
1,264 Views
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
0 Kudos
venky999
Beginner
1,264 Views
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
0 Kudos
Petter_L_Intel
Employee
1,264 Views
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
0 Kudos
venky999
Beginner
1,264 Views
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
0 Kudos
Petter_L_Intel
Employee
1,264 Views
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
0 Kudos
venky999
Beginner
1,264 Views
Hi Petter,
Thank you.
Please find the input parameters I am passing tosample_encode
h264 -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
0 Kudos
Petter_L_Intel
Employee
1,264 Views
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
0 Kudos
venky999
Beginner
1,264 Views
Thank you Petter.
Kind Regards,
Venki
0 Kudos
Reply