Help - Search - Members - Calendar
Full Version: 2-pass encoding vs. constant quality
Hydrogenaudio Forums > Digital Audio/Video > General A/V
Continuum
Are there any advantages of using 2-pass encoding compared to constant quality/quantizer, except using a target filesize? If this is not an issue for me, am I better off using 1-pass, quality- and speedwise?

I read somewhere that the target of 2-pass encoding is to use a quantizer as constant as possible, is that true? unsure.gif
If yes, why do so many people claim that 2-pass is inherently better?
fccHandler
QUOTE (Continuum @ Dec 3 2003, 06:27 AM)
I read somewhere that the target of 2-pass encoding is to use a quantizer as constant as possible, is that true? unsure.gif

Not exactly. My understanding is that 2-pass will try to use higher quantizers where it thinks you won't notice it, and lower quantizers where it thinks they are needed. There is some "artificial intelligence" involved, while 1-pass quantizer blindly applies the same quantizer to every frame. According to this theory, a 2-pass encode which targets the same filesize as your previous 1-pass encode should look slightly better.
Continuum
Wouldn't it be possible to use this "intelligence" for a one pass encoding as well? If, for example, it is analyzing the movement of the scene, it could do so as well in a 1-pass scenario. Or is there really so much more behind it?
fccHandler
I don't know, but there'd better be more behind it (given that it takes twice as long to do!) tongue.gif

Honestly, I tend to use 1-pass quantizer for most things anyway because I'm too impatient. I only go with 2-pass when I absolutely need a file to be a specific size.
kl33per
A 2-pass encode at the same filesize as 1-pass fixed quantizer encode will (should in theory) always look better. I would only recomend 1-pass quntizer based encodings at the lowest quantizer availble and only then for transcoding to another format. Otherwise 2-pass is the way to go.

1-pass enocdes can be made to conform to a certain filesize or bitrate using guesstimation. This is because when analizing a scene for motion in a 1-pass encode you don't know the complexity of the motion to come. Therefore if you use to much bitrate in the first half of the film, but the second half was more complex, the second half will look terrible. Let me relate it to audio codecs.

All VBR audio codecs (IIRC) try to encode to a specific SNR. This is like 1-pass quantizer based video encodes that compress the film by a set ratio. 2-pass or nth-pass encodes of video don't aim for a set quality but for a set bitrate of filesize. Because they're 2-pass they can better estimate where the bitrate is needed because they no which parts of the movie are complex and which are not.

Hope this all makes sense.
fccHandler
Great explanation. And it brings to mind a question (slightly OT) which I've been wondering about for some time. Why doesn't LAME have a 2-pass mode? Similar to the theory with 2-pass video, one would expect 2-pass audio to give the best quality for a given file size...
kl33per
Indeed a two pass mode for audio codecs would be able to accurately dictate a filesize or bitrate but who wants to with an audio codec. I certainly don't. I guess it would be interesting though.
Continuum
QUOTE (kl33per @ Dec 4 2003, 05:00 AM)
The process can be applied to 1-pass using guesstimation.  This is because when analizing a scene for motion in a 1-pass encode you don't know the complexity of the motion to come.  Therefore if you use to much bitrate in the first half of the film, but the second half was more complex, the second half will look terrible.

I don't understand that. If the second half is more complex, then constant quantizer will use more bits on it!

The only reason, I can see, why 2-pass could be theoretically better (qualitywise), is that the quantizer value is not related to the perceived quality under certain conditions. But then, how would a 2-pass mode know that? ph34r.gif
kl33per
QUOTE (Continuum @ Dec 4 2003, 05:26 PM)
QUOTE (kl33per @ Dec 4 2003, 05:00 AM)

The process can be applied to 1-pass using guesstimation.  This is because when analizing a scene for motion in a 1-pass encode you don't know the complexity of the motion to come.  Therefore if you use to much bitrate in the first half of the film, but the second half was more complex, the second half will look terrible.

I don't understand that. If the second half is more complex, then constant quantizer will use more bits on it!

The only reason, I can see, why 2-pass could be theoretically better (qualitywise), is that the quantizer value is not related to the perceived quality under certain conditions. But then, how would a 2-pass mode know that? ph34r.gif

Sorry, that was probably written poorly. What I was referring to was applying the same sort of 'intelligence' you mentioned earlier to 1-pass encoding (i.e. 1-pass bitrate or filesize based encoding).

Note: Original post now edited.
i4004
this is a funny issue in many respects;
recently i stacked 1pass(limited quantizers) to 2pass encoding(unlimited quants);
the only thing 2pass did different was that it almost never used quant2,but rather started from quant3....and subsequently it had least higher quants than 1pass encoding....
and then,i want my still scenes on quant2;no doubt about it;i kept my 1pass encoding....erased 2pass quant3 galore...

but indeed,2pass might save you SOME bitrate(or you may try 1pass in 3-x mode..heh) but i'm wondering will you notice a difference between my 1pass and other folks 2pass'....
and if small percentage of quality increase(if existant at all..) is justified with 2x encoding time.....

