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

Hardware AVC Encoding implementation configuration and usage

PhilippS1
Beginner
1,353 Views

Hi,

 

I am currently trying to use the oneVPL sdk to encode frames rendered in DX11 on Windows on discrete intel GPUs.

I adjusted hello-encode sample to use hardware encoding as far as I understand, but when calling MFXVideoENCODE_Query(...) with the configured parameters (see attached code) it always tells me that it is unsupported (at line 71). I used the vpl-inspect.exe to give me information on the available implmentation and I think that I have the right one installed (see capabilities.txt)

 

So my questions are:

* Do I have to many parameters configured? Where is the configuration no supported? How can I check that?

* Do I need to install some additional software on my machine for it to be picked up?

 

Thanks in advance!

  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", cfgImplementationQueryFilter);
  VERIFY(MFX_ERR_NONE == sts, "MFXSetConfigFilterProperty failed for Impl");

  // Implementation must provide an AVC encoder
  cfg[1] = MFXCreateConfig(loader_);
  VERIFY(NULL != cfg[1], "MFXCreateConfig failed")
  cfgVal[1].Type = MFX_VARIANT_TYPE_U32;
  cfgVal[1].Data.U32 = TARGET_ENCODING;
  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");

  allocatorParams_.bUseSingleTexture = true;
  allocatorParams_.uncompressedResourceMiscFlags = 0;
  allocatorParams_.pDevice = d3d_device_.Get();

  allocator_.Init(&allocatorParams_);

  MFXVideoCORE_SetFrameAllocator(session_, &allocator_);
  VERIFY(MFX_ERR_NONE == sts, "Setting external frame allocator failed");

  MFXVideoCORE_SetHandle(session_, MFX_HANDLE_D3D11_DEVICE, d3d_device_.Get());
  VERIFY(MFX_ERR_NONE == sts, "Passing d3d11_device handle to onevpl failed");

  // Print info about implementation loaded
  ShowImplementationInfo(loader_, 0);

  // Initialize encode parameters
  encodeParams.IOPattern =  MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; //See https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_hw.html
  // encodeParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
  encodeParams.mfx.CodecId = TARGET_ENCODING;
  encodeParams.mfx.CodecProfile = MFX_PROFILE_AVC_CONSTRAINED_BASELINE;

  encodeParams.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
  encodeParams.mfx.TargetKbps = max_bitrate_;
  encodeParams.mfx.RateControlMethod = MFX_RATECONTROL_VBR;
  encodeParams.mfx.FrameInfo.FrameRateExtN = frame_rate_;
  encodeParams.mfx.FrameInfo.FrameRateExtD = 1;
  encodeParams.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
  encodeParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
  encodeParams.mfx.FrameInfo.CropW = codec_settings->width;
  encodeParams.mfx.FrameInfo.CropH = codec_settings->height;
  encodeParams.mfx.FrameInfo.Width = ALIGN16(codec_settings->width);
  encodeParams.mfx.FrameInfo.Height = ALIGN16(codec_settings->height);

  mfxVideoParam outParams;
  sts = MFXVideoENCODE_Query(session_, &encodeParams, &outParams);
  VERIFY(MFX_ERR_NONE == sts, "Encode query failed");

  // Initialize encoder
  sts = MFXVideoENCODE_Init(session_, &outParams);
  VERIFY(MFX_ERR_NONE == sts, "Encode init failed");

  // Prepare output bitstream
  bitstream_.MaxLength = BITSTREAM_BUFFER_SIZE;
  bitstream_.Data = (mfxU8*)calloc(bitstream_.MaxLength, sizeof(mfxU8));

 

0 Kudos
5 Replies
Rahila_T_Intel
Employee
1,307 Views

Hi,

 

Thank you for posting in Intel Communities.

 

After observation in your code, It seems like you are trying to encode video to AVC. (is it what you are doing)?


The code snippet you have given is not a complete one, hence it is very difficult for us to interpret what exactly you are wanting to do.

Can you provide the sample reproducer to understand better?

 

Thanks


0 Kudos
PhilippS1
Beginner
1,285 Views

Hello,

 

thank you for answering!

 

I just saw that I said it fails on line 71, but it is actually 64 (this message should return MFX_NO_ERROR, but it returns MFX_NOT_SUPPORTED)

I only provided the sample for the initialization of the encoder because that is currently the only interesting part. In this part of the code it fails to find an appropriate encoder implementation on my system.

Also when trying to run the provided samples (legacy as well as the new ones) with

.\sample_encode.exe h264 -sw -i <input-file> -w 320 -h 240 -o test.h264
 
it fails with the following message (this is both for -sw & -hw)

 

PhilippS1_0-1681741482520.png

 

 

 

0 Kudos
Rahila_T_Intel
Employee
1,254 Views

Hi,

 


Please find the Encode Features for Intel® Discrete Graphics available from the below link. 

https://www.intel.com/content/www/us/en/docs/onevpl/developer-reference-media-intel-hardware/1-1/features-and-formats.html#ENCODE-DISCRETE

 

Also find the oneVPL Dispatcher behavior when targeting Intel GPUs below:

https://github.com/oneapi-src/oneVPL#onevpl-dispatcher-behavior-when-targeting-intel-gpus

 

You can refer the below GitHub link to know the details about the Intel® oneVPL GPU and its supported hardware platforms, Supported video encoders, dependencies...etc.

https://github.com/oneapi-src/oneVPL-intel-gpu

 


Could you please provide us the answers to our below doubts so that we can debug your issue further?

1. Details about your application you attached. 

2. Sample Reproducer i.e. the code which you've written and all the command to compile and analyze.

3. Are you able to run the original hello_encode sample which comes with oneVPL, in your system without any issues?

4. Can you share your the details of OS, Processor and oneVPL GPU Runtime version.


Thanks


0 Kudos
Rahila_T_Intel
Employee
1,198 Views


Hi,


We haven't heard back from you. Could you please give us an update?


Thanks



0 Kudos
Rahila_T_Intel
Employee
1,147 Views

Hi,


We have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.


Thanks


0 Kudos
Reply