It depends on if you want to stream or if you want to record.
For recording, use a hardware encoder (nvenc, quicksync) with quality-based rate control (CQP, ICQ, CRF) and no bitrate-based rate control (everything with BR in it). Use a quality setting of about 18-21. This gives a quality almost indistinguishable from the original and has no CPU power demand.
For streaming, you have to use bitrate-based rate control (CBR), and here it depends on the power of your CPU. x264 has the best quality, but takes away much CPU. Hardware encoders like NVENC and Quicksync don't use CPU but produce less quality. We discussed that in
this thread. A table where you can compare yourself
is here.
My personal recommendation for streaming is in the middle of the first post of that thread. If you don't want to read, it could be simplified as: if you have the cpu power, so you can encode without lags and frame loss, use x264. Otherwise use nvenc. If you don't have nvenc, use Quicksync. Avoid amd-vce if you have Quicksync or nvenc available.