Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th March 2007, 06:14   #1  |  Link
ArtDen
Registered User
 
Join Date: Mar 2007
Location: Russia
Posts: 9
x264: Constant quality vs constant file size

What case would be better for best quality of the resulting video if I want to encode 2-hour average dynamic 720x384 film into 700-1000 Mb file? Is there difference in quality of two equal sized files which are encoded whith CQ and CFS?

PS: all quality options are setted to maximum. CFS method works with 2-passes of course.
ArtDen is offline   Reply With Quote
Old 16th March 2007, 08:15   #2  |  Link
check
phjbdpcrjlj2sb3h
 
check's Avatar
 
Join Date: Sep 2005
Location: Western Australia
Posts: 1,691
2pass gives superior output to a identically sized 1pass output.
check is offline   Reply With Quote
Old 16th March 2007, 08:22   #3  |  Link
TechMage89
Contemporary Anachronism
 
TechMage89's Avatar
 
Join Date: Mar 2005
Posts: 11
If you are storing it on the hard drive (or any other medium with high transfer speeds) and don't need predictable file size, CQ is what most people prefer.

CQ doesn't choke on high-motion, high-detail sequences (it just increases the bitrate for that sequence), so nitpickers can't complain that the fast-motion scenes are very blocky (or blurry). On the whole, CQ provides a consistent level of quality across the video, which many people find more natural-looking.

The main drawback to CQ is that both the overall file size and the maximum bitrate are unpredictable, so it doesn't work well on any storage medium slower than about 30% of the uncompressed bitrate (because, depending on settings the bitrate could get that high (it could be higher, but it would not be worth it))

@check: that's only true if you are using average bit rate (abr) CQ is different entirely.

Last edited by TechMage89; 16th March 2007 at 08:27.
TechMage89 is offline   Reply With Quote
Old 16th March 2007, 08:55   #4  |  Link
ArtDen
Registered User
 
Join Date: Mar 2007
Location: Russia
Posts: 9
Is your assertions "CFS is better than CQ" confirmed by real testing of these modes (with comparing PSNR value for example) or it's only private opinion?
ArtDen is offline   Reply With Quote
Old 16th March 2007, 10:03   #5  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
"Better" is too ambiguous to ask for proof of. But based on the human psychovisual system, average brightness still scenes are by far the most important, and fast-moving scenes can suffer quite a bit of damage before it becomes obvious. All two-pass systems exploit this, as does x264's crf mode. Single-pass bitrate can only approximate it with its imperfect information. That's why crf is generally superior to cq unless you really need superb high-motion quality (screenshots, huge hdtv, whatever).

Better considering psnr and ssim, usually not, unless you also weight them for motion/brightness/etc. But it's also usually small enough that it's not statistically significant; psnr differences aren't usually visually reliable unless they're more than 2dB.

Last edited by foxyshadis; 16th March 2007 at 10:05.
foxyshadis is offline   Reply With Quote
Old 16th March 2007, 10:56   #6  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Quote:
All two-pass systems exploit this
No. x264 uses only the complexity of the scene, without any nothing of luminosity or motion. It will raise the quantizer on complex scenes, lower it on simple ones. That is mostly done for coding efficiency purposes ( ie, PSNR at a given filesize ) : Raising the quantizer on a complex scene allows to lower it on a lot of simple scenes.

Since complex scenes tends to hide artifacts better than simple scenes, the side effect is that visually the quality does seem to be somehow constant with CRF.

CRF is more efficient than CQP only if you consider the final size.
__________________
Manao is offline   Reply With Quote
Old 16th March 2007, 11:13   #7  |  Link
DocAliG
MPEG Member
 
Join Date: Oct 2006
Posts: 39
Quote:
Originally Posted by Manao View Post
No. x264 uses only the complexity of the scene, without any nothing of luminosity or motion.

