View Full Version : 2-pass is not so good


yingx2
25th December 2002, 16:02
Hi, all

Haven't spoken here for a while, but I have sereral questions that I really cannnot find the answers on my own, so I have to ask.

After finishing my 2-pass encoding job, I opened my analyse.log to figure out its quant distribution as usual. All of sudden I realized all of the quants are round numbers(such as 2,3,4,5) -- Non-integral quant values like 2.5 or 3.7 are not used at all

Does this mean that 2-pass encoding method are less flexible in terms of bitrate distribution than we thought? I know I must miss some simple point but I just couldnt figure it out myself, sorry.

And another thing is: In two pass mode, DivX 5.02 tends to save bitrates in early part of a movie using higher quant values, whlle enconding the last 1/10 of the frames at quant 2, whcih brings about "unbalanced quality". If the comp-test value is somewhere between 50%-80%, I would see the last 1/10 of frames all being enconded at quant 2 in the analyse.log, and the last 1/10 part of the movie might just be talking heads, or some less bitrate-demanding scenes, resulting in a "unintelligent bitrate distribution" of this encoding project. I know this has been mentioned before, but again I cannot find the solution.

I'm not talking about how to encode credits seperately. For example, I capture NBA games via MJPEG codec quite often, and later convert them into DivX AVI format. Sometimes the last 1/10 of the frames were extremely static scenes -- Commentators discussing about games. In that case, I would get undersized files since those scenes were so compressible that even if the codec assigned quant 2 to all of those frames, I still could not achieve my desired file size. This kind of encoding job always ends up with an avg quant like 3.12, not 2. This "quant 2 for the late part" tendency makes the codec lose the ability to encode movies intelligently.

Imagine this: A 200,000 frame NBA game consisting of 180,000 bitarte-intense frames in the first part, and 20,000 easy frames in the end. You want to fit it onto 2 CDs, so your bitrate combination is: 128kpbs for audio - 1617kbps for video. You select a proper resolution based on a comp value around 50%-80%. Finally, you end up with a 1,300MB file. So you open your analyze.log, trying to figure out what happened. Yes -- Quant 3, 4, 5 for the main part of the game that you want as good as possible, and quant 2 for trivial talking heads. So getting a undersized file itself becomes an irrelevant issue. The unintelligent bitrate distribution is the one that bothers you. Again, encoding those easy frames seperately is not what I'm looking for. Even if I take this approach, encoding the last 20,000 frames seperately, the codec would still encode the 180,000 frame part in two parts -- quant 2 for the last 18,000 frames, quant 3, 4, 5 for the first 162,000 frames. Any ideans?

I've heard that changing the RC period to half of the number of total frames makes the codec compensate better. However, I've done some tests and the results indicated that tweaking RC period makes practically no differeces to the quant distribution -- Yes, I opened log files to compare quant values line by line. (I tried default value, 1/2 of frames and total frames for RC averaging period) .

