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.

AV1 with constant bitrate (CBR)

Max_Gud
New Contributor I
2,076 Views

How do I get the oneVPL encoder to use CBR mode for the AV1 codec? Setting Rate Control to MFX_RATECONTROL _CBR does not give results and with any dark scene, the bitrate drops below TargetBitrate, after which it soars to values that are significantly higher than TargetBitrate. A similar problem is observed with HEVC, but the bitrate drop is not as strong.
When checking with MediaInfo files encoded with AV1 and HEVC codecs, there is no information about Constant bitrate, and for an AVC codec with the same encoding parameters, the information is displayed.

0 Kudos
18 Replies
RemyaP_Intel
Moderator
2,037 Views

Hi,


Thank you for posting in Intel communities.


To assist you better, we need the below details. Kindly share the same.


  • OS and Hardware details of the machine in which you are trying
  • oneVPL version which you are using
  • Exact steps to reproduce your issue
  • Sample reproducer to reproduce the issue
  • Screenshots and other configurations, if any



Regards,

Remya Premdas 



0 Kudos
Max_Gud
New Contributor I
2,030 Views

Windows 10, dGPU Intel Arc A380

oneVPL 2.9

I install MFX_RATECONTROL_CBR in mfx.RateControlMethod
Setting the target bitrate in mfx.TargetKbps

 

The code is part of the plugin for OBS Studio, if it is possible to check the operability in such conditions, then a sample for verification can be downloaded from the link https://github.com/ma3uk/obs-qsv-onevpl/releases

The source code for these steps is located at the link
https://github.com/ma3uk/obs-qsv-onevpl/blob/main/source/QSV_Encoder_Internal_new.cpp#L332

 

Screenshots of MediaInfo recorded videos using AV1, HEVC, AVC.

The parameters for recording video of all codecs are set the same.

Max_Gud_0-1684848831968.png

Max_Gud_1-1684848958571.png

Max_Gud_2-1684849007906.png

 

0 Kudos
RemyaP_Intel
Moderator
2,007 Views

Hi,


MSDK/oneVPL API uses unions to groups settings applicable for different bitrate modes. For example see https://github.com/oneapi-src/oneVPL/blob/master/api/vpl/mfxstructures.h#L735, TargetKbps, QPP and ICQQuality are in the same union. So, one thing which could go wrong would be to mix up settings applicable to different BRC modes which can lead to basically unpredictable results.

Are you changing any setting? Please verify the same. Otherwise, let us know.

Also, can you please share a sample reproducer(the input file you are using)?


Regards,

Remya Premdas


0 Kudos
Max_Gud
New Contributor I
1,945 Views

I looked at the Nvidia Nvenc implementation and they have the FillerDataInsertion parameter so that the bitrate is always at a given level, there is a 3 filler_payload flag in mfxPayload, can I use it for AV1? If I can, could you show me how to do it with code examples or similar.

0 Kudos
Max_Gud
New Contributor I
2,003 Views
Only the necessary parameters are used to set the modes, only Target Bitrate is used for CBR. The code used for the installation is shown below.
 
 
switch (pParams->RateControl) {
case MFX_RATECONTROL_LA_HRD:
case MFX_RATECONTROL_CBR:
mfx_EncParams.mfx.TargetKbps = (mfxU16)pParams->nTargetBitRate;
break;
case MFX_RATECONTROL_VBR:
case MFX_RATECONTROL_VCM:
mfx_EncParams.mfx.TargetKbps = pParams->nTargetBitRate;
mfx_EncParams.mfx.MaxKbps = pParams->nMaxBitRate;
break;
case MFX_RATECONTROL_CQP:
mfx_EncParams.mfx.QPI = (mfxU16)pParams->nQPI;
mfx_EncParams.mfx.QPB = (mfxU16)pParams->nQPB;
mfx_EncParams.mfx.QPP = (mfxU16)pParams->nQPP;
break;
case MFX_RATECONTROL_AVBR:
mfx_EncParams.mfx.TargetKbps = (mfxU16)pParams->nTargetBitRate;
mfx_EncParams.mfx.Accuracy = (mfxU16)pParams->nAccuracy;
mfx_EncParams.mfx.Convergence = (mfxU16)pParams->nConvergence;
break;
case MFX_RATECONTROL_ICQ:
case MFX_RATECONTROL_LA_ICQ:
mfx_EncParams.mfx.ICQQuality = (mfxU16)pParams->nICQQuality;
break;
case MFX_RATECONTROL_LA:
mfx_EncParams.mfx.TargetKbps = (mfxU16)pParams->nTargetBitRate;
break;
}
0 Kudos
RemyaP_Intel
Moderator
1,933 Views

