I am encoding NV21 frames coming from camera preview. For some reason schema which is working fine on other devices works incorrectly on Sony Xperia Z1
Are you sure you pass timestamps in the right unit (microseconds) - and that it has set a sensible framerate?
Some encoders might ignore the timestamps and only set a fixed bitrate budget per frame, based on the framerate.
Others might try to calculate how many bits they're allowed to use per frame based on the timestamp.
If the timestamps are given e.g. in milliseconds instead, this could lead to the encoder reducing the size of encoded frames down towards zero.