Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ffmpeg

After browsing around Google, I've came across this page about h264 encoding and discovered about qp. https://trac.ffmpeg.org/wiki/Encode/H.264

My questions are: What are the differences with crf and qp? Is it better to use qp over crf overall, or is it only if for using qp 0 for best lossless? 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. Lastly, would changing either of them cause incompatibility with non-ffmpeg players or just qp?

I'm converting from webm to mp4 by the way.

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.

like image 877
Nova Avatar asked Nov 18 '16 02:11

Nova


People also ask

What does CRF do Ffmpeg?

The Constant Rate Factor or CRF is an option available in the libx264 encoder to set our desired output quality. It enables us to specify a target value that maps to a specific quality by adjusting the bitrates automatically based on the input video.

Is CRF the same as Cqp?

Similar to how CQP gives you a range of 0 to 30, with the lower numbers being better quality, CRF ranges from 0 to 51, with around 17 to 24 being considered 'good quality'. Approximately every 6 points will double your file size, and as you can imagine, subtracting 6 will halve it.

What is the best CRF for video?

VMAF 93 = Good Enough So, if you're using CRF 20, you're almost certainly delivering a VMAF quality that's higher than 93-95 (since lower CRF values deliver higher quality). This means that the data rate on all videos that you distribute is likely too high, or at least higher than it needs to be.

What is CRF and bitrate?

– Bitrate variability. – Cost (2 or more passes) – Most other VOD. CRF. – Adjusts data rate to achieve quality.


Video Answer


2 Answers

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.

like image 78
aergistal Avatar answered Sep 27 '22 22:09

aergistal


Just for the record, -qp is supported by both livx264 and h264_nvenc codecs (CUDA-backed coded).

CUDA ignores -crf, which took me forever to notice.

like image 41
Michał Leon Avatar answered Sep 27 '22 22:09

Michał Leon