- 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 MFXVideoDECODE_DecodeFrameAsync() -> return MFX_ERR_NOT_INITIALIZED
#####################################
# sample_code
#####################################
int main(int argc, char *argv[]) {
bool isDrainingDec = false;
bool isDrainingEnc = false;
bool isStillgoing = true;
bool isFailed = false;
FILE *sink = NULL;
FILE *source = NULL;
mfxBitstream bs_dec_in = {};
mfxBitstream bs_enc_out = {};
mfxFrameSurface1 *dec_surface_out = NULL;
mfxSession session = NULL;
mfxStatus sts = MFX_ERR_NONE;
mfxStatus sts_r = MFX_ERR_NONE;
mfxSyncPoint syncp = {};
mfxU32 framenum = 0;
mfxVideoParam encodeParams = {};
mfxVideoParam stream_info = {};
Params cliParams = {};
// variables used only in 2.x version
mfxConfig cfg[4];
mfxVariant cfgVal[4];
mfxLoader loader = NULL;
mfxU8 timeout_count;
//Parse command line args to cliParams
if (ParseArgsAndValidate(argc, argv, &cliParams, PARAMS_DECODE) == false) {
Usage();
return 1; // return 1 as error code
}
/*
if (MFX_IMPL_TYPE_SOFTWARE != cliParams.implValue.Data.U32) {
printf("Only software implementation is supported\n");
return 1;
}
*/
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_HEVC;
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");
*/
// Implementation must provide a JPEG decoder
cfg[3] = MFXCreateConfig(loader);
VERIFY(NULL != cfg[3], "MFXCreateConfig failed")
cfgVal[3].Type = MFX_VARIANT_TYPE_U32;
cfgVal[3].Data.U32 = MFX_CODEC_AVC;
sts = MFXSetConfigFilterProperty(
cfg[3],
(mfxU8 *)"mfxImplDescription.mfxDecoderDescription.decoder.CodecID",
cfgVal[3]);
VERIFY(MFX_ERR_NONE == sts, "MFXSetConfigFilterProperty failed for decoder CodecID");
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);
// Initiate bs_dec_in for decode input stream and parse basic stream information (input width and height)
// in : session, source
// out: bs_dec_in, stream_info
// Prepare input bitstream and start decoding
bs_dec_in.MaxLength = BITSTREAM_BUFFER_SIZE;
bs_dec_in.Data = (mfxU8 *)calloc(bs_dec_in.MaxLength, sizeof(mfxU8));
VERIFY(bs_dec_in.Data, "Not able to allocate input buffer");
bs_dec_in.CodecId = MFX_CODEC_AVC;
//Pre-parse input stream
sts = ReadEncodedStream(bs_dec_in, source);
VERIFY(MFX_ERR_NONE == sts, "Error reading bitstream\n");
stream_info.mfx.CodecId = MFX_CODEC_AVC;
stream_info.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
sts = MFXVideoDECODE_DecodeHeader(session, &bs_dec_in, &stream_info);
VERIFY(MFX_ERR_NONE == sts, "Error decoding header\n");
// Prepare bitstream for encode output and encode params
// in : stream_info.mfx.FrameInfo.Width, stream_info.mfx.FrameInfo.Height
// out: bs_enc_out, encodeParams
bs_enc_out.MaxLength = BITSTREAM_BUFFER_SIZE;
bs_enc_out.Data = (mfxU8 *)calloc(bs_enc_out.MaxLength, sizeof(mfxU8));
VERIFY(bs_dec_in.Data, "Not able to allocate input buffer");
encodeParams.mfx.CodecId = MFX_CODEC_HEVC;
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;
//{
//encodeParams.mfx.FrameInfo.FourCC = stream_info.mfx.FrameInfo.FourCC;
//encodeParams.mfx.FrameInfo.ChromaFormat = stream_info.mfx.FrameInfo.ChromaFormat;
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 = stream_info.mfx.FrameInfo.Width;
encodeParams.mfx.FrameInfo.CropH = stream_info.mfx.FrameInfo.Height;
encodeParams.mfx.FrameInfo.Width = ALIGN16(encodeParams.mfx.FrameInfo.CropW);
encodeParams.mfx.FrameInfo.Height = ALIGN16(encodeParams.mfx.FrameInfo.CropH);
encodeParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
// Initialize the encoder
sts = MFXVideoENCODE_Init(session, &encodeParams);
VERIFY(MFX_ERR_NONE == sts, "Could not initialize Encode");
printf("Transcoding %s -> %s\n", cliParams.infileName, OUTPUT_FILE);
while (isStillgoing == true) {
sts = MFX_ERR_NONE;
// Read input stream for decode
if (isDrainingDec == false) {
sts = ReadEncodedStream(bs_dec_in, source);
if (sts != MFX_ERR_NONE) // No more data to read, start decode draining mode
isDrainingDec = true;
}
// Decode MJPEG stream
if (isDrainingEnc == false) {
timeout_count = 0;
do {
sts = MFXVideoDECODE_DecodeFrameAsync(session,
(isDrainingDec == true) ? NULL : &bs_dec_in,
NULL,
&dec_surface_out,
&syncp);
// From API version 2.5,
// When the internal memory model is used,
// MFX_WRN_ALLOC_TIMEOUT_EXPIRED is returned when all the surfaces are currently in use and timeout set by mfxExtAllocationHints for allocation of new surfaces through functions DecodeFrameAsync expired.
// Repeat the call in a few milliseconds.
// For more information, please check oneVPL API documentation.
if (sts == MFX_WRN_ALLOC_TIMEOUT_EXPIRED) {
if (timeout_count > MAX_TIMEOUT_COUNT) {
sts = MFX_ERR_DEVICE_FAILED;
break;
}
else {
timeout_count++;
sleep(WAIT_5_MILLISECONDS);
continue;
}
}
else
break;
} while (1);
}
}
}
#####################################
hello-transcode.exe -hw -i input.h264
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
Transcoding input.h264 -> out.h265
---> MFXVideoDECODE_DecodeFrameAsync return MFX_ERR_NOT_INITIALIZED(-8)
Why do I get MFX_ERR_NOT_INITIALIZED(-8) error when encoding with AVC/HEVC codec?
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.
We have observed that you made some changes in the code, and the "MFX_ERR_NOT_INITIALIZED" error occurs when the session is not correctly initialized. Currently, the hello-transcode sample in oneVPL focuses on converting a mjpeg video stream to h265 video format.
However, there is no existing sample that specifically addresses the transcoding of h264 to h265. Could you please try transcoding a mjpeg video file instead of an AVC video?
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
I will try transcoding a mjpeg video file instead of an AVC video
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