Hi,


We do not have access to the google drive link to download the video. If the file size is less, please attach it here. Otherwise, I have shared the detailed steps separately in a private message on how to transfer the files. Please follow the steps and share the file with us.


Regards,

Remya Premdas


0 Kudos
Max_Gud
New Contributor I
1,925 Views

I attached to the message an archive with 2 video samples for recording, when recording which the problem is clearly visible when changing the scene.

0 Kudos
Max_Gud
New Contributor I
1,923 Views

I also attach a file after the encoding process, in it I specifically paused the video to get a static picture. Looking at the video bitrate indicators, you can see that when paused, the bitrate dropped to 311 kbit/s, and after the pause was lifted, it jumped to 10000 kbit/s

0 Kudos
RemyaP_Intel
Moderator
1,883 Views

Hi,


Thanks, We have received the video file. We are checking internally with our team. Meanwhile, could you please share with us all the encode parameters you have set(not only bitrate control mode)?



Regards,

Remya Premdas


0 Kudos
Max_Gud
New Contributor I
1,869 Views

Of course, here is a list of parameters

.mfx.CodecId = MFX_CODEC_AV1;

.mfx.TargetUsage = MFX_TARGETUSAGE_1;

.mfx.CodecProfile = MFX_PROFILE_AV1_MAIN ;

.mfx.GopOptFlag = MFX_GOP_CLOSED;

.mfx.GopRefDist = 8;

.mfx.IdrInterval = 0;

.mfx.NumSlice = 1;

CO.FieldOutput  = MFX_CODINGOPTION_ON;

CO.VuiVclHrdParameters = MFX_CODINGOPTION_ON;

CO.VuiNalHrdParameters = MFX_CODINGOPTION_ON;

CO.NalHrdConformance = MFX_CODINGOPTION_ON;

CO2.FixedFrameRate = MFX_CODINGOPTION_ON;

CO2.SkipFrame = MFX_SKIPFRAME_NO_SKIP;

CO2.BitrateLimit = MFX_CODINGOPTION_OFF;

CO3.BitstreamRestriction = MFX_CODINGOPTION_ON;

AV1BitstreamParam.WriteIVFHeaders = MFX_CODINGOPTION_OFF;
AV1ResolutionParam.FrameHeight = 1080
mfx_Ext_AV1ResolutionParam.FrameWidth = 1920;
AV1TileParam.NumTileGroups = 1;
AV1TileParam.NumTileColumns = 1;
AV1TileParam.NumTileRows = 1;
 
0 Kudos
RemyaP_Intel
Moderator
1,837 Views

Hi,


Thanks for your response. We are checking internally with our team. We will get back to you with an update.


Regards,

Remya Premdas


0 Kudos
RemyaP_Intel
Moderator
1,827 Views

Hi,


Could you please share with us if you have referred any document or guide for setting these parameters.


Regards,

Remya Premdas


0 Kudos
Max_Gud
New Contributor I
1,817 Views
0 Kudos
RemyaP_Intel
Moderator
1,778 Views

Hi,


Thanks for sharing. We are working on this. We will get back to you with an update.


Regards,

Remya Premdas


0 Kudos
mkpatel3
Employee
1,667 Views

Within HRD constraints, it may have smaller frame size in dark scenes and use up more bits for next frames but as long as it stays within HRD constraints, it should be OK. is your goal to achieve frame size close to target bitrate as much as possible? This will not be good in terms of compression efficiency. 

0 Kudos
Max_Gud
New Contributor I
1,666 Views

Yes, the task is to ensure that the bitrate is as stable as possible, without drawdowns on dark scenes and on black screens, for example in some games where the download of locations takes place on a black screen. This is necessary for streaming the stream to streaming services, such as Youtube, as well as for streaming the stream using WebRTC.
For example, when encoding the AVC codec, there are no such problems, the bitrate drawdown occurs, but it is insignificant and most often does not exceed 2000 kbit/s, for example, with a stream with a bitrate of 8000, the drawdown on the black screen is 6000-7000 followed by a surge to 9500-10000, but with AV1 on the black screen, the bitrate can drop to 47 kbit/s followed by a surge up to 16000-18000.

0 Kudos
Max_Gud
New Contributor I
1,580 Views

I also noticed that the AVC codec with ratecontrol LA_HRD behaves the same as AV1 with CBR - the bitrate on dark and static scenes can also drop significantly to 47 kbit/sec.

0 Kudos
RemyaP_Intel
Moderator
1,477 Views

Hi,


Sorry for the delay. Our team is still working on this. We will get back to you with an update.


Regards,

Remya Premdas


0 Kudos
Reply