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.

How to set up Media encoder mfx to have 2 B-frame

jigong
Beginner
636 Views
Hi
I want to have 2 B-frames from Media encoder and set GopRefDist to be 3. But the size of encoded file is same as that of GopRefDist = 1 (no B-frame). It is supposed that encoded data size with B-frame is lower than that without B-frame. Here is the code
m_mfxEncParams.mfx.GopPicSize = 15; //gop length should be enough to consume bitrate
m_mfxEncParams.mfx.GopRefDist = 3; //Distance between I- or P- key frames (1 means no B-frames)
m_mfxEncParams.AsyncDepth = 1;//internal buffering should be disabled in encode
m_mfxEncParams.mfx.NumRefFrame = 1;
Thanks for any advice.
Jiuxiang
0 Kudos
7 Replies
Petter_L_Intel
Employee
636 Views
Hi Jiuxiang,

The way you configure GOP is correct to produce a P,B,B sequence.

The file size is not much dependent on the selected GOP structure but instead depends on the rate control and bit rate you have selected.

If you analyze the final encoded stream you will see that the B frames are significantly smaller than the P frames which is what I think you're expecting to see?

Regards,
Petter
0 Kudos
jigong
Beginner
636 Views
Hi Petter,
Thanks for reply.
1, Here is NAL type of first 21 encoded frame types: AUD, SPS, PPS, SEI, IFrame, AUD, PPS, SEI, PFrame,AUD, PPS, SEI, PFrame,AUD, PPS, SEI, PFrame,AUD, PPS, SEI, PFrame. I did not see B-Frame. BTW, is the index of B-Frame same as P-Frame?
2. You are right. I changed GOP size to use more P-Frames to want to reduce the size of encoded file ( not change the bitrate). But all the kind results have the same size. P-frame has 50% of I-Frame in size. Why the encoded files have the same size even if using more P-Frame.?
3. In our application, we have to use higher bitrate stream to compansate the high motion factor and high resolution, is there a way to reduce the size of encoded file (because transported by network) in Media SDK? Such as like 2 pass encoding ( I know Media SDK does not support 2 pass encoding.)
Thanks.
Jiuxiang
0 Kudos
Petter_L_Intel
Employee
636 Views
Hi Jiuxiang,

1. To verify your config I used the same set of parameters you supplied to encode, the encoded stream generated PBBP frame type order as expected.... It's following the exact same NAL sequence as you specified but b-frames are generated. I suspect your configuration is slightly different?
If you're still having issues making it work please provide Media SDK tracer log so that we can take a look at the set of parameters you use.

2. As stated earlier, the selected bit rate will dictate the size of your file. If you use frequent b-frames you may consider decreasing the bit rate. You can also explore the VBR, AVBR or QCP rate modes for greater momentary bit rate dynamics. Media SDK also support dynamic bit rate change, which may be of interest to you if you need to quickly adapt to changes in the environment. Using QCP mode you can also control QP for each frame which gives you indirect control of bitrate.

3. Media SDK does not support 2 pass encoding.

Regards,
Petter
0 Kudos
jigong
Beginner
636 Views
Hi Petter,
Thank you very much. Your suggestion is very helpful. The traceing the log file shows the encoded file does include B-frames. Since I used CBR, so whatever changeing other setting, all the files have the same size. Once using other bitrate control, the size of encoded file reduces significantly although the bitrate is as high as before.
If the size of encoded file reduced a lot, does it mean the quality of video is lower too even have the same bitrate setting? In this case, does the bitrate setting have any meanings?
Thanks.
Jiuxiang
0 Kudos
Petter_L_Intel
Employee
636 Views
Hi Jiuxiang,

there is no direct relation between bitrate and quality. The quality of the encoded output depends on many things such as profile, GOP, etc. etc.

If you want better control of quality per frame or frame type please check out the CQP rate control mode.

Regards,
Petter
0 Kudos
jigong
Beginner
636 Views
Hi Petter,
Thank you for your helpful suggestion. I am still trying to understand the relationship between video quality and configuration of Media SDK mfxVideoParam. But I didnot know what the following members of mfxVideoParam mean: NumSlice, EncodedOrder and BufferSizeInKB.
Could you tell me what acroname ofCQPis?
Thanks.
Jiuxiang
0 Kudos
Petter_L_Intel
Employee
636 Views
Hi Jiuxiang,

Please refer to the Media SDK manual and developer guide for details about the parameters.
CQP = Constant Quantization Parameters. Also referenced in manual.

Hope this helps, let us know if you have any questions.

Regards,
Petter
0 Kudos
Reply