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 the parameters of framesurface

xiaozha
Beginner
419 Views
the functions MFXVideoENCODE_EncodeFrameAsync() "5", namelyMFX_WRN_INCOMPATIBLE_VIDEO_PARAM , why?
my code :

mfxSession *sSession= new mfxSession();
mfxVersion vVersion={MFX_VERSION_MINOR, MFX_VERSION_MAJOR};
if(MFX_ERR_NONE!= MFXInit(MFX_IMPL_AUTO,&vVersion,sSession))
return -1;
mfxIMPL implStyle = MFX_IMPL_AUTO;
MFXQueryIMPL( *sSession, &implStyle );
switch(implStyle)
{
case MFX_IMPL_SOFTWARE:
std::cout<<"software";
break;
case MFX_IMPL_HARDWARE:
std::cout<<"hardware";
break;
default:
std::cout<<"wrong";
break;
}
mfxVideoParam *par=new mfxVideoParam();
par->AsyncDepth=0;
par->Protected=0;
par->IOPattern=MFX_IOPATTERN_IN_SYSTEM_MEMORY;
par->mfx.CodecId=MFX_CODEC_AVC;
par->mfx.TargetKbps=100;
par->mfx.EncodedOrder=0;
par->mfx.FrameInfo.Height=480;
par->mfx.FrameInfo.Width=704;
par->mfx.FrameInfo.FrameRateExtD=2;
par->mfx.FrameInfo.FrameRateExtN=200;
par->mfx.FrameInfo.FourCC=MFX_FOURCC_NV12;
par->mfx.FrameInfo.ChromaFormat=MFX_CHROMAFORMAT_YUV420;
par->mfx.FrameInfo.PicStruct=MFX_PICSTRUCT_FIELD_TFF;
par->mfx.FrameInfo.CropX=0;
par->mfx.FrameInfo.CropY=0;
par->mfx.FrameInfo.CropW=704;
par->mfx.FrameInfo.CropH=480;
mfxStatus retOfInit=MFXVideoENCODE_Init(*sSession,par);//here retOfInit equals 0, which means no error;
mfxFrameSurface1 *frsf=new mfxFrameSurface1();//
memcpy(&frsf->Info,&par->mfx.FrameInfo,sizeof(mfxFrameInfo));
frsf->Info.Height=480;
frsf->Info.Width =704;
frsf->Info.FourCC=MFX_FOURCC_NV12;
frsf->Info.ChromaFormat=MFX_CHROMAFORMAT_YUV420;
frsf->Info.PicStruct=MFX_PICSTRUCT_FIELD_TFF;//I don't understand this parameter.
mfxU8* Y=new mfxU8[704*480];
mfxU8* UV= new mfxU8[704*240];
for(int i=0;i<704*480;i++)
Y=80;
for(int i=0;i<704*240;i++)
UV=150;
frsf->Data.Y=Y;
frsf->Data.UV=UV;
frsf->Data.Locked=0;
frsf->Data.Pitch=704;
mfxBitstream *bs=new mfxBitstream();
bs->Data=new mfxU8[1000000];
bs->MaxLength=1000000;
mfxSyncPoint syn;
int r= MFXVideoENCODE_EncodeFrameAsync(*sSession,NULL,frsf,bs,&syn);
//r equals 5 and there is no data in bs. I wanna know if some parameters are not correct.

I am a new guy in programming and h.264, and english, :(. Right here hoping for answers. thx.

0 Kudos
2 Replies
IDZ_A_Intel
Employee
419 Views
Hi xiaozha,

The primary issue you're facing is that there is not enough space in the bit stream buffer. Please increase the size to about 5MB and try again. You can also get an estimate of the requried size by calling GetVideoParam on the encoder and look at the mfx.BufferSizeInKB parameter.

Besides this, there are many somewhat strange parameter vales used in your code, such as the values selected as frame rate and target bit rate. I recommend exploring if these are the actual values you want to use?

Also, I would highly suggest performing a mem zero on the allocated parameter structures and bit stream.

Additionally, you will likely get varning MFX_WRN_INCOMPATIBLE_VIDEO_PARAMS when calling encoder init since the rate control value has not been set. Encoder will select a valid value for you, but this is probably not what you want?

The Media SDK encode sample has more details on how to setup an encode pipeline.

Regards,
Petter
0 Kudos
xiaozha
Beginner
419 Views
thanks a lot :) I am going to try more.
0 Kudos
Reply