And I found an old thread where Acaila wrote : "The RC values are not used with 2-pass mode so you can forget about those". -- This is what I see so far.(http://forum.doom9.org/showthread.php?s=&threadid=22571)

But the people on the official DivX forum treat RC period really seriously, which contradicts all my tests.
http://forums.divx.com/viewtopic.php?topic=44129&forum=6
http://forums.divx.com/viewtopic.php?topic=44413&forum=6

Unfortunely, they did not provide any quant distribution comparison to convince me.

Either I'm or they are idiotic.

It seems they are not, as I'm now about to beilieve that 1-Pass quality-based 100% mode is the smartest VBR encoding method. It takes as much bitrate as" it needs" to maintain perferct quality in high-motion scenes, and it will never use 10,000kbps to encode simple frames like what MPEG2 codec does in constant bitrate mode -- It takes only what it needs to produce best possible picture quality.

I can fit Lord of the Rings onto "only" 4 CDs using 100%qb mode at full resolution, along with AC3 sound. Size unpredictability was a big problem. Here's what I did to make it come out exactly 2800MB:

1. Assume the credits is 30MB in size. (without sound)

2. Extract AC3 sound with DVD2AVI. Lets say it's 500MB in size.

3. Use divx5enc to do a comp test for the main movie. Now you get a predicted maximum file size. Let's say it's 2000MB.

4. Make sure "2800MB(4 CDs) - 30MB(credits) - 500MB(AC3 sound) - interleaving&frame overhead (Let's say it's 20MB) = maximum file size predicted above" It's 2250MB in this case

5. 2250MB doesn't equal to 2000MB. In order to make it 2250MB, you need to try a sharper resize method. The original resize parameter is "BicubicResize (720,304,0.333,0.333)", so you change it to (720,304,0,0.5) and run a comp test again. Do it serveral times until the predicted maximum file size is somewhere near 2250MB. Once it's close enough, you can start to encode it using 1-Pass QB 100% mode. There are several DivX encoding parameters whcih can help you shrink or enlarge a file, but I think changing resize parameter is enough. I only use B-frames and leave everything else as default.

6 The predicted size should be pretty close to the actual size. If the predicted size is not so accurate, and your actual file size is just 2200MB, that's ok. All you have to do is make the credits 80MB. (30+2250-2200). In fact, credits of 80MB isn't OK to me. The acceptable range to me is somewhere between 5MB and 50MB. So I have to try another resize parameter and encode the main movie part again.

Most movies won't require more than 3 CDs with this kind of "maximum quality ripping machanism". If using 2 CDs to backup a DVD movie is acceptable to you, why not use 1 or 2 more CDs to produce the best quality possible? Is it overkill to encode movies this way? Well, it's all about personal taste. People with trained eyes are more likely to see minor compression artifacts we don't see. They need much more bitrate to watch a movie comfortably, so they might be willing to take this approach.

I use it just because I think DivX5's 2-pass mode is not intelligent enough on bitrate allocation. But sometimes I would also ask myself : Is 2GB or 3GB really too large for a movie? I'm sure that 2 years later, I will watch these movies again, and what I will care then is how good they are, not how small they are. Because I'll need something big enough to feed my 1TB HD and my double-layer double sided DVD-R discs.

Don't make me look too bad, please. It's already painful for a non-native English speaker to type so many words in English. I'm not trying to convine anyone of anything. I'm just sharing my ideas, asking questions and expecting your precious opnions. Thanks for taking the time reading this crap, and Merry Christmas to all!!

Oh, my last question: How do you pronounce the word "DivX" ?

jggimi
25th December 2002, 18:05
I can answer only one of your questions. I pronounce DivX in 2 syllables. "Div" with a short i, as in the most common US/Canadian pronunciation of the first syllable of the word "divide." I pronounce the second syllable as "icks," again with a short i. My accent is on the first syllable. I'll bet many pronounce the second syllable as "ecks," which is how many prounounce the letter "X."

I've never investigated quant details, and can't help much with that. I do turn off b-frames when doing single pass 100% encodings, since I've been told here that b-frames will impact quant 2 encodings, since they have a best value of quant 4. I've never confirmed it, I just do it as a matter of course, now.

khp
25th December 2002, 18:42
Originally posted by yingx2

After finishing my 2-pass encoding job, I opened my analyse.log to figure out its quant distribution as usual. All of sudden I realized all of the quants are round numbers(such as 2,3,4,5) -- Non-integral quant values like 2.5 or 3.7 are not used at all


On single frames, the quantizers are always integers, this is the same for both 1-pass and 2-pass. When you do a qualitybased encoding at quant 2.5, some frames will use quant 2 and others quant 3.

Originally posted by yingx2

And another thing is: In two pass mode, DivX 5.02 tends to save bitrates in early part of a movie using higher quant values, whlle enconding the last 1/10 of the frames at quant 2, whcih brings about "unbalanced quality". If the comp-test value is somewhere between 50%-80%, I would see the last 1/10 of frames all being enconded at quant 2 in the analyse.log, and the last 1/10 part of the movie might just be talking heads, or some less bitrate-demanding scenes, resulting in a "unintelligent bitrate distribution" of this encoding project. I know this has been mentioned before, but again I cannot find the solution.

The bitrate distribution engine in DivX5 does not work very well, when you get close to maximum quality. This is, at least in part, because divx5 uses bitrate controlled encoding durring the first pass (as opposed to xvid which uses maximum quality encoding for the first pass), in two pass encoding. This means that divx5 does not learn enough durring the first pass, to do a perfect second pass, when the movie compresses better than divx expected it to. On the other hand, I think it works very well, when your filesize target is approx 55-70% of maximum quality.

Originally posted by yingx2

And I found an old thread where Acaila wrote : "The RC values are not used with 2-pass mode so you can forget about those". -- This is what I see so far.(http://forum.doom9.org/showthread.php?s=&threadid=22571)

But the people on the official DivX forum treat RC period really seriously, which contradicts all my tests.
http://forums.divx.com/viewtopic.php?topic=44129&forum=6
http://forums.divx.com/viewtopic.php?topic=44413&forum=6

Unfortunely, they did not provide any quant distribution comparison to convince me.


I'am not sure what the truth about this is. But I would not be surprised if Acaila is correct. But of course this is very easy to test.

Originally posted by yingx2

Either I'm or they are idiotic.


IMHO, the divx.com forums are largely populated by utter fools.


Originally posted by yingx2

It seems they are not, as I'm now about to beilieve that 1-Pass quality-based 100% mode is the smartest VBR encoding method. It takes as much bitrate as" it needs" to maintain perferct quality in high-motion scenes, and it will never use 10,000kbps to encode simple frames like what MPEG2 codec does in constant bitrate mode -- It takes only what it needs to produce best possible picture quality.


If you don't care about filesize, yes quality based encoding @ 100% is best. But most of us do care about filesize.

Acaila
25th December 2002, 23:16
First off I must say that you can write quite a long story for someone who's native language isn't english :D

I believe I have heard it mentioned before that people found that DivX encoded the last part of their video with too low quantizer. All in all DivX5 has proven to have a less than optimal motion estimation. If 1-pass mode works better for you, than use that. Most of us need to stick to a maximum filesize, so 2-pass mode is the only sensible solution (no matter what shortcomings it might have).

As for this part:
And I found an old thread where Acaila wrote : "The RC values are not used with 2-pass mode so you can forget about those". -- This is what I see so far.(http://forum.doom9.org/showthread.php?s=&threadid=22571)

But the people on the official DivX forum treat RC period really seriously, which contradicts all my tests.
http://forums.divx.com/viewtopic.ph...c=44129&forum=6
http://forums.divx.com/viewtopic.ph...c=44413&forum=6

Unfortunely, they did not provide any quant distribution comparison to convince me.There are several values that pertain to Rate Control. All those EXCEPT "Rate Control Averaging Period" are for 1-pass mode alone. So that is the only one that is relevant to 2-pass made. Most people seem to find setting it to half the total numer of frames to be an improvement, personally I haven't seen much evidence of this with my own encodes...

khp wrote:
IMHO, the divx.com forums are largely populated by utter fools.I would never call them that, but I stopped reading there a long time ago for a reason :).

manono
26th December 2002, 08:39
Hi-

First off I must say that you can write quite a long story for someone who's native language isn't english

I agree. That was well written, even for someone whose first language is English.

?¿öM¿?
26th December 2002, 09:50
Hi,
You have better command over the english language than I do and I am from an english speaking country. Me english bad speak (j/k).

I still use DivX 5.0 Pro as it seems to give me better results. I noticed what you are saying, though not to the same degree, that DivX 5.02 Pro did not seem to produce as good average quality in 2pass over the whole movie as 5.0 Pro does. I didn't run any tests (aside from a few double encodes with the same parametres), I just went back to 5.0 Pro and am much happier with the results.:D

yingx2
26th December 2002, 19:19
Thank you for all of your nice responses :)

@jggimi
I always wanted to know this. I am much happier now.

@khp
a lot of new information there. Thanks a lot.
And I am gratified at knowing what you think about them. Chances are, I'm not idiotic. :)

@Acaila
@manono
@???
Thank you for the complement about my English. You guys are making me feel good.


I think I need to offer futher explaination about my fisrt post to make it clearer, since it's a little bit too long. Note: the following ideas are very likey to be wrong and I will be more than happy to be corrected. (But please be gentle.)

1. Undersized movies are not necessarily saturated, "especially when they contain very easy frames at the end, even if their comp values just reach some 60%"

(I believe the quoted part is something original)

2. Setting the RC avg period values to 1/2 # of total frames hardly influences the quality.

I know this is fairly chellengeable since some divx gurus suggest the opposite. And I've noticed that there are more and more people on this board starting to talk about the RC period's miraculous impact on a movie's overall quality. That makes me so jealous because I cannot see it.

This is very easy to test. At least some "before/after" screenshots will do. However, I'm looking foward to seeing some quantative comparison tests conducted by experienced users here to prove me wrong. (Because I'm eager to make my encodings benefit from RC period, too)

