- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
OS : Windows 10
CPU : 11th Gen Intel(R) Core(TM) i7-11700
oneVPL MFXVideoENCODE_Init() -> return MFX_ERR_INVALID_VIDEO_PARAM
#####################################
# sample_code
#####################################
int main(int argc, char *argv[]) {
// Variables used for legacy and 2.x
bool isDraining = false;
bool isStillGoing = true;
bool isFailed = false;
FILE *sink = NULL;
FILE *source = NULL;
mfxBitstream bitstream = {};
mfxFrameSurface1 *encSurfaceIn = NULL;
mfxSession session = NULL;
mfxSyncPoint syncp = {};
mfxU32 framenum = 0;
mfxStatus sts = MFX_ERR_NONE;
mfxStatus sts_r = MFX_ERR_NONE;
Params cliParams = {};
mfxVideoParam encodeParams = {};
// variables used only in 2.x version
mfxConfig cfg[3];
mfxVariant cfgVal[3];
mfxLoader loader = NULL;
// Parse command line args to cliParams
if (ParseArgsAndValidate(argc, argv, &cliParams, PARAMS_ENCODE) == false) {
Usage();
return 1; // return 1 as error code
}
source = fopen(cliParams.infileName, "rb");
VERIFY(source, "Could not open input file");
sink = fopen(OUTPUT_FILE, "wb");
VERIFY(sink, "Could not create output file");
// Initialize VPL session
loader = MFXLoad();
VERIFY(NULL != loader, "MFXLoad failed -- is implementation in path?");
// Implementation used must be the type requested from command line
cfg[0] = MFXCreateConfig(loader);
VERIFY(NULL != cfg[0], "MFXCreateConfig failed")
sts =
MFXSetConfigFilterProperty(cfg[0], (mfxU8 *)"mfxImplDescription.Impl", cliParams.implValue);
VERIFY(MFX_ERR_NONE == sts, "MFXSetConfigFilterProperty failed for Impl");
// Implementation must provide an HEVC encoder
cfg[1] = MFXCreateConfig(loader);
VERIFY(NULL != cfg[1], "MFXCreateConfig failed")
cfgVal[1].Type = MFX_VARIANT_TYPE_U32;
cfgVal[1].Data.U32 = MFX_CODEC_AVC;
sts = MFXSetConfigFilterProperty(
cfg[1],
(mfxU8 *)"mfxImplDescription.mfxEncoderDescription.encoder.CodecID",
cfgVal[1]);
VERIFY(MFX_ERR_NONE == sts, "MFXSetConfigFilterProperty failed for encoder CodecID");
// Implementation used must provide API version 2.2 or newer
cfg[2] = MFXCreateConfig(loader);
VERIFY(NULL != cfg[2], "MFXCreateConfig failed")
cfgVal[2].Type = MFX_VARIANT_TYPE_U32;
cfgVal[2].Data.U32 = VPLVERSION(MAJOR_API_VERSION_REQUIRED, MINOR_API_VERSION_REQUIRED);
sts = MFXSetConfigFilterProperty(cfg[2],
(mfxU8 *)"mfxImplDescription.ApiVersion.Version",
cfgVal[2]);
VERIFY(MFX_ERR_NONE == sts, "MFXSetConfigFilterProperty failed for API version");
sts = MFXCreateSession(loader, 0, &session);
VERIFY(MFX_ERR_NONE == sts,
"Cannot create session -- no implementations meet selection criteria");
// Print info about implementation loaded
ShowImplementationInfo(loader, 0);
// Initialize encode parameters
encodeParams.mfx.CodecId = MFX_CODEC_AVC;
encodeParams.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
encodeParams.mfx.TargetKbps = TARGETKBPS;
encodeParams.mfx.RateControlMethod = MFX_RATECONTROL_VBR;
encodeParams.mfx.FrameInfo.FrameRateExtN = FRAMERATE;
encodeParams.mfx.FrameInfo.FrameRateExtD = 1;
if (MFX_IMPL_SOFTWARE == cliParams.impl) {
encodeParams.mfx.FrameInfo.FourCC = MFX_FOURCC_I420;
}
else {
encodeParams.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
}
encodeParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
encodeParams.mfx.FrameInfo.CropW = cliParams.srcWidth;
encodeParams.mfx.FrameInfo.CropH = cliParams.srcHeight;
encodeParams.mfx.FrameInfo.Width = ALIGN16(cliParams.srcWidth);
encodeParams.mfx.FrameInfo.Height = ALIGN16(cliParams.srcHeight);
encodeParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
// Initialize encoder
sts = MFXVideoENCODE_Init(session, &encodeParams);
VERIFY(MFX_ERR_NONE == sts, "Encode init failed");
}
#####################################
hello-encode.exe -sw -i input.h264 -w 320 -h 240
---> MFXVideoENCODE_Init return MFX_ERR_INVALID_VIDEO_PARAM
hello-encode.exe -hw -i input.h264 -w 320 -h 240
---> MFXVideoENCODE_Init return MFX_ERR_INVALID_VIDEO_PARAM
but, encode CODEC change MFX_CODEC_AVC -> MFX_CODEC_HEVC
hello-encode.exe -sw -i input.h264 -w 320 -h 240
Implementation details:
ApiVersion: 2.9
Implementation type: SW
AccelerationMode via: NA
DeviceID: 0000
Path: D:\oneVPL\oneVPL\examples\api2x\x64\Debug\libvplswref64.dll
---> MFXVideoENCODE_Init return MFX_ERR_NONE
hello-encode.exe -hw -i input.h264 -w 320 -h 240
Implementation details:
ApiVersion: 2.3
Implementation type: HW
AccelerationMode via: D3D11
DeviceID: 4c8a/0
Path: C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_e648bb2a2af8e9de\libmfx64-gen.dll
---> MFXVideoENCODE_Init return MFX_ERR_NONE
Why do I get MFX_ERR_INVALID_VIDEO_PARAM(-15) error when encoding with AVC codec?
Can't AVC video codec encode to AVC?
Thank you in advance for your reply.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for posting in Intel Communities.
The MFX_ERR_INVALID_VIDEO_PARAM error occurs only when incorrect video parameters are provided during encoder initialization. Based on the code you have provided, it seems that changes have been made to the code during the initialization of the encode parameters, which could be the reason for the error.
Please note that you cannot encode AVC to another AVC format. Currently, oneVPL has a sample hello-encode which encodes nv12/i420 video to a HEVC(h265) Video codec. Could you please let us know why you are encoding to AVC so that we can try to help you further?
Regards,
Thasneem Vazim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. Could you please give us an update?
Regards,
Thasneem Vazim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm sorry for late reply
We are encoding with AVC in our self-developed application.
Found the legacy sample_multi_transocde sample instead of the hello-transcode sample
Let's migrate by referring to this sample
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for the update.
Kindly let us know if we can stop monitoring this thread if there are no issues.
Regards
Thasneem Vazim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may close the case.
Thanks again for your help.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page