The primary issue you're facing is that there is not enough space in the bit stream buffer. Please increase the size to about 5MB and try again. You can also get an estimate of the requried size by calling GetVideoParam on the encoder and look at the mfx.BufferSizeInKB parameter.
Besides this, there are many somewhat strange parameter vales used in your code, such as the values selected as frame rate and target bit rate. I recommend exploring if these are the actual values you want to use?
Also, I would highly suggest performing a mem zero on the allocated parameter structures and bit stream.
Additionally, you will likely get varning MFX_WRN_INCOMPATIBLE_VIDEO_PARAMS when calling encoder init since the rate control value has not been set. Encoder will select a valid value for you, but this is probably not what you want?
The Media SDK encode sample has more details on how to setup an encode pipeline.