Encode with h264_nvenc and -preset p5
Encode H.264 on an NVIDIA GPU with h264_nvenc, using -preset p5, -tune hq and a constant-quality -cq value, on FFmpeg 4.4 or later.
The NVENC encoder replaced its old preset names (slow, hq, llhq and the rest) with seven levels, p1 to p7, in FFmpeg 4.4. p1 is the fastest and lowest quality, p7 is the slowest and best, and p5 is a sensible place to start when quality matters more than speed.
ffmpeg -i in.mp4 -c:v h264_nvenc -preset p5 -tune hq \
-rc vbr -cq 23 -b:v 0 -profile:v high -c:a copy out.mp4
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile -of default=nw=1 out.mp4codec_name=h264
profile=HighNVENC has no -crf. The nearest equivalent is -rc vbr -cq 23 with -b:v 0, which asks for constant quality with no bitrate cap. Without -b:v 0 the encoder keeps its default bitrate target and -cq only bends it. The -profile:v high matters because the encoder's default profile is main, which drops features that most players handle.
Do not expect -cq 23 to look like -crf 23 from libx264: the scales differ, so judge a few values by eye. Run ffmpeg -h encoder=h264_nvenc to list the options your build and driver accept. The NVENC notes on the FFmpeg wiki cover driver requirements.