If you want absolute control, you can override internal x264 parameters using x264-params or x264opts .
A "Spiral" or highly optimized x264 setup leverages advanced features to balance visual fidelity with bitstream size: spiral x264
If you have a specific file size in mind, you must use Two-Pass Encoding (calculating bitrate), not CRF. For everything else, use CRF. If you want absolute control, you can override