fcc said it well;
QUOTE
According to this theory, a 2-pass encode which targets the same filesize as your previous 1-pass encode should look slightly better.

but again,"slightly better" is a flexible term...
once upon a time i though considerable savings in bitrate are possible by 2pass way....now i don't think they are....
now i save my time....
here in croatia we have a saying "speed is a virtue"....

to quote undercut;
QUOTE
But why use one pass encoding at all and not two pass? I think it depends on trade-offs and your taste. Some will claim that two pass encoding will always result in better quality, but that's completely subjective and often false. If you have two MS-MPEG4 video both of same size, one done in one pass and other in two pass, it's not possible to say one is conclusively better than the other. Technically, there are no wasted bits in both of these files. All the bits are used up somewhere. Question is how well and effectively the bits are used up to suit our eye.

http://www.undercut.org/Nandub_OnePass/

some will call this a "sacrilige";i call it "truth"....
my eyes prefer top-notch still scenes while motion may block(but up to particular quant;say 6 till 9....)
also,i'm not using his stuff,but normal nandubRC2....

i think i have the stats(1pass my settings,2pass muf's settings..see filename);
QUOTE
DivX DRF Analyzer v0.9.5 Report!
File Name: D:\Video\Finished\3rd_rock_[].avi
FourCC: DIV3
Codec: MSMPEG4
Resolution: [ Width: 512 Height: 384 ]
Frame Rate: 25.000 frames per second
The Video has 31796 frames [ 00:21:11 ]

Average Frame quality is  MEDIUM [Average DRF/quantizer is 3.80]
Standard Deviation: Quality is MEDIUM [Std. Deviation is 1.17]
Image Resolution is MEDIUM

There are NO frame drops ( NO drops is better )

Recomended Resolution: [432x320]  (Target DRF/quantizer=2.8)
The filesize should be larger!

Performance Caracteristics:
Macroblocks per frame: 768
The Width is multiple of 32

Kilobits per Second: 1200.60
Kilobits per Frame: 47.99
Kilobits per Macroblock: 0.062
Bits per Pixel: 0.25

Frame Quality Statistics :

DRF=1&2: 3354 10.7%
DRF=3:  10975 34.9%
DRF=4:  9441 30.0%
DRF=5:  5230 16.6%
DRF=6:  1684 5.4%
DRF=7:  499 1.6%
DRF=8:  260 0.8%
DRF=9:  0 0.0%
DRF>9:  0 0.0%
KeyF/DeltaF:  1.12%
KeyDRF<4: 0
KeyDRF=4: 326
KeyDRF>4: 27

AverageKeyDRF: 4.11
MAXDRF: 8
AverageDRF: 3.80
Deviation: 1.17

http://www.geocities.com/analyzerDRF/



QUOTE
DivX DRF Analyzer v0.9.5 Report!
File Name: D:\Video\Finished\3rd_rock_[muf].avi
FourCC: DIV3
Codec: MSMPEG4
Resolution: [ Width: 512 Height: 384 ]
Frame Rate: 25.000 frames per second
The Video has 31796 frames [ 00:21:11 ]

Average Frame quality is  MEDIUM [Average DRF/quantizer is 3.77]
Standard Deviation: Quality is HIGH [Std. Deviation is 0.70]
Image Resolution is MEDIUM

There are NO frame drops ( NO drops is better )

Recomended Resolution: [432x320]  (Target DRF/quantizer=2.8)
The filesize should be larger!

Performance Caracteristics:
This video seems to have too FEW Keyframes. May degrade image quality and seeking.
Macroblocks per frame: 768
The Width is multiple of 32

Kilobits per Second: 1212.68
Kilobits per Frame: 48.47
Kilobits per Macroblock: 0.063
Bits per Pixel: 0.25

Frame Quality Statistics :

DRF=1&2: 68 0.2%
DRF=3:  11739 37.2%
DRF=4:  15486 49.0%
DRF=5:  4062 12.9%
DRF=6:  212 0.7%
DRF=7:  30 0.1%
DRF=8:  1 0.0%
DRF=9:  0 0.0%
DRF>9:  0 0.0%
KeyF/DeltaF:  0.63%
KeyDRF<4: 7
KeyDRF=4: 191
KeyDRF>4: 0

AverageKeyDRF: 3.95
MAXDRF: 8
AverageDRF: 3.77
Deviation: 0.70

http://www.geocities.com/analyzerDRF/
smok3
QUOTE (i4004 @ Mar 3 2004, 01:41 AM)
the only thing 2pass did different was that it almost never used quant2,but rather started from quant3....and subsequently it had least higher quants than 1pass encoding....

uhmm, but isnt that something to be expected? i mean, what 2-pass mode is trying to achive is filesize and constant subjective quality, so it has to reduce some of the parts and increase some other (bitrate wise).

(but i agree, i dont care that much for that 10 second shooting part when all other 'love scenes' look like piccasso. (and again that ratio is dictated by the average bitrate, so i would expect that the formula should fail easily in smaller average bitrate conditions.))
i4004
QUOTE
what 2-pass mode is trying to achive is filesize and constant subjective quality

regarding filesize;check this out
http://i4004i4004.bizhosting.com/cgi-bin/i...atrix/pdesk.png
notice the
Wild at heart_.avi
and
Gable&Lombard.avi

was this 1pass limited quants,or 2pass encoding? wink.gif
both movies 2h long,both have awfull lot of them 2quants.. smile.gif ..(but that's also payed for with some niners,obviously... sad.gif )

all in all...perfectly acceptable....
smok3
QUOTE (i4004 @ Mar 3 2004, 04:26 AM)
was this 1pass limited quants,or 2pass encoding?  wink.gif

yes ic what you mean, actually i did encode a few video guides with 1pass xvid the other day and the filesize was perfect (but the video was like a lot of static screens, so that isnt surprising)

'brzina je vrlina' ?
i4004
QUOTE
'brzina je vrlina' ?

sweet!
cool.gif

QUOTE
and again that ratio is dictated by the average bitrate, so i would expect that the formula should fail easily in smaller average bitrate conditions

well said....at some point 1pass may just start to drop frames or to increase the quant's in insane manner....
anyway,i didn't experienced either..it seems i know what i can do and what i can't do with mpeg4( biggrin.gif )
t.g.deck
Just adding some info that hasn't been mentioned, yet.

Basically, an almost constant-quantizer-encode more or less is what XviD tries to reach in 2nd pass of a two-pass. (Slight fluctuation isn't necessarily a bad thing.)

Given that you can live with a file not reaching quite the size you aim at, you could give 2-pass a miss and use a constant quantizer instead. (Needless to say, CBR is a no-no.) Except for two slight advantages of two-pass:
- Two-pass in XviD attains quant=2 to those few frames where no gain is expected from compressing them higher (i.e. they're small enough at quant=2). Possibly a minimal gain in quality.
- Two-pass allows to give I-frames a slight boost. Whether this actually makes a positive difference remains somewhat unclear, but I'd say it probably does.
i4004
QUOTE
Basically, an almost constant-quantizer-encode more or less is what XviD tries to reach in 2nd pass of a two-pass.

how can you claim this,as we all know that constant-quantizer encodings result in unpredictable filesizes???

filesizes are achieved by varying the quantizer!!!

you are wrong!

i thought i linked this
http://www.geocities.com/analyzerDRF/
?
inspect your xvid files,as it seems you never did;if you do 2pass with target bitrate in mind(quants with wide span) they are fluctutating,FOR SURE!
otherwise you would get constant quant and unpredictable bitrate....
more hi-motion mean more high quants....
it's simple really.....

codec's only mechanism to regulate bitrate are quants....
smok3
CODE
DivX DRF Analyzer v0.9.5 Report!
File Name: D:\lightwave_matroska_ac3_dvd_rips_guides\explosive_eff_w_hyperwoxels\hyper.avi
FourCC: XVID
Codec: XviD0028
Resolution: [ Width: 512 Height: 384 ]
Frame Rate: 29.970 frames per second
The Video has 178610 frames [ 01:39:19 ]

Average Frame quality is  HIGH    [Average DRF/quantizer is 2.96]
Standard Deviation: Quality is MEDIUM    [Std. Deviation is 1.38]
Image Resolution is MEDIUM

The file has Packeted Frames!

There are NO frame drops ( NO drops is better )
This video may have some frames with VERY POOR Quality!

Recomended Resolution: [496x368]  (Target DRF/quantizer=2.8)
The filesize should be larger!

Performance Caracteristics:
This video seems to have too FEW Keyframes. May degrade image quality and seeking.
Macroblocks per frame: 768
The Width is multiple of 32

Kilobits per Second: 710.78
Kilobits per Frame: 23.71
Kilobits per Macroblock: 0.031
Bits per Pixel: 0.12

Frame Type Statistics :
I Frames: 0.41%
P Frames: 64.66%
B Frames: 34.93%
S Frames: 0.00%
N Frames: 0.00%
(More Advanced Codecs use B and S frames)
Frame Quality Statistics :

DRF=1&2:    90695    51.0%
DRF=3:  25410    14.3%
DRF=4:  48332    27.2%
DRF=5:  5559    3.1%
DRF=6:  2980    1.7%
DRF=7:  2588    1.5%
DRF=8:  834    0.5%
DRF=9:  625    0.4%
DRF>9:  859    0.5%
KeyF/DeltaF:  0.41%
KeyDRF<4:    630
KeyDRF=4:    23
KeyDRF>4:    75

AverageKeyDRF:    2.34
MAXDRF:    14
AverageDRF:    2.96
Deviation:    1.38

now, this is the report of that 1pass thingy, interesting data, but nothing that would really learn me anything... (or maybe i'am missing something..?)
Continuum
QUOTE (i4004 @ Mar 3 2004, 07:49 PM)
QUOTE
Basically, an almost constant-quantizer-encode more or less is what XviD tries to reach in 2nd pass of a two-pass.

how can you claim this,as we all know that constant-quantizer encodings result in unpredictable filesizes???

filesizes are achieved by varying the quantizer!!!

I don't see a contradiction. He even said "more or less". Of course the codec needs to vary the quantizer, otherwise the output filesize would be restricted to 31 different values. If for example a "constant" quantizer setting of 3.4 yields the required bitrate, then a good 2-pass algorithm should find it and use mostly quantizer 3 or 4.

If this really is the target of the algorithm, or in how far this objective is accomplished is another question...
t.g.deck
Exactly.
i4004
continuum;
QUOTE
I don't see a contradiction. He even said "more or less".

he said;
QUOTE
Basically, an almost constant-quantizer-encode more or less is what XviD tries to reach in 2nd pass of a two-pass.


now you do a drfanalyze on your 2pass xvid stuff,and tell me if it was "almost" or it was " more or less" OR IT WAS NOT.....
i say it is NOT....there will be bunch of different quants there,so there's no talk about "almost" or "more or less".....
you may as well post a drfanalyize file so we all see it....

what's "more or less"?
quants 2-3?
qunats 2-9 used?
quants 2-11?

there is constant quant(no filesize prediction),and there is varied quant(filesize can be predicted,wether it be 1 or 2 passes),and that's it;there's no in between,there's no "almost constant-quantizer-encode more or less is what XviD tries to reach in 2nd pass of a two-pass"
there's no such thing...
no "almost constant-quantizer"!

inspect your files and tell me if i was right...
no,it's not just semantics,but putting the things on their places!
cquant and varied quant are 2 very different things!
t.g.deck
I would call this 'trying really hard to misunderstand an easy idea'.

But to help you out: The stronger the compression, the more the quantizer varies. If you have a, let's say, 70% quality, it'll stay, in the range of 2 quantizers.
Continuum
I repeat what I have said above:
QUOTE (Continuum @ Mar 3 2004, 09:42 PM)
If this really is the target of the algorithm, or in how far this objective is accomplished is another question...

I don't know the answer (your measurements seem to indicate that the answer is "no").

Nevertheless it would be theoretically possible that a codec uses only two adjacent quantizer values for the whole movie.
i4004
QUOTE (t.g.deck @ Mar 4 2004, 06:27 AM)
I would call this 'trying really hard to misunderstand an easy idea'.

But to help you out: The stronger the compression, the more the quantizer varies. If you have a, let's say, 70% quality, it'll stay, in the range of 2 quantizers.

so who was wrong,you or me?
to reiterate,i said quants dance(to respect target filesize,off course),and you were real easy to misunderstand when you said that xvid is "almost" constant in 2pass....i say "like hell it is!"
again;there's no "almost";there's varied or constant quant;if encoding uses more than 1 quant,then it means it's not fixed!
also,narrow quant span means less filesize predictability...

2 quantizers?
ok,let's see analyze of your typical xvid encoding,and let's see if you're doing stuff on 2 quantizers(as that means very low predictability too...go on,man,show me encoding with quants2-3 that hit the filesize,or 3-4,or 4-5 or...or...)

[personal attacks removed by moderation]

i'm off untill you prove yourself right with drfanalyzed file....(but you would have to produce real magic to save yourself...)

again;2pass producing "almost" fixed quant?
go on,admit it that this is silly thing to say!
2pass is MENT to be used for getting the filesize OK,and c.quantizer is MENT to be used in 1pass mode(to achieve constant quality;off course)...

ahhh.....

continuum;
QUOTE
Nevertheless it would be theoretically possible that a codec uses only two adjacent quantizer values for the whole movie.

why "theoretically"?
just limit them quants to desired span!
like p-frames 2-3 or 3-4 or...the i-frames will follow anyway.....
that's exactly what i'm doing in 1pass limited quants mode(only i use wider span so target filesize is respected)
2-3,3-4 etc is unpredictable....ABR mechanism can't kick in with such narrow span....

it's stupidity to call ANY mpeg4 1pass codec CBR as it's NOT(i never saw mpeg4 codec that produced CBR bitrate!can't happen!every frame is different!);on the other hand,mpeg1/2 produce CBR,but there it is also artificial(padding the stream with zeroes if there's less bitrate than targeted....and increasing(higher numbers) the quants to respect the upper limit...)
we may go so far to say that this is also applied in audio compression (as perfect CBR would mean for example constant 3khz sinusiod...but..it happens that 3khz sinus is not really a music...is it....i wan't to say that CBR128kbit mp3 is ABR underneath all that zero padding and cutting the peaks.(same as mpeg1/2 CBR)...but i'm not audio encoding freak,so i may be wrong...if i am,please correct me....i say that CBR modus is something that nature doesn't know...in audio or video...)

someone that says how "CBR" in mpeg4 is a "no-no" never actually did a single 1pass encoding and analyzed it's quants!
why is he talking then?
beats me!
Continuum
QUOTE (i4004 @ Mar 4 2004, 05:39 PM)
why "theoretically"?
just limit them quants to desired span!
like p-frames 2-3 or 3-4 or...the i-frames will follow anyway.....
that's exactly what i'm doing in 1pass limited quants mode(only i use wider span so target filesize is respected)

No, I mean the purpose of the 2-pass algorithm is (or is suggested to be) finding these two quantizers and the needed relation between their number (e.g. 2/3 q3 and 1/3 q4). You could model this behaviour in a 1-pass scenario only if you exactly knew these values a priori. (It's possible that you make an educated guess, but this will never be totally accurate.)

Now maybe the exact computation is extremely difficult, some special "tricks" change the quantizer distribution (e.g. use not too much bits on complex scenes) or the assumption is flat out wrong -- I don't know...
i4004
QUOTE
No, I mean the purpose of the 2-pass algorithm is (or is suggested to be) finding these two quantizers and the needed relation between their number (e.g. 2/3 q3 and 1/3 q4).


hmm...i thought i was clear;
but even clearer;
try 1pass quants 3-4 and try 2pass quants 3-4.....(now look for differences)

main purpose of 2pass is to hit target size while achieving OK quality.....
the first premise(hit the target bitrate) says that "two quantizers used" is a silly concept to say the least......just too narrow span!

does that brin git to it's place now?
filesize AND quality,and not quality alone;quality alone is c.quant's domain(also called constantquality encoding..as you see narler do...)

i suggest;
doing encodings with different modes and different quants span,and after that doing analysis....
that way no confusion is possible......
i'm only saying this after many encodings(with different modes) and many drfanalyized files(and many clips visually inspected,sure...drfanalyze is worth nothing if you can't find a relation between quants used and achieved frame quality..)...and i mean MANY....i never saw anything that would say otherwise...


/ivo
Continuum
You don't understand what I am trying to say. No analyzers are needed.

QUOTE (i4004 @ Mar 4 2004, 06:52 PM)
try 1pass quants 3-4 and try 2pass quants 3-4.....(now look for differences)

No! I mean that the algorithm decides on the span (2-3, 3-4, 4-5, etc.) Nothing is fixed by the user.

QUOTE
the first premise(hit the target bitrate) says that "two quantizers used" is a silly concept to say the least......just too narrow span!

Maybe it is not the optimal concept, but it is definitely possible. Find the greatest n, so that a constant quantizer n encoding is still larger than the specified target size. Now you can do an encoding with quantizers varying between only n and n+1 which reaches the target.

(That does not mean that Xvid's algorithm is implemented this way.)
niktheblak
QUOTE (Continuum @ Mar 4 2004, 09:37 PM)
Maybe it is not the optimal concept, but it is definitely possible.

It certainly could be done, but why should it be done? Why should the codec limit itself to only two quantizer values? Am I missing something here?

QUOTE
(That does not mean that Xvid's algorithm is implemented this way.)


Nope. With my 2-pass Xvid encodes the quantizer values usually span the entire range of 2-10, with most hits on the values 2-4. I could limit the quantizer range, but I can't see any reason why I should do it.
t.g.deck
It should be clear that we only take p-frame quants into account? Because b-frames should be 1.5x the p-frame quant by definition. And I-frames are boosted to be lower than p-frame quant by most people. Also some 'small' quants may come out as quant=2 even if the rest is more highly compressed; this is wanted and expected in special cases, as I wrote above. (I certainly hope nobody is counting the quants used for the ending credits of the movie... wink.gif )
i4004
continuum,this holds no water...(i said that tg's words will confuse!)

QUOTE
No! I mean that the algorithm decides on the span (2-3, 3-4, 4-5, etc.) Nothing is fixed by the user.

so you're saying that we give codec a 2-31 span and then let it decide what 2quants to pick?
is that it?
what if i'm doing moto-race?
and there are some still scenes?
whole concept goes down the toilet!

this is not implemented in that way,neither will it ever be....(even in theory it sounds non-realistic)

QUOTE
Now you can do an encoding with quantizers varying between only n and n+1 which reaches the target.

i told you to try "n+1" qunt span(ie.2 quants) so you can see for yourself that you can't reach the target this way....
it's either too small(too high overall quants) or too big(too low overall quants)....
too small means looks like crap,and too big means "dad...i want dvd burner..." smile.gif
i hate big quants,and my dad doesn't have the money...same as i don't...hehe
(not untill this cdrw burner is working anyway... wink.gif )

i really think tg shouldn't of mentioned "almost" const.quantizer,as after that you got this weird ideas( smile.gif )
and he didn't really mean it that way anyhow..he didn't ment it literally....(as you saw by his later response)
and also as he mentions,when you include b-frames it all just collapses...
video compression simply doesn't work in that way,and i hope it never will( biggrin.gif )
no codec will be picking 2quants on my stuff,let me tell you...

but all this stuff is reminding me about huffyuv;we should go otherway around;smaller filesizes and better quality,instead of thinking about these ultra high bitrate situations....(as i hope you wouldn't do 4-5...for sure you wouldn't let codec pick those two? biggrin.gif )
although in that other thread skywalker just said he doesn't see a difference between quant 2 and 5...( sad.gif .... smile.gif )


QUOTE
Why should the codec limit itself to only two quantizer values?

ask continuum...( biggrin.gif )....
but ok.one could say this;if mpeg4 was so effective that quant2 has the bitrate of quant31 we would all be doing quant2 encodings only...( smile.gif )


QUOTE
Nope. With my 2-pass Xvid encodes the quantizer values usually span the entire range of 2-10, with most hits on the values 2-4.

as expected and normal thing codecs do...
Continuum
QUOTE
(i said that tg's words will confuse!) [...] after that you got this weird ideas

Look at the first post in this thread, it was actually the question. rolleyes.gif wink.gif

QUOTE
what if i'm doing moto-race?
and there are some still scenes?
whole concept goes down the toilet!

Why? The same quantizer will use more bits on the complex race scenes and less on the easy still scenes. Which (I assume) is the intended behaviour.

QUOTE
i told you to try "n+1" qunt span(ie.2 quants) so you can see for yourself that you can't reach the target this way....

headbang.gif You CAN ALWAYS reach the target with only two quantizer values!

The whole argument boils down to this: is the quantizer correlated to the perceived quality?

I don't know the internals of a video codec; I suppose the quantizer is a threshold for the perceptual entropy compression, and thus maybe the best guess of the algorithm, how the final picture will look like. But maybe the situation is completely different (as your analyzed distributions indicate), and that's why I asked the question in the first place: How does the codec decide on the used quantizer (based on the wish of constant quality)?

edit: spelling
t.g.deck
QUOTE (Continuum @ Mar 4 2004, 11:58 PM)
QUOTE
i told you to try "n+1" qunt span(ie.2 quants) so you can see for yourself that you can't reach the target this way....

headbang.gif You CAN ALWAYS reach the target with only two quantizer values!

LOL! This smilie says it very well!

Really, why is it so hard to understand for i4004 that a codec can reach its target filesize by switching between two quantizers? DivX5 for example goes to extremes in order to try and do this: The 'n' passes are for finding a quantizer distribution with more constant quality (less quantizer fluctuation) that still reaches the target filesize. This 'n' passes-thing was all the (marketing) rage for some short time - I mean, could it have gotten past anyone how it works?

Let me try again to explain it: In dumb CBR mode you have a fixed span of time or frames for which the codec tries to keep the target bitrate; because the codec cannot know how big the next upcoming frame is, it'll have to guess a quantizer. If the frame comes out too big, it'll have to compensate by using a higher quantizer on some other frame. Let's say the codec used quant=2 on a frame too big, and now it has to use several times frame=4 to compensate for that. But that's CBR. In 2-pass it is possible to calculate which (theoretical) average quantizer would have to be used in order to reach the target. It is well possible, to stay with that example, to reach the same filesize that CBR reached by using quants 2-4-4-4 by using quants 3-4-3-4. What the actual size of a compressed frame is can't be foretold, so there still will be fluctuation necessary in order to compensate, unless you do n-passes.

As there are no odd frame quantizers and the adaptive quantization of individual macroblocks within a frame can't be forced by two-pass, an alternation between at least two adjacent (anything but adjacent wouldn't make sense) quantizers must be used in order to reach that average quantizer. Nobody has claimed that XviD does this strictly or perfectly; but on the other hand I don't think fluctuation is important enough to justifiy doing several passes.

It is really not that hard to understand! Just use an odd quantizer in XviD's single pass mode, it's the same.

Hope that one broke through the wall.

Edited out: some harshness
i4004
i reverted to page1 and i can only see that you started to ttalk about 2 quants after i ressurected the thread,ie. after tgdeck mentioned "almost constant" thingie....
you asked about cq. versus 2pass....

and you asked;
QUOTE
I read somewhere that the target of 2-pass encoding is to use a quantizer as constant as possible, is that true?

nope..the target of 2pass is to hit the target bitrate by varying the quants...so quant. as constant as possible is not used in 2pass modes (or ABR 1pass)
cannot be used as that breakes filesize expectancy....

QUOTE
Why? The same quantizer will use more bits on the complex race scenes and less on the easy still scenes. Which (I assume) is the intended behaviour.


balance is lost;still scenes will look like crap on higher quants,and we can't really use quants that low as then filesize rockets....

QUOTE
You CAN ALWAYS reach the target with only two quantizer values!

ahhh..yes,i see....you're saying that target filesize is reachable if we pick the right quants............fair enough,your thoughts,but i'm saying that it doesn't really work!
because of your next sentence;
QUOTE
The whole argument boils down to this: is the quantizer correlated to the perceived quality?

off course it is;quantizer is THE most important thing for the quality of the frame...
so 2quants are as i already said;either lookin' crappy or overboard with filesizes...
neither is really acceptable......

QUOTE
How does the codec decide on the used quantizer (based on the wish of constant quality)?

no..it decides based on the bitrate wish...codec is not clever at all!

if you're interested in quantizer explanation,i have one;
god damn,where are the links when you need'em....
http://virtualdub.everwicked.com/index.php...44&hl=quantizer
(i better bookmark this one)

QUOTE
Really, why is it so hard to understand for i4004 that a codec can reach its target filesize by switching between two quantizers?

no it's not,but i want a solid proof;drfanalyzed file report....
1 or 2 pass encoding with 2 quants that reaches desired filesize.....shouldn't be too hard for 2pass guys,right?but make the footage demanding....

QUOTE
Let me try again to explain it: In dumb CBR mode you have a fixed span of time or frames for which the codec tries to keep the target bitrate;

offcourse!
for 1pass ABR(as i said no need to call it CBR) we wan't this buffer as big as possible...indeed...

QUOTE
It is well possible, to stay with that example, to reach the same filesize that CBR reached by using quants 2-4-4-4 by using quants 3-4-3-4.

yes...but i already said that i like still scenes on low quants;but you explained 2pass method well;it will tend to use overall higher quants.....and i said i hate that.... smile.gif

QUOTE
It is really not that hard to understand!

when you produce drfanalyzed report that says xvid(or other mpeg4) did 2quant encoding in 2pass mode and hit the target filesize, i'll believe you;untill then i won't.....
i hope that's fair
(offcurse invitation is opened to anyone reading this.....)

but how will you do that,beats me...(as codec desn't have the slightest clue what quants to use.....ie you would have to limit them manually......in fact i would go so far to say that codec only knows that increasing the quant makes the bitrate go down....all the tweaking of the codec settings we do,proves it;codec are a dumb things!
i only said that 1pass with limited quants can be made indistuinguishable from 2pass encoding...if you push the right buttons....i tried to show it on that 1pass versus 2pass drfanalyzed files...doing a 3-9 span for 1pass would bring 1pass even closer to 2pass encoding....but as i said,i'm not doing 3-x (as is usual 2pass practice) as i wan't a "picasso"(heh) on still scenes.....i compared still scenes on my 1pass versus still scenes on 2pass...i liked 1pass stuff better....exactly as undercut said;no bits are wasted....it's just where they are spent.....i like to use 2 as much as i can...and motion can be slightly worse(but as i said,not too bad;untill quants 6 till 9))

QUOTE
Hope that one broke through the wall.

i posted a solid proof for the things i'm saying.....now you post a solid proof on your concepts.....i didin't saw it yet,and your words alone won't do....

you explained the 1pass versus 2pass mode well,but i believe you are mistaking if you say that target bitrate will be reached by 2 only quants....(as you clearly agreed with continuum when he said it!)
we all know that it would take many test encoding to pick the right 2 quants,and that's not it!that's not automated process.....not useable...not appropriate to do 10 test encodings to see what 2 quants to use.....

as i usually say;encode more,talk less... biggrin.gif
and encode more to reach better quality.....we neeed not theorize this much when we have actuall codecs to test it with...

why won't i do this tests for you?
1-i have "old man and the sea" to cap now
2-my hdd is full again,so more job for nandub...
3-2pass 2quants won't work/doesn't work... biggrin.gif

i'm leaving this thread here....i believe i repeated my stuff few times too many.....
if you post a solid proof that you can do the stuff you claimed are possible,i'll apologize and accept it....no problems...

cheers

/ivo

edit;"cannot be used as that breakes filesize expectancy....
t.g.deck
QUOTE (i4004 @ Mar 5 2004, 04:53 AM)
balance is lost;still scenes will look like crap on higher quants,and we can't really use quants that low as then filesize rockets....

Not true.
1) Just because a frame is small this doesn't mean it will look worse than a big frame at the same quant. The thing is, it is not necessary to quantize it highly. If you switch off b-frames (not recommended) encode at >70% compressiblity and don't use a boost, you could have such a 2nd pass where everything stays within the range of two quants. But this is not desirable. Having most p-frames not jump too much is.

I have said that before, I get the feeling you don't read thoroughly.

2) All the time we've been talking about encoding at sane quantizers like 2-3 or 3-4. Small frames don't look like crap at these quants and nothing rockets nowhere.

If you'd use quantizers like 8-10, having small frames compressed at quant=2 wouldn't save such an encode, either...

QUOTE
as i usually say;encode more,talk less...
and encode more to reach better quality.....we neeed not theorize this much when we have actuall codecs to test it with...

From my experience with encoding and encoding-related forums - which date back quite some years (haven't seen you around back in Nando's days discussing DRF-limitations - which Nando agreed were a very bad idea) - I'm inclined to say that many mass-encoders don't think much about their outdated methods and produce a lot of low-quality output while interested amateurs progress nicely with newer software using default-settings.

I've always found the fun in encoding lies in experimenting and re-encoding again and again to test new features. Usually a movie stays on my HD for weeks, as do several encoded versions of it, done with different custom-matrices etc. till I eventually decide to keep one. Dear colleague, there is a big difference between simply talking too much (often decorated with lots of smilies and emotion) and the development of a consistent stream of thought.

Edited out: some harshness
Edited: made it even simpler and easier to understand
i4004
just to add a further explanation on my thoughts mentioned here
http://www.hydrogenaudio.org/forums/index....ndpost&p=190501
("artificial cbr in audio too" issue)

here's a thread on vdub forum that i remembered while i wrote the above linked stuff....so i went ahead and corrected the stuff with vwpaint's thoughts...here
http://virtualdub.everwicked.com/index.php...=45&#entry24837
(it's enough to read last 2posts on vdub....)
t.g.deck
The quote from Very WetPaint is about MP3-encoding. You should know that video is quite something else; as the first sentence from that quote already implies:
QUOTE
By their nature, audio compression schemes tend more toward CBR than image compression.


It's an unrelated quote, dear colleague. I seem to recall that kind of unrelated quotes and links that don't contribute anything to the clarification of the subject from previous discussions.

Edit: To post something actually related, here are some quantizer-statistics from encoding the Matrix Reloaded trailer; without b-frames (in order not to mess the statistics up due to the b-quant ratio and offset) also without adaptive quantization. Results are as expected, deviation within 1 quantizer at 70% of the 1st pass' size, within 2 quants at 50%:

no b-frames, no aq
50% of 1st pass (54,7 MB; deviation: -818 kb):
quant2=16.4%
quant3=53.2%
quant4=29.5%

no b-frames, no aq
70% of 1st pass (77,4 MB; deviation: -243 kb):
quant2=54,9%
quant3=45,1%

The quant-distribution is quite the same for i- and p-frames. XviD 1.0 RC3. VHQ=4, GMC and trellis were used; 10% i-frame boost and the default 5% for overflow treatment. Interpretation: The 2-pass code seems to work nicely in reaching a rather conservative quant-distribution.

Maybe I'll add stats with b-frames and aq later, but as DRF-analyzer doesn't distinguish between frame-types, I'd have to use the XviD-status window which in turn doesn't output percentages per quant per frame-type. So I'd have to guess percentages which isn't quite a scientific method. tongue.gif

---------------

Edit: In spite of my doubts mentioned above, I've encoded now with b-frames and aq to about the same filesize (slight deviation in such short samples makes for a lot of difference) as the first video without b-frames. Aim was to see whether any more constant distribution of p-frame quantizers could be traded for using b-frames and aq. The result seems to support this notion only partly:

b-frames, AQ
55,2 MB (deviation: -298 kb):
i-frames 2-3 (average 2.40)
p-frames: 2-4 (average 2.79, about 80% are quant=3, about 5% are quant=4)
b-frames: 4-7 (average 4.66, less than 5% are quant=6 or 7)

Interpretation: We see that p-frame quants now tend towards a solid '3' and only deviate one quant up or down in a 20% of all cases. [edit]This must be taken with a grain of salt, though, as AQ means in a good portion of those frames some macroblocks have a higher quantizer.[/edit] So although the result seems unimpressive at first, the reduction of quant=4 p-frames from 30% to 5% should not be valued lowly. It must also be remembered that the DRF-analyzer counted i- and p-frame quants in the non-b-frame encodes as one and the same.

Counting i- and p-frames together the same way for the b-frame-enabled encode for one thing would mean a further slight shift towards the lower quants for this latter encode. Furthermore, in the non-b-frame encode i-frame quant-distribution followed p-frame quant-distribution, meaning that we also had many quant=4 i-frames. There are no quant=4 i-frames in this last encode.

Edit: To come back full circle to the initial question/topic ("Are there advantages of two-pass over single-pass?"): When you encode small clips like the one above, there is no real reason to use two-pass, single pass will do fine. But in most cases you have some filesize limitations (a CD-R, a DVD-R...) for the video you work with and hence you should use XviD's two-pass like it was meant to be (default two-pass settings, no quantizer-restrictions) because it quite accurately hits the target filesize and reaches about the best quality possible for that filesize. This means, an even quality is reached by a quantizer distribution that comes very close to using a fixed quantizer in single-pass. XviD's two-pass algo has been coded by someone who really knew what he did.
MugFunky
my 2 cents...
QUOTE
Average Frame quality is  MEDIUM [Average DRF/quantizer is 3.80]
Standard Deviation: Quality is MEDIUM [Std. Deviation is 1.17]


standard deviation 1.17... that means 95% of all frames are within 2.34 quants of the average (remember stats?)

out of 31 possible values i'd say that's "more or less" constant smile.gif it's a pretty steep bell-curve at any rate.
holkie
too bad i dont quite follow this discussion that goes a bit too far technically for me ohmy.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.