How to specify encoder sps parameters? bitstream_restriction_flag = 1

How to specify parameters in the encoder so that the bitstream_restriction_flag parameter in the SPS of the encoded video in H.264 is set to 1?

You can add vui->bitstreamRestrictionFlag = 1;

See #11131 (Nvenc b_ref_mode middle does not write max_num_reorder_frames == 2 in SPS) – FFmpeg

This is now fixed in ffmpeg. that is way you do it
avcodec/nvenc: set bitstreamRestrictionFlag when neccesary · FFmpeg/FFmpeg@d724584 · GitHub

Can you verify that now ffnpeg writes all values in that structure correctly? Looks like it writes max_num_reorder_frames 2 for b_ref_mode each, while it should be max_num_reorder_frames 1?