View Single Post
Old 13th December 2006, 22:39   #1  |  Link
Teegedeck
Moderator, Ex(viD)-Mascot
 
Teegedeck's Avatar
 
Join Date: Oct 2001
Posts: 2,564
XviD presets thread

Hello. This thread is here to wrap up the now-confusing first XviD presets thread and to perhaps make it easier to discuss XviD presets - these or others.

Also henryho_hk's great batchfile for almost-automatic encoding with those presets will finally get its deserved own thread, now - here it is: avs2qxvid.bat thread. Please note that I'm not very active in encoding nowadays, so I won't contribute that much to enhancing the presets - maybe we can try to work up to something like 'community presets' eventually.

The XviD presets are now part of MeGUI, AutoMKV, MKVMagic and we also have a batch script by henryho_hk which makes for semi-automatic encoding. (Note that MeGUI doesn't use the preset's first-pass settings, yet, due to technical limitations - but that isn't so grave for the outcome.) Thanks to everyone who took the trouble of incorporating the presets! I hope everyone who uses the them finds them worthwhile. So:

What are these presets anyway?
The presets represent a collection of settings that should guarantee (within reasonable limits) the best quality for a given filesize in two-pass encoding with XviD at all times; and also a reasonable speed/quality ratio. The underlying concept is that different settings are used for different demands on compression in order to better exploit the versatility of XviD. In that respect these 'XviD presets' are very different from presets or profiles found elsewhere.
Presets are named by a minimum percentage that a comp. check with the application Enc should yield if you want to use that preset; but more about that lateron. These are _quality_ presets, meaning they start with the strongest compression and lowest quality and move up to the weakest compression and highest fidelity to the source (which for me equals 'quality'). Strong compression and high fidelity don't go together well, as a tendency.

The lower the percentage in the preset's name, the stronger the compression it delivers is. So the 'low' presets (30%, 45%) deliver lower quality and stronger compression and the 'high' presets (68%, 90%) deliver higher quality but less compression. You MUST perform a comp. check with Enc OR use henryho_hk batchfile to find out which preset to choose! More about that, again, later.

To give users more choice, there always are a 'fast' and an 'HQ' version of each preset. Mostly the 'fast' presets aren't noticeably worse in quality than their 'HQ' counterparts but they certainly are faster (about double as fast). For the presets that deliver strong compression ('>30%' and '>45%') the quality advantage of the HQ variant is more visible; it gets less and less obvious with the 'higher' presets.

What these presets aren't
These presets aren't meant for ensuring compatibility with standalone players. The use of CQMs, which is the very base of the presets, is not compatible with many standalone players; the same goes for QPel. Having a 'watered-down' version of each preset for each standalone-chipset would also make an already complex topic even more confusing. Thus, if you have a standalone and want to encode to the best quality reachable for that thing, please turn to henryho_hk's great avs2qxvid.bat which should provide for your needs. Besides, I think XviD's 'level' settings should really take care of the problem. If they don't they are broken.

How does it work?
If the filesize you aim for is easy to reach presets with high-quality CQMs are used that preserve more detail and thus deliver a higher fidelity to the source. For higher compression on the other hand presets with more effective settings and custom quantization matrices are used. Fidelity might not be reachable this way, but at least a subjectively pleasing result is possible. Still, a big emphasis is on efficiency, i.e. what doesn't give more bang for the buck doesn't get into a preset.

Because the presets try to deliver the best quality for a certain strength of compression all presets will in the effect yield a minimum and a maximum filesize, depending on the video content. This restriction prevents you from using the wrong preset for your purpose. But this can also mean that you get under- or oversizing in the 2nd pass if you chose the wrong preset.

How do I choose the correct preset?
The preset names are based on a compressibility-check with Enc which should take only 10 minutes or something. Yes, that's the big setback; you have to perform this comp. check BEFORE you encode and choose your preset according to the percentage result Enc gives you. This should give you accurate 2nd-pass filesizes (in most cases...). Everything else would be a shot in the dark.

In detail you need to do this: Start up Enc, select your .avs, choose 'compressibility check' and enter the filesize you're aiming for in kilobytes. Also you better choose the 'extended' method for the test. Then you have to configure XviD. Set it to single-pass, constant quantizer=3. Load the SixOfNine (non-VHS!) CQM and set b-frames to max=2, ratio=1.62, offset=0, ME-precision to 4, VHQ=off, Trellis=on, Turbo=on, no packed bitstream and no other switches at all. (That means, it'll go damn fast...) Then press 'start'. The result Enc gives you will be a percentage figure.

BTW, a general hint for high quality encoding: it's a good idea to try and keep the full resolution of your source if possible. No sense in encoding 320x at the 90%-preset

I've deciced on a preset, now how do I use it?
You can either enter the settings from the presets into XviD's VfW GUI manually; you can use the Batch script byhenryho_hk; you can use the inbuilt XviD presets in MKVMagic or you can use the presets in MeGUI. The most up-to-date version of MeGUI already comes with XviD presets, for older versions you can download the presets here and import them.

I did use a preset according to the outcome of a comp. check but I still got over-/undersizing - what do I do now?
If you get over- or undersizing in spite of doing a comp. check -- sorry, that can happen - the comp. check seems pretty reliable but it's nothing scientific. As I get more feedback on the accuracy of the percentage figues I might tune them a bit. Or not. Hey, that's life.