Mmmmh.That might be somehow interesting to consider those parameters as well.... Regarding the human visual system.....
DocAliG is offline   Reply With Quote
Old 16th March 2007, 11:50   #8  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Quote:
Originally Posted by Manao View Post
No. x264 uses only the complexity of the scene, without any nothing of luminosity or motion. It will raise the quantizer on complex scenes, lower it on simple ones. That is mostly done for coding efficiency purposes ( ie, PSNR at a given filesize ) : Raising the quantizer on a complex scene allows to lower it on a lot of simple scenes.
Of course, that's exactly what I meant, in another way. 2-pass is visually better for most people than cq at a given file size because it allows higher quality in the frames they'll be able see more detail in, even though the codec only thinks in terms of complex and simple frames. (If people could take in every frame equally, no matter how fast it flashed by, it would be a bad tradeoff for the codec to make no matter how much it saved; that's why I brought up hvs. It's the ultimate underpinnings of what the codecs do.) There are exceptions, like an unstable camera panning over a field, that'll be considered complex and get a raised quant even though to the eye there's not much going on, but in movies the correlation usually holds. And of course exceptions because some people have amazing eyes or use it for more than just watching at normal speed.

I only mentioned brightness because I was talking about human vision, even though it's AQ that exploits that (among other things) and not the svn x264. Or rather, it's mostly xvid's AQ and kopernicus's patch. =p

Last edited by foxyshadis; 16th March 2007 at 11:52.
foxyshadis is offline   Reply With Quote
Old 16th March 2007, 20:39   #9  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,392
Quote:
Originally Posted by Manao View Post
CRF is more efficient than CQP only if you consider the final size.
You *always* consider the final size. Because if size didn't matter, you wouldn't be compressing it. And how else would you define efficiency, anyway?

Last edited by akupenguin; 16th March 2007 at 21:04.
akupenguin is offline   Reply With Quote
Old 17th March 2007, 07:55   #10  |  Link
ArtDen
Registered User
 
Join Date: Mar 2007
Location: Russia
Posts: 9
Yes, 2-pass better than constant quality. I tested two files PSNR and was surprised: 2-pass gives better quality (slightly larger PSNR and slightly more details on screen with 4x zoom). But it advantage is very small with quality=25 and nearly insignificant with quality=21. Also SSIM test shows identical values for both method. So if file size doesn't matter, constant quality is quite usable.

Last edited by ArtDen; 17th March 2007 at 08:16.
ArtDen is offline   Reply With Quote
Old 23rd March 2007, 17:37   #11  |  Link
delacroixp
Emperor building empire
 
delacroixp's Avatar
 
Join Date: Mar 2007
Location: ZAR
Posts: 674
How does Constant Quality 'really' work ???

I've been using AutoMKV with the H264 (=> MKV container) ConstantQuality-CRF profile.

I used AVInaptic on an episode of 'Band of Brothers' with the following Results ... which would indicate that although I used Q23... the Average Quantizer was 25.5 with a swing between Q10 and Q34... how wierd is that ???

Quote:
IEEE Xplore

PSNR control for GOP-level constant quality in H.264 video coding
De Vito, F.; De Martin, J.C.
Signal Processing and Information Technology, 2005. Proceedings of the Fifth IEEE International Symposium on
Volume , Issue , 18-21 Dec. 2005 Page(s): 612 - 617
Digital Object Identifier 10.1109/ISSPIT.2005.1577167

Summary: For some multimedia applications, like storage or surveillance, it may be desirable to encode the content at constant quality level; the encoder should be aware of media content and set suitable parameters. In this work, we analyze the case of video. We propose an algorithm to adapt the quantization, to obtain constant PSNR. This algorithm selects each frame's quantizer level by comparison with the average of PSNR over N preceding frames, and modifying the quantizer accordingly. This system proved to obtain the target average with a variance in the order of 0.3 in most of the cases. Furthermore, the application may require a per-GOP constant PSNR, like in semantic-based video coding. To obtain this effect, we propose a method to track a given PSNR pattern. The proposed algorithm is able to achieve the target PSNR for each single shot, with a convergence time of only few frames after shot boundary.
According to this article on IEEE Explore a modified Quantizer Strategy is desirable...

What gives... I want a real quantizer... all the profiles (Sharktooth, etc... seam to support Variable Quantizer settings).



Pascal
delacroixp is offline   Reply With Quote
Old 23rd March 2007, 20:06   #12  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
Why don't you do a constant quantizer encode then?
nurbs is offline   Reply With Quote
Old 23rd March 2007, 21:11   #13  |  Link
weaver4
Registered User
 
