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
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.

Correct parameters for MFXVideoENCODE_Query


MFXVideoENCODE_Query continues to return MFX_ERR_UNSUPPORTED in all combinations of parameters.  Platform is Intel(R) Core(TM) i5-7260U CPU @ 2.20GHz.

My vainfo returns the following information:

libva info: VA-API version 1.3.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/
libva info: Found init function __vaDriverInit_1_3
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.3 (libva 2.3.0)
vainfo: Driver version: Intel iHD driver - 16.9.git_00f9ae_2018-10-01
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD

and my relevant code is as follows

    mfxStatus sts = MFX_ERR_NONE;

    // Initialize the Session
    MFXVideoSession session;
    mfxIMPL impl = MFX_IMPL_AUTO_ANY;
    mfxVersion ver = {{0, 1}};
    sts = session.Init(impl, &ver);

    // Initialize the Encoder
    mfxENC = std::make_unique<MFXVideoENCODE>(session);

    // Set parameters for encoder
    mfxVideoParam mfxEncParams;
    memset(&mfxEncParams, 0, sizeof(mfxEncParams));

    mfxEncParams.mfx.CodecId = MFX_CODEC_AVC;
    mfxEncParams.mfx.CodecLevel = MFX_LEVEL_AVC_1;
    mfxEncParams.mfx.TargetKbps = kbitrate;
    mfxEncParams.mfx.EncodedOrder = true;

    mfxEncParams.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
    mfxEncParams.mfx.FrameInfo.Width = f_width;
    mfxEncParams.mfx.FrameInfo.Height = f_height;
    mfxEncParams.mfx.FrameInfo.CropX = 0;
    mfxEncParams.mfx.FrameInfo.CropY = 0;
    mfxEncParams.mfx.FrameInfo.CropW = f_width;
    mfxEncParams.mfx.FrameInfo.CropH = f_height;
    mfxEncParams.mfx.FrameInfo.FrameRateExtN = framerate;
    mfxEncParams.mfx.FrameInfo.FrameRateExtD = 1;
    mfxEncParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;

    // Query the parameters to verify
    sts = mfxENC->Query(&mfxEncParams, &mfxEncParams);
    sts = mfxENC->Init(&mfxEncParams);

Are my parameters incorrect, and if so how can I verify the correct parameters for the platform? kbitrate, f_width, f_height, and framerate are external parameters that have been tested at values 5000, 640, 480, 25 respectively.

0 Kudos
3 Replies

Hi Mark,

It looks like your API usage is not in the correct sequence, actually mfxENC->Init() and mfxENC->Query() is reversed. You should call Init() first.


0 Kudos

But in SDK Developer Reference was written about MFXVideoENCODE_Query: "The application can call this function before or after it initializes the encoder"

0 Kudos

Hi Anatoly,

Sorry for the late response, I think there should be some conflict among the parameters, you can refer to the following file to check how Media SDK check the parameters:

This file also shows some information about the parameter unit we checked.

The other way to find the conflict is to start from a set of parameters which works, so you can this set from the sample_encode when it works normal. Then you change it toward your expected values, you will find which one causes the problem.


0 Kudos