So, here's what you do:
  • If you get undersizing use the next 'higher' preset (reflected by a higher percentage in the preset's name).
  • If you get oversizing, use the next 'lower' preset.
  • If you get undersizing using the highest preset ('>90%') increase resolution if possible.
  • If you get oversizing using the lowest preset ('>30%') reduce your resolution.

A note on 1-pass encoding: These presets are meant for two-pass. Of course you can also use the presets for constant-quantizer encoding. BUT if you want to do that use a constant quantizer 3 or 4. As for CBR encoding: just dont. DON'T!

How did these presets get together?
These presets are deduced from a (hopefully) systematic approach in which I tried to set up two categories ('compression' and 'speed'), each holding several levels associated with a set of XviD switches, and combined the levels of those categories into pairings. See this initial post for the detailed approach. The count of theoretical pairings has been reduced to a sensible number by first dropping 'unattractive' candidates and second by performing practical testing. Modifications were made as a result of testing, too, so that some of the actual presets don't closely resemble the initial theoretical categories anymore. But they are certainly better now than they were in the beginning.

What exactly are the settings for the presets?
Now, this is important for you if you want to set up the presets manually in XviD's VfW GUI.

We have seven basic presets, plus 2 'special purpose' presets. Nine in total. Note that the 'special purpose' presets aren't in the MeGUI profiles, yet.

First pass settings:
Same CQM as in second pass; same number of max consecutive b-frames, b-frame ratio and b-frame offset as in second pass; AQ if used in second pass; Trellis; ME precision=5, (except for the 'DVD-R perfect' preset, where it should be '4'); VHQ=1; Turbo. A zone with constant quantizer as specified in the preset-settings.
And that's it; no QPel, no GMC, no VHQ for-b-frames, no chroma ME.

Second pass settings:
  • XviD '>30% comp. check' (fast): MSP=6, VHQ=1, VHQ for b-frames, AQ, EQM v3 ULRv3, curve-compr. H30, L15, quantizer-restrictions min. 3, max. 5
  • XviD '>30% comp. check' (HQ): MSP=6, VHQ=4, VHQ for b-frames, QPel, AQ, EQM v3 ULRv3, curve-compr. H30, L15, quantizer-restrictions min. 3, max. 5
  • XviD '>45% comp. check' (fast): MSP=6, VHQ=1, VHQ for b-frames, QPel, EQM v3 LR, curve-compr. H20, L7, quantizer-restrictions min. 3, max. 4
  • XviD '>45% comp. check' (HQ): MSP=6, VHQ=4, VHQ for b-frames, QPel, EQM v3 HR, curve-compr. H20, L7, quantizer-restrictions min. 3, max. 5 (4 for I-frames)
  • XviD '>58% comp. check' (fast): MSP=6, VHQ=1, VHQ for b-frames, Qpel, SixOfNine, curve-compr. H15, L5, quantizer-restrictions min. 3, max. 5 (4 for I-frames)
  • XviD '>58% comp. check' (HQ): MSP=6, VHQ=4, VHQ for b-frames, Qpel, SixOfNine, curve-compr. H10, L3, quantizer-restrictions min. 3, max. 5 (4 for I-frames), Overflow Control Strength=0
  • XviD '>90% comp. check' (fast): MSP=4, VHQ=1, VHQ for b-frames, b-frames 1/1.00/1.00, QPel, b-frame sensitivity=-3, SixOfNine, no curve-compression, quantizer-restrictions min. 2, max. 4 (3 for I-frames), Overflow Control Strength=0
  • XviD '>90% comp. check' (HQ): MSP=4, VHQ=3, VHQ for b-frames, b-frames 1/1.00/1.00, QPel, b-frame sensitivity=-3, SixOfNine, no curve-compression, quantizer-restrictions min. 2, max. 4 (3 for I-frames), Overflow Control Strength=0
Special purpose presets_
  • for editing only: 1-pass only: ME6, VHQ=1, no b-frames, chroma ME, EQM EHR, constant quantizer = 2
  • Anime/CG/Cartoon preset: cartoon mode(!), b-frames ratio 1.0, offset=1, ME6, VHQ=1, VHQ for b-frames, chroma ME, H.263, 1st pass @q=2, quantizer-restrictions min. 2 max. 6

Settings that are always active if not specified otherwise: ME precision=6, chroma ME, Trellis, chroma opt., b-frames: max. 2 consecutive, ratio 1.62, offset 0, ME precision = 5 for first pass.
Note: 1st pass @ quant=xy means that you have to set that quantizer as a zone in the first pass and have to change it back to weight=1 for the second pass.


Lastly, why should I care about XviD (ASP) presets when there are more modern (AVC) codecs?

Strange as it sounds, there are some things ASP codecs still do better than AVC codecs IMHO; at low compression they simply deliver higher fidelity with many DVD source than AVC codecs; or so my eyes tell me. Roughly I would say that AVC certainly looks better than XviD with the '>30%' presets. But still you may want to use XviD for some reason? (If there ever is an XviD binary that can produce both ASP and AVC output, the >30% preset should definitely be changed to utilize AVC). AVC can look better than XviD with the '>45' preset. Not in every case, I would say, so XviD might still be worthwhile here. But I would say that from the '>58%' preset upwards high fidelity is more easily reached with XviD. So for me personally XviD presets are valuable because I want to make 'transparent' backups (=backups that can't be told from the original). You might or might not find a reason to use these presets - if you do: have a lot of fun!

Edited: In comp.-check use 'extended' method and no packed bitstream in XviD.
__________________
It's a man's life in Doom9's 52nd MPEG division.
"The cat sat on the mat."
ATM I'm thoroughly enjoying the Banshee - a fantastic music player/ripper for Linux. Give it a whirl!

Last edited by Teegedeck; 8th February 2007 at 22:45.
Teegedeck is offline   Reply With Quote