CRF fixes the quality target and leaves the size open; 2-pass fixes the size and leaves the quality open. CQ is a quality mode on hardware encoders and only sounds similar. Using this site's measurements, we see why CRF produces different sizes for different videos.
In the quantization lesson you learned CQP, CRF, and ABR as concepts. Here we sort out which to pick and when, alongside the numbers this site measured.
Option names and support for 2-pass differ by encoder. Before using it, check with ffmpeg -h encoder=encoder_name.
If there is no strict limit on file size, it is simpler to finish with a single CRF run. It spends fewer bits on easy scenes and more on hard ones by itself. But even the same CRF gives different results for different videos. In the Why the same CRF gives different results measurement on this site, the VMAF at x264 CRF 30 was as follows.
Source: the crf-by-content-v1 measurement article. There are only four clips, so these are not representative of all kinds of video.
With a limit like 'this file has to fit in 10 MB', CRF is hard to use, because you only learn the output size after encoding finishes. In that case you use 2-pass: you set a target bitrate, the first pass analyzes how hard the whole video is, and the second pass distributes bits using that information. It is known as a method used to hit an average bitrate more accurately.
# Pass 1: analyze only and discard the output (no audio)
ffmpeg -y -i input.mp4 -c:v libx264 -preset medium -b:v 2400k -pass 1 -an -f null /dev/null
# Pass 2: the actual encode using the analysis
ffmpeg -i input.mp4 -c:v libx264 -preset medium -b:v 2400k -pass 2 -c:a aac output.mp4You can get the bitrate value by entering the duration and target size into the video size and bitrate calculator. Just remember that fixing the size leaves the quality open. In the crf-sweep measurement, the bitrate at x264 CRF 28 was 2,490 kbps for blue_sky and 11,623 kbps for riverbed, a gap of about 4.7× (1080p25, 10 s clips). If both had to fit in 2.5 Mbps, that would be plenty for blue_sky but far too little for riverbed.
All of the measurement articles were run in CRF mode (this is also noted in the limitations of the preset-speed article). There are no numbers on this site for how much better 2-pass is than CRF at the same size, and we don't claim any here.
The -cq of a hardware encoder such as NVENC plays a role similar to CRF in that it is a mode that fixes quality, but the same number does not mean the same quality. You can't carry a software CRF value over to a hardware CQ as-is, and this site's measurements are for software encoders, so we can't estimate hardware results (why this site can't use hardware encoders).
No limit: CRF. With a limit: 2-pass (or try lowering CRF step by step within the limit). If you use a hardware encoder, the only way is to check the result on the same video yourself.
How much the size shrinks as you raise CRF is measured in the CRF step size measurement. On four 10-second clips, x264 and x265 shrank to 40–47% of the original size per CRF +6, so 'CRF +6 halves the size' held roughly true as an average over the whole range, but individual steps varied from 26% to 58%. SVT-AV1 and VP9, which use a 0–63 scale, kept about 57–67% for the same +6.
A mode that fixes the quality target and lets the size follow. The same value can give very different sizes depending on how hard the video is.
A method that analyzes the video in the first pass and uses that information in the second pass to distribute bits and hit a target bitrate.
The fixed-quality mode of a hardware encoder. Its numbers are not compatible with software CRF.
HandBrake's Constant Quality value (Rate Factor). For x264 and x265 it is known to be passed straight through as the encoder's CRF. To find the equal-VMAF value for another codec, use the tool 'HandBrake RF to FFmpeg CRF Conversion Chart'.
With the condition 'the output file must not exceed 10 MB', which rate control should you consider first?
In the crf-by-content measurement, the VMAF at the same x264 CRF 30 differed by clip, from 80.57 to 98.22. What conclusion can you draw?