We are integrating VCE that in MediaSDK 1.1 beta, the one based on AMFCreateComponent API.
Here is my code to create encoder (according with simpleEncode sample code):
|AMF_ERROR( AMFCreateComponent(m_pContext, AMFVideoEncoderVCE_AVC, &m_pEncoder) );|
|// Usage is preset that will set many parameters|
|AMF_ERROR( PushParamsToPropertyStorage(¶ms, ParamEncoderUsage, m_pEncoder) );|
|// override some usage parameters|
|AMF_ERROR( PushParamsToPropertyStorage(¶ms, ParamEncoderStatic, m_pEncoder) );|
|AMF_ERROR( m_pEncoder->Init(amf::AMF_SURFACE_NV12, pParams->width, pParams->height) );|
|AMF_ERROR( PushParamsToPropertyStorage(¶ms, ParamEncoderDynamic, m_pEncoder) );|
and then I make following call to get SPS/PPS headers:
|AMF_ERROR( m_pEncoder->GetProperty(AMF_VIDEO_ENCODER_EXTRADATA, &extradata) );|
But received SPS/PPS is wrong. So resulting mp4 file can not be played by Windows Media Player. But first frame contains proper SPS/PPS. I tried to use hex editor and change mp4 headers with SPS/PPS from first frame and Windows Media Player plays this file fine. Can you please guide me what I did wrong?
Next I will try to do is to apply ParamEncoderDynamic parameters before m_pEncoder->Init call (just swap these lines). But the above code is from sample in media SDK. And I even tried to set parameters according with config file and do not set any parameter at all (just use all default) - same result. But I do not think this will help. Seems there some bug in encoder.
We can also work around this - by encoding 1 frame, read result, get SPS/PPS and reinitialize encoder. But we looking for proper solution.