View Full Version : ffmpeg libx264 '-crf' vs. '-qp' vs. q=nn.n
fvisagie
8th December 2012, 08:03
To brush up on ffmpeg H.264 encoding I've been reading the FFmpeg and x264 Encoding Guide (http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide). One issue there isn't quite clear to me and so far there hasn't been any explanation on the ffmpeg users' list. I'll be very grateful for your knowledge.
The guide refers to the –crf and –qp options but neither is explained in ffmpeg documentation. What is their relationship to each other and when is it advisable to use which? How do these two relate to the q=nn.n printed after encodes?
Many thanks,
Francois
J_Darnley
8th December 2012, 11:05
Do not use qp. Use crf which is, as far as the newbie is concerned, constant quality. The q value printed by ffmpeg is the "average" quantiser over the whole video.
fvisagie
10th December 2012, 06:43
That seemed to be the case; thanks for confirming, James.
Where can I read up the non-newbie stuff about relationship/s between crf, qp and quantizer? Or do you have an explanation handy?
Warperus
10th December 2012, 16:15
Quantizer is a general name for different quantization parameters. Generally it means qp for h.264, but for mpeg-4 asp or mpeg-2 it has another meaning (there is different mathematics behind the scene).
Some non-newbie explanation of qp in h.264:
http://www.vcodex.com/files/H264_4x4_transform_whitepaper_Nov10.pdf
For x264 qp coding means that it uses exactly same qp for every macroblock (depending on frame type). On the other side qp in reports for other "modes" is is some sort of average among frame macroblocks.
Features like adaptive quantization and mb-tree change qp on macroblock level depending on picture qualities and similarities (it's not compatible with fixed qp). Crf selects qp according to amount of motion in frame, but it can tuned by other features.
Unfortunately, crf to qp equation is not available. The general idea for crf is to provide visual quality about the same as qp with the same value, but it's not accurate equation. Even developers of x264 can't clearly state what qp will be chosen for particular crf - it severly depends on source and other settings.
fvisagie
11th December 2012, 07:46
Perfect! I have some familiarity with most of the concepts, so it's mostly a matter of understanding if/how they apply to H.264/x264. Many thanks.
fvisagie
12th December 2012, 14:49
I also found this helpful x264 settings documentation (which includes a summary of ratecontrol mechanisms):
mewiki.project357.com/wiki/X264_Settings
And
A qualitative overview of x264's ratecontrol methods (http://git.videolan.org/?p=x264.git;a=blob_plain;f=doc/ratecontrol.txt;hb=HEAD)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.