What video codecs can provide "adaptive quality"?
You're on the right track with -crf and x264 (the best H.264 encoder), and it should provide the "quality threshold" that you're looking for. CRF is recommended if you want a certain output quality and output file size is of less importance. Conversely, performing a two-pass encode with -b:v is recommend if you are targeting a specific output file size and quality is of less importance.

Encoding HEVC/H.265 with x265 should follow the same basic guidelines. You'll generally get better compression in exchange for a longer encoding time.

1. Choose a preset

A preset is a collection of options that will provide a certain encoding speed:compression ratio. A slower preset will provide better compression (compression is quality per filesize). General usage is to use the slowest preset that you have patience for. Current presets in descending order of speed are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Ignore placebo as it is a joke and a waste of time (it helps at most ~1%). If it's encoding too slowly then use a faster preset.

2. Choose a CRF value

The range for x264 is 0-51 where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality. A subjectively sane range is 18-28. Consider ~18 to be visually lossless: it should look the same as the input but it isn't technically lossless. Increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate.

General usage is to choose the highest -crf value that still provides an acceptable quality. That is if the output looks good then try a higher value and if it looks bad then choose a lower value.

3. Encode

Use these settings for the rest of your videos. They should all end up with the same quality.

Example

ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv


Also see


FFmpeg Wiki: H.264
FFmpeg Wiki: H.265