When the h264 encoder generates a keyframe, it is observed that the "nal_ref_idc" field is 0 for all nal's of that frame. Also for the IDR NAL. Somehow this is not giving issues when streaming via rtsp, but when recording it as transport stream (.ts) files the video is unbearable to watch due to missing reference picture.
Now I have to manually set the "nal_ref_idc" field when the encoding is done. Please adjust the encoder to comply to the standard.
According to the standard: