In ffmpeg, -qp 0 will get you lossless x264. I use it all the time (via OBS) to losslessly record my screen.