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.

Intel h.264 encoder gives invalid first frame

Wayne_S_
Beginner
518 Views

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 7.16.8.4, 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 ) );
   }
   else
   {
      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
Anna_B_Intel
Employee
518 Views

Hi Wayne, 

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

Best wishes,

Anna

0 Kudos
Wayne_S_
Beginner
518 Views

Anna,

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?

Wayne

0 Kudos
Reply