View Full Version : ANQ: measuring/setting XViD quality
jaapaa
14th October 2004, 17:04
Another Noobie Question...
I've read about DVD - Avi conversion with gordian knot and during that I've read about the XViD settings. Now I'm just transferring my mpeg movies to .AVIs packed with XViD.
Now here is the part that I haven't seen anywhere:
How can I set XViD for good enough quality?
All the controls are based on the file size. You have bitrate calculator which calculates the desired bitrate to get file of desired size. What I would like to find is quality setting, just like with JPEGs. Quality 0.9 is pretty darn good, 0.75 less good but bearable.
When one saves a jpeg, there is never a dialog asking what size the file should end up to, or is there? (I've yet to see one). Instead there is quality setting, which is set and the file ends to what ever size matches that quality.
Is there a way to achieve this with XViD?
Can I just look at resolution, say
352x240 = 84480 pixels / frame * 29.97 Fps = 2531865 bits/sec
Then multiply that with decent enough XViD quality (I've seen figures stating it should be between 0.17 to 0.30 bits/pixel/frame) so we
get 2531865 * 0.3 = 741kb/sec
Am I totally lost here, is it this linear?
Any rules of thumb about bits/pixel ratios on different kind of video?
jggimi
14th October 2004, 17:56
Your question about "Good Enough" is answered by Gordian Knot (or AutoGK) through a technology known as Compressibility Testing.
Read up on it.
jaapaa
14th October 2004, 20:11
I had lots of question about it too, but I decided not to rip my DVDs. Right now I'm encoding mpeg files laying on my HD, which I don't know how to handle with gordian knot (can you even do that?). I just fire up virtualdubmod and process the mpeg file...
I've yet to find tutorial which tells the information so that it's constant with my personal testing on the same matter.
At least information on compressibility check at http://www.divx-digest.com/articles/dvd2xvid_gordianknot.html
I think I'll return to this later...
jggimi
14th October 2004, 20:43
MPEG-2s can be encoded with GK by opening them in DGIndex/DVD2AVI as if they were .vob files.
--------------------------------------------------
Compressibility tests for determining quality are pretty simple to use, but complex to discuss.
From Doom9's GK guide:...You also have to keep watching the Bits/Pixel values....It's a bit guesswork as you cannot predict compressibility of your movie. {Highlight mine}And that is why you do a compressibility test. Every video has different compression characteristics.
AutoGK is easier to learn, and requires less knowledge to use then GK. To that end, it makes some decisions for you. These automated decisions are actually similar to the ones you might make on your own when using GK.
From Doom9's AutoGK guide:About resolution selection:
AutoGK tries to obtain a Bits/(Pixel*Frame) value that is 70% of the Compressibility test (the Bits/(Pixel*Frame) value obtained when the movie is compressed for maximum quality). If the resolution to obtain this value is below 512x for a 4:3 movie, or 608x for a 16:9 movie, the limit is set to 60% instead of 70%. In addition to changing the resolution, the resizing filter is also changed (instead of a very crisp filter that yields a high Bits/(Pixel*Frame) value like the bicubic resize a neutral bicubic or lanczos filter is used), along with custom quantizer matrices in XviD.
The comp test is performed at a 704x resolution for 2 CDs and 640x for 1 CD. B-frames are used unless the Bits/(Pixel*Frame) value used goes above 85% of the compressibility test and the maximum resolution has been used.
In maximum quality mode, the maximum resolution of 720x is used (but black bars are still cropped away if applicable).From the AutoGK tutorial:...Advanced Settings....The Resolution settings will allow you to set a horizontal resolution (Fixed width) or a minimum horizontal resolution. Minimum width means that the movie will not be encoded at a horizontal width lower than what you set. It will try the higher resolutions, but if the compression test results are too low, it will try lower resolutions until it gets to your minimum width, stop there, and encode it at that width (and corresponding height), no matter what the compress test results might suggest. Although AutoGK can make certain adjustments if the quality won't be good for your chosen horizontal resolution and file size, it's very possible that the quality will suffer if you choose a high resolution fixed width and go for 1 CD. The chances of this happening are less if you choose a Minimum width, but it can still happen. With time you'll learn the relative compressibility of different movies, but if you change from the default Auto width, you might pay attention to the Compression Test results when they show up in the Log Window. Ordinarily you'll want a result of between 60-80%, and if you get below 50% or so, the quality will suffer noticeably. In that case you may wish to abort the process and start over with a different Horizontal width, or use an extra CD.
killingspree
14th October 2004, 21:03
more on doing a compressability check manually (including xls spreadsheets to do the calculations for you)
http://forum.doom9.org/showthread.php?s=&threadid=44414
kr
steVe
jaapaa
15th October 2004, 12:42
Thanks a bunch, I've learned a lot. Again.
These instructions help a lot when one is working with DVDs and other mpeg-2 streams. Actually I had one simple error earlier, the reason why I didn't get constant results from GK's compressibility test: Nowhere did it say that the compressibility test must be run with XViD set to single pass encode. I think I had it usually at 2 pass, 1st encode when doing the compressibility test.
Now, I'm not going to let you off so easily....
I have lots of mpeg-1 material, which I'd like to encode with XViD.
Cause I can't open mpeg-1 stream in DGIndex, I need to know how GK calculates the video size. For example, I tested with 151 second (mpeg-2) clip, set it to 2200Kbit/s and GK says it will generate 40418kb file.
151sec*2200kbits/sec = 332 200kbit, which is way more than 40418 kb. Where does it get that figure? I need that for calculating the compressibility. Or is there another way to check compressibility of mpeg-1 stream when ?
Or is this the bit vs byte thing, ie. 8 bits to a byte? That would result to 41525, which is still slightly more than what GK came up with.
stephanV
15th October 2004, 12:59
you forget 1 kilobyte = 1024 bytes but 1 kilobit = 1000 bits
so for the correct conversion ---> 151*2200/(8*1.024)= 40552 kB (i think your clip is actually 150.5 seconds :p)
anyway, it will still be a little bit larger because of container-overhead.
BTW - for notations use capital letter 'B' for byte and just 'b' for bit. it avoids confusion :)
iradic
15th October 2004, 19:31
dont know what exactly you are calculating, but with mpegdecoder by Nic (from avisynth filters page - newest version doesnt support mpeg1 but older ones do) you can open mpeg1 (in avs) in gknot... and let gknot calculate for you (and encode if you want)...
bye
jaapaa
15th October 2004, 23:24
Thanks. Already tried it. Result was totally green screen.
Guess there were too many layers of data trough avisynth.
mpeg1 - avs - d2v (opened by gnot) - avs (processed by virtual dubmod) -> green screen.
jaapaa
16th October 2004, 08:11
This is an answer to my original question, just in case someone else is thinking about the same problem I had.
1) Open your movie in VirtualDubMod
2) Create avi and compress it with single pass, quantizer set to 2, you can disable audio (this is just a compression test, no need for audio).
3) open the avi you just created with VDM. Check file - > file information, take down the average delta frame size
4) Calculate the desired filesize by: Compression * Avg delta * frames in the movie / 1024 = filesize in Kbytes.
5) Divide that by lenght of the movie (seconds) and multiply by 8 (8bits in one byte) = now you have the target bitrate for desired quality.
There it is!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.