Sorry for the delayed response.
The way the encoder is created and initialized is correct.
Coming to your observations, firstly AMF Encoder will only generate elementary stream. It does not generate any container format. So to understand, are you wrapping the output from the encoder into mp4 file?
Secondly, dynamic encoder parameters can only be applied once the encoder is intialized. Not earlier to it.
Could you help us with the following:
Confirm that the encoded elementary stream is correct? You could test this using standard tools to play elementary H.264 streams such as Elecard.
Bitstream is correct, we record mp4 and can play it. But SPS/PPS from AMF_VIDEO_ENCODER_EXTRADATA and from first frame was different. So we made SPS/PPS probe - submit 1 black frame, flush, extract SPS/PPS from output, then reinitialize encoder and start using it. No more issues after that work around. But now I think this issue can be related to another recently reported issue AMF VCE - Wrong encoding bitrate (fps). This maybe makes sense to retest AMF_VIDEO_ENCODER_EXTRADATA.
Personally I think this makes good sense to support unified parameters input. It is because developers need to remember Variant type for every parameter and apply every parameter in proper way. And if AMD change some type later this may make many issues. For example, x264 have following function:
int x264_param_parse(x264_param_t *param, const char *name, const char *value);
So you can apply every parameter as string and don't care about it's type. So I added converters for all parameters that doesn't have converter assigned and I can submit string value for any parameter and encoder works properly now.
The developers tell me that the AMF Media SDK (avl. under NDA) contains a fix for this problem.