Quantcast
Channel: Intel® Software - Media
Viewing all articles
Browse latest Browse all 2185

Intel h.264 encoder gives invalid first frame

$
0
0

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?

 


Viewing all articles
Browse latest Browse all 2185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>