Here's what I suggest to quantify quality improvement introduced by changing RC averaging period:

1. Cut a clip which contains continuous high-motion scenes longer than 2,000 frames from the movie encoded with the so called "optimal RC period value", and compare its bitrate with the bitrate of the same clip encoded with default parameters.

2. Or simply compare the quant distribution of the same movies and point out major differences between their analyze.log files.

I did both above, but failed to prove that RC period plays an important role in 2-pass mode. But maybe that's just because I am not that experienced as you pros or I made some mistakes in my tests.

About the 1-Pass QB 100% thing, you can entirely forget about it if you don't like it.

My point is, that you will never get any chance to go wrong with this approach, unless a big filesize is wrong for you. Or, perhaps a big filesize is wrong for you now, but will it become not so wrong 2 years later?

And most importantly, movies encoded at 100% quality are not evilly big:

Bedazzled
Johnny Mnemonic
Antitrust

They're all 2CD rips encoded with a very sharp bicubic resize parameter --(720,xxx,0,0.75~1.5). And they all have 5.1 AC3 sound. Of course many advanced enconders are able to make these movies look good using only 1 CD, and I will never doubt it.

Thanks for reading all this crap again, but at least this time it's shorter :)

?¿öM¿?
27th December 2002, 14:40
http://forum.doom9.org/showthread.php?threadid=32633
I will do this when my delightful holiday(with my girl at her home in France) is over.

