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.

H.264 Encoder VBR

Ashim_Prasad
Beginner
855 Views

Hi,

I was trying VBR Rate control (MFX_RATECONTROL_VBR) for H.264 Encoder. The file size that gets generated is always same irrespective of amount of motion. I have specified max bit rate to be 2048 Kbps. It generates file size which matches roughly max bit rate and looks to be doing CBR.

Any other parameter that I need to set for making VBR work.

0 Kudos
4 Replies
Jeffrey_M_Intel1
Employee
855 Views

No additional parameters are needed.  However, which parameter are you setting?  The main parameter used is TargetKBPS.  If this is not set you will get a default value.  The maxKBPS setting does not actually cap the bitrate. It specifies the maximum bitrate at which the encoded data enters the Video Buffering Verifier (VBV) buffer.      

0 Kudos
Ashim_Prasad
Beginner
855 Views

I am setting TargetKbps to same as maxBitRate. Following are all the parameters that I am setting. I have tried setting maxBitrate to zero, in which case as per documentation encoder should compute this value.

param->mfx.CodecId = MFX_CODEC_AVC;
param->mfx.CodecProfile = MFX_PROFILE_AVC_MAIN;
param->mfx.CodecLevel = 0;
param->mfx.NumThread = 0;

param->mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
param->mfx.RateControlMethod = MFX_RATECONTROL_VBR;
param->mfx.GopPicSize = 30;
param->mfx.GopRefDist = 1;
param->mfx.GopOptFlag = MFX_GOP_CLOSED;

param->mfx.IdrInterval = 0;

param->mfx.InitialDelayInKB = 0;

param->mfx.TargetKbps = 2048;
param->mfx.MaxKbps = 2048;

param->mfx.NumSlice = 0;
param->mfx.NumRefFrame = 0;
param->mfx.EncodedOrder = 0;
param->mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;

param->mfx.FrameInfo.Width = BIT_ALIGN16(1280);

param->mfx.FrameInfo.Height =
            (MFX_PICSTRUCT_PROGRESSIVE == param->mfx.FrameInfo.PicStruct) ?
            BIT_ALIGN16(720) : BIT_ALIGN32(720);

param->mfx.FrameInfo.FrameRateExtN = 30;
param->mfx.FrameInfo.FrameRateExtD = 1;
param->mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
param->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;

param->mfx.FrameInfo.CropX = 0;
param->mfx.FrameInfo.CropY = 0;
param->mfx.FrameInfo.CropW = 1280;
param->mfx.FrameInfo.CropH = 720;

 

0 Kudos
Jeffrey_M_Intel1
Employee
855 Views

One way to start looking at this is if you can replicate the behavior with sample_encode, sample_multi_transcode, or one of the tutorials.  If yes, then behavior may be related to content.  If no, then there may be an application/parameter issue but you can use the example code as a guide.  For example code we recommend the tutorials.

0 Kudos
Bjoern_B_Intel
Employee
855 Views

Hi Ashim,

Let me share some background on CBR and VBR concepts as both are standard bitrate controls and more people might have questions on this as well. It all comes down to video quality and bitrate (file size).

Constant Bit Rate (CBR): The intended use for CBR are situations where bitrate variations are penalized and buffering is not possible (i.e. low latency for video conferencing, game streaming, very small physical decoder buffers).

Variable Bit Rate (VBR): The intended use for VBR are situations where a target bitrate is desired but bitrate variations are allowed. It can (but necessary don’t have to) provide higher quality at same bitrate versus CBR. Unlike CBR, VBR does not “pad” bitstream with unused bits.

Lookahead is an evolved VBR. Variations and latency are larger than VBR, but since it includes some benefits similar to 2-pass it can dramatically boost quality.

While the bitrate, and hence the file size, might be the same, the bitrate variation across a period of time is different compared to CBR and video quality might be higher using VBR instead of CBR. You might want to do a file size as well as a quality comparison when comparing CBR and VBR.

Best,
Bjoern

0 Kudos
Reply