How I addressed this was to add a USB flash drive to my machine and set the recording path to that drive.
Read on for the details:
I have a fairly high end but older system that I added a 6TB drive into. I also have a NVidia 2060 super with video encoding. So CPU and encoding was not the issue.
I was trying to record a few things that were over 5 minutes long for a class but kept experiencing video freezes in my recordings. I followed the advice on changing priorities and running as administrator as well as lowing the quality but to no avail. Still saw the video freezing in the middle for a few seconds.
I guessed that the problem might be the system blocking writes to my hard drive, so I plugged in an USB drive and set the path to write to that drive. I have had success multiple times in a row with no stutter or video freezing.
I believe the trick is to save your recording to a drive that is not the same one on which you are running your OS.
Give this a try and if it works for you leave some positive feedback so others will know if they should also try it.