Are you sure you fit 100% quality 1pass encodes on 2CD's? I get files of 2-4GB without audio usually. A 5.1AC3 track often comes to something like 300MB alone.

/OFF TOPIC/
I just got told I'm going to be hurt if I check this forum one more time. I can't help myself...:D

NachoKun
28th December 2002, 02:15
?¿öM¿? wrote:
Are you sure you fit 100% quality 1pass encodes on 2CD's? I get files of 2-4GB without audio usually. A 5.1AC3 track often comes to something like 300MB alone.

Yes, that is possible if the movie consists of lots of low-motion and/or dark scenes. Fast-motion and/or colorful, detailed scenes need a lot more bitrate in MPEG4 encoding.

?¿öM¿?
28th December 2002, 11:28
You are correct, it is possible:o . I just thought that the movies listed below might have exceed 1.4GB. Antitrust has good compressibility, but the johnny neumonic DVD I have is poorly authoured and has alot of noise. I don't have bedazzeled, but I wouldn't have thought it compresses that well.

Yingx2 seems to know what s/he is talking about so I guess it was a silly question. I officially withdraw it.:D

yingx2
28th December 2002, 15:47
Bedazzled's compressibility is just at a medium level, but its duration is quite acceptable for a 100% quality 2 cd rip. I uploaded 2 short clips from it to show why I think 100% encoding is the smartest vbr compression method in terms of the flexibility of bitrate allocation -- It can go as high as 6500kbps and as low as 900kbps, depending on how much it needs.

http://myweb.hinet.net/home1/joefox/low.avi
http://myweb.hinet.net/home1/joefox/hi.avi

Are they sharp? I'm not as crazy as you guys think, am I? --still crazy enough.

@???
I hope you're still in one piece now.:)

I just got told I'm going to be hurt if I check this forum one more time. I can't help myself...

?¿öM¿?
28th December 2002, 16:47
That is superb quality. I only dled low.avi(56k here:( ), but it looks great, nice and crisp. If it fits on 2CD with 100%q 1pass, I guess it isn't necessary to do a 2nd pass anyway. I haven't done any serious 1pass encoding (except at 100%q) for a long time, around early DivX4. I think I'll do some comprehensive testing "1pass vs 2pass" and post the results. Perhaps I should post them at the DivX.com forum aswell :p .

/OFF TOPIC... again/
Referring to DivX.com 1pass vs 2pass links:
I like the way the DivX.com forums often degenerate into a flaming war. Makes for entertaining reading.

... baby, i'm sorry, ouch... really, this is the last time... ouch...I think your overreacting... rofl:D .

EDIT: I think that the reason you need an integer quantizer is that the codec only stores 30 quantizer matrices and the quantizer value is the centre of a matrix. Real (decimal) numbers are much harder to manipulate than integers and cause more bugs in programs, especially when being used in complex equations with type cast integer -> reals. An xvid guru would know as I've been told you can set your own quantizer in xvid. The developers would certainly know.

dTb
10th January 2003, 07:46
Originally posted by yingx2
Here's what I suggest to quantify quality improvement introduced by changing RC averaging period:

1. Cut a clip which contains continuous high-motion scenes longer than 2,000 frames from the movie encoded with the so called "optimal RC period value", and compare its bitrate with the bitrate of the same clip encoded with default parameters.

I don't think this is such a good test for testing the effect of rc averaging period. It would probably be better to say take 10mins of video where it changes between high motion and low motion a number of times. Encode it twice, once with rc averaging set to 1/2 the # of frames and the second time with it at the default of 2000.

Hey stop bagging the divx forums alright, its not so bad.:(