Join Date: Jun 2005
Posts: 925
The problem with two-pass with a set filesize is that you have to set the filesize. You are much more likely to pick a filesize that is too small or too big. For example you might have a movie that 1hr 30 minutes long so you decide 900k might be the right value (0.21 bits per pixel). Well half the time that will be OK and half the time it will be not good enough. But if you pick a constant quality value and then encode you don't need to guess.

I guess you could encode once in CQ to get a filesize and then do a two pass encode to the same filesize and then if you look really, really, really hard you might see a difference between the two pass and single pass.

So IMHO you are much more likely to get a "poor quality" movie by picking a filesize on your own than running CQ.

Last edited by weaver4; 23rd March 2007 at 21:36.
weaver4 is offline   Reply With Quote
Old 23rd March 2007, 21:46   #14  |  Link
weaver4
Registered User
 
Join Date: Jun 2005
Posts: 925
Quote:
We propose an algorithm to adapt the quantization, to obtain constant PSNR. This algorithm selects each frame's quantizer level by comparison with the average of PSNR over N preceding frames, and modifying the quantizer accordingly.
Somebody correct me if I am wrong, but I don't see that working very well where scenes go from inactive to very active in a single frame. Like: two men are talking and then a bomb goes off with fire, wood, bricks and body parts flying everywhere.
weaver4 is offline   Reply With Quote
Old 23rd March 2007, 22:03   #15  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
so crf in x264 is basically constant psnr? or...?
smok3 is offline   Reply With Quote
Old 23rd March 2007, 22:28   #16  |  Link
buzzqw
HDConvertToX author
 
Join Date: Nov 2003
Location: Cesena,Italy
Posts: 6,552
a simply but effective definition by check http://forum.doom9.org/showthread.php?p=881943

BHH
__________________
HDConvertToX: your tool for BD backup
MultiX264: The quick gui for x264
AutoMen: The Mencoder GUI
AutoWebM: supporting WebM/VP8
buzzqw is offline   Reply With Quote
Old 24th March 2007, 05:17   #17  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,392
You don't want constant PSNR. I can't think of any application where it would be desirable.

Ratecontrol targets can be order on a scale of constant bitrate to constant PSNR, as follows. The visually optimal mode is somewhere in the middle, and is definitely not below CQP. Of course, these are not the only possible modes, there's a whole continuum of others in between, as well as different algorithms to implement these targets.

CBR
ABR
CRF/2pass
CQP
CPSNR

(CRF and 2pass are at the same point on the CBR-to-CPSNR continuum, because they have the same target bitrate distribution. 2pass just ends up slightly closer to that target.)

Last edited by akupenguin; 24th March 2007 at 05:28.
akupenguin is offline   Reply With Quote
Old 24th March 2007, 21:24   #18  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
ok, so CRF is 'simply' like 1pass ABR with no bitrate limits?
smok3 is offline   Reply With Quote
Old 25th March 2007, 13:34   #19  |  Link
delacroixp
Emperor building empire
 
delacroixp's Avatar
 
Join Date: Mar 2007
Location: ZAR
Posts: 674
@nurbs

Quote:
Originally Posted by nurbs View Post
Why don't you do a constant quantizer encode then?
I guess you're right... eventhough check gives a beautifull description with the advantages of CRF on megui/x264 ABR question.
However, I think there are very real concerns about CQ-CRF as pointed out by weaver4 above and omion x264 constant quality first pass back in 2005.

I suppose, like all encoding... there is no single solution and only by becoming more expert will we get closer to the Holy Grail of Encoding.



Pascal
delacroixp is offline   Reply With Quote
Old 25th March 2007, 19:18   #20  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,392
Quote:
Originally Posted by delacroixp View Post
However, I think there are very real concerns about CQ-CRF as pointed out by weaver4 above and omion x264 constant quality first pass back in 2005.
I don't see any concerns about CRF... omion only posted concerns about CQP, which were answered by implementing CRF. weaver4 posted concerns about CQP and 2pass, for which his solution was to use CRF. What's not to like about CRF?
akupenguin is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.