Media (Intel® oneAPI Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools from Intel. This includes Intel® oneAPI Video Processing Library and Intel® Media SDK.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Intel h.264 encoder gives invalid first frame


I am trying to use the Intel Quick-Sync Hardware Encoder via its Media Foundation IMFTransform interface.  (Either mfx_mft_h264ve_32.dll or mfx_mft_h264ve_64.dll, file version, product version 7.0.1540.4116.)

Input video subtype is MFVideoFormat_NV12.

Output video subtype is MFVideoFormat_H264.

I am running on Windows 10.

The problem I am seeing is that the first frame of compressed video appears to be invalid.  It is a key frame, but its size is less than 1/2 the size of subsequent key frames.  The compressed frames seem fine after the second key frame (about 4 or 5 seconds in).

I assume I must be doing something wrong in the setup.  Here is a code snippet:

   verifyHrOrReturn( CoCreateInstance( CLSID_MF_INTEL_H264EncFilter, NULL,
                               CLSCTX_INPROC_SERVER, IID_PPV_ARGS( &m_pVideoMFT ) ) );

   // Is the Encoder async
   UINT32 nIsAsync = 0;
   verifyHrOrReturn( m_pVideoMFT->GetAttributes( &pAttributes ) );
   verifyHrOrReturn( pAttributes->GetUINT32( MF_TRANSFORM_ASYNC, &nIsAsync ) );

   // The Intel Encoder should be async
   assert( nIsAsync != 0 );

   if ( nIsAsync )
      verifyHrOrReturn( pAttributes->SetUINT32( MF_TRANSFORM_ASYNC_UNLOCK, TRUE ) );
      return E_FAIL;

   verifyHrOrReturn( m_pVideoMFT->SetOutputType( 0, m_pOutputType, 0 ) );
   verifyHrOrReturn( m_pVideoMFT->SetInputType( 0, m_pInputType, 0 ) );

   verifyHrOrReturn( m_pVideoMFT->ProcessMessage( MFT_MESSAGE_COMMAND_FLUSH, NULL ) );
   verifyHrOrReturn( m_pVideoMFT->ProcessMessage( MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL ) );

On its ICodecAPI interface, I set the rate control mode to eAVEncCommonRateControlMode_Quality and the quality setting to 75.

Then I send it a MFT_MESSAGE_NOTIFY_START_OF_STREAM message and call BeginGetEvent on its IMFMediaEventGenerator interface.

Is there something I am missing here?


0 Kudos
2 Replies

Hi Wayne, 

Could you please share input .yuv and encoded stream files?

Best wishes,




Thanks for the reply.  I apologize for being so slow to respond.  I have been on vacation for the past week.

I am not exactly sure what you are asking for.  I did a brief recording and put the results here.  There are a bunch of files in this folder:

EncodedVideoStream.mp4 is the compressed video file that used the Intel Quick-Sync Hardware Encoder to encode as h264.

FileCompressionTrace.txt is a trace file that records the media type for the video samples as well as the compressed sample sizes.

RawVideoFrame_0 - RawVideoFrame_163 are simply binary files of the raw frames (NV12 colorspace).

Does this give you the information you need to help me diagnose the problem?