ffmpeg

What's the difference with crf and qp in ffmpeg?


I read https://trac.ffmpeg.org/wiki/Encode/H.264 about h264 encoding and discovered qp.

Q1: What are the differences with crf and qp?
Q2: Is it better to use qp over crf overall, or is it only if for using qp 0 for best lossless?
Q3: Does qp have a known sensible setting if it's preferred? So far, I know crf has the default value of 23 while 18 is a sensible preferred increase in quality, although I don't understand why 18 wouldn't be default if better sensible lossless.
Q4: Would changing either of them cause incompatibility with non-ffmpeg players or just qp?

I'm converting from webm to mp4.

I was going to test crf 23 and 18 and pick which is best but I can't seem to find any concrete information on this comparison or about qp.


Solution

  • When you set the quantization parameter QP directly it remains constant throughout the encoding and each frame will be compressed based on the set value.

    Constant rate factor CRF allows the QP to go up for frames with a lot of motion or down for still frames resulting in a consistent perceived quality while keeping the compression efficient.

    This article explains it very well.

    The CRF default is just a default, you need to pick a value adapted for your type of video. FFmpeg has filters like PSNR and SSIM which allow you to compare the results.