View Full Version : 2pass encoding and quantizer settings in Xvid.
badshah
2nd February 2007, 23:31
Hi,
I hope u will help me with my small query...
1st let me brief u abt my ripping...
I record videos from TV tuner card and then rip them in xvid format...
untill now i have been doing 1 pass encoding but now i was learning into two pass encoding and quantizer settings..
I record videos @ 12mbps (720x576) and so far after experimenting encoding at various bitrates I am not able to get the quality at any bitrate lower than 2200-2500kbps (i wanna do quality @1500kbps max)
filters used : de-interlace, croping, resize (width-640 and suitable height), smart smoother & msharpen.
i didnt understand the thing is that where shud i alter the quantizer values
check out my settings and tell me where shud I change my settings
http://maxupload.com/img/87E44C69.jpg
http://maxupload.com/img/0E6DC03B.jpg
http://maxupload.com/img/89F225E5.jpg
http://maxupload.com/img/9B03799D.jpg
also check out my other xvid settings :
http://maxupload.com/img/5E2E0E91
http://maxupload.com/img/24362D1C.jpg
http://maxupload.com/img/729B6E28.jpg
Normally a Video of 3 to 4 mins shud not go above the size of 40-50 MB (audio 128kbps-CBR) ... but my files go well above 60 MB to 70 or 80 MB (in Single pass encoding) :(
I hope u will help me out with my queries and also guide me with ur suggestions :o
eagerly waiting for ur reply,
Regards.
HeadBangeR77
3rd February 2007, 03:00
1) The hard and recommended way (:p)
- read the main XviD guide on the Doom9.org website,
- after that search here for XviD's presets threads (there are two of them, the long working thread with whole lot of useful information, and the shorter one, with the last revison of presets).
2) Some tips, just rules of thumb:
1500-1800 kbps for 640x??? should be enough to do a very decent 2-pass encode.
a) In the 1st window set the min. quantizer to 2, instead of 1, and the maximum to 5, 4 for I-frames (2,4,2,5,2,5).
b) In the 2nd window go to Zone Option, select Quantizer 3.0 instead of Weight 1.0, select "Begin with Keyframe" and "Chroma Optimizer".
c) In the 3rd window, under "Overflow" option, set strength to 0, improvement to 8, degradation to 4 (0,8,4). Under "Curve Compression" set 5 and 5 (I don't know your source, so it's a safe curve modulating).
d) Go back to the 2nd window, click on more, and select:
- Motion Search Precision 5
- VHQ 1, VHQ on b-frames, Chroma ME, Turbo
That's the first pass. It's a so called hybrid first pass: will run faster than a full first pass, but slower than the default fast first pass. It will gather more information for the 2nd one, thus improving quality, hopefully. The settings for the 2nd pass differ a bit:
e) Gosh, the options described under a) and c) have no influence in the first pass, and should be set as described in a) and c) for the 2nd pass.
f) In the 4th window set the desired filesize in kilobytes, and under Zone Options leave "Weight 1.0", but tick "Begin with keyframe" and "Chroma Optimizer". The quality profile should be user defined, since we're setting everything manually now.
g) 5th window: MSP=6 (as it is now), VHQ at least 2 (4 will slower the encoding, but is always the best quality-wise), VHQ for b-frames, Chroma ME, no Turbo! In the second tab plz check, if the settings are similar to those described under a).
h) Then tack QPEL, unless your standalone can't handle it (if so, uncheck it for the first pass as well), B-frames 2/1.62/0 respectively (the same for the first pass - excuse the mess, but I'm goinf from window to window, and some of those option are valid for both passes, some only for the 2nd one).
What application do you use for your encodings? You have a custom quantization matrix selected there, and I haven't got the faintest idea which, 'cause there is above hundred of them. Also plz tell me the desired filesize and length.
cheers,
HDBR77
PS. To make it clearer : apart from b), d), f) and g) the rest of the settings (like quantization type /matrix, B-frames) should be set the same for both passes.
badshah
3rd February 2007, 18:01
^^ Thanks a lot for ur reply and help.
I use virtualdub for my encoding. I use Didee's 6of9 matrix or I use Bulletproofs High Quality Matrix (I have no Idea what this matrix do but its better than using H.263 I guess :o)
I was confused a lot while reading so many posts and threads.. but ur post has given me some direction... thanks again :).
HeadBangeR77
4th February 2007, 02:40
^^ Thanks a lot for ur reply and help.
You're welcome.
I use virtualdub for my encoding.
The latest stable one or the "experimental" 1.7.0? I've been using the latter for a few months and never had any problems with it so far.
I use Didee's 6of9 matrix or I use Bulletproofs High Quality Matrix (I have no Idea what this matrix do but its better than using H.263 I guess)
At higher bitrates, though high bitrates are a broad term (depends on the source and the resolution you use), yes, definatley. If you encode at resolutions 640x???, with target bitrate about 1500kbps, then (again, a rule of thumb):
- for 4:3 I would recommend matrices like: Soulhunter's V6 (sort of replacement for the standard MPEG), HVS Best, Sharktooth's V3 HR, Heini's MR (modded version of the previous one, my personal favouirite ;)) or even Soulhunter's V3;
- for 16:9 or 1:2.35 source I would give Didee's SixOfNine, Didee's SixOfNine HVS or Heini's SixOfNine a try.
These are those I know the best. I've used no more than twenty so far, some of them just a few times, some of them very often.
I was confused a lot while reading so many posts and threads.. but ur post has given me some direction... thanks again :).
Glad to hear my nightly mumbling up there was of any use. ;) I haven't written anything wrong, as I'm reading through it now, yet both passes were mixed together.
good luck with your encodes! :)
badshah
4th February 2007, 23:24
The latest stable one or the "experimental" 1.7.0? I've been using the latter for a few months and never had any problems with it so far.
VirtualDub MPEG 2 - version 1.6.15 :)
At higher bitrates, though high bitrates are a broad term (depends on the source and the resolution you use), yes, definatley. If you encode at resolutions 640x???, with target bitrate about 1500kbps, then (again, a rule of thumb):
- for 4:3 I would recommend matrices like: Soulhunter's V6 (sort of replacement for the standard MPEG), HVS Best, Sharktooth's V3 HR, Heini's MR (modded version of the previous one, my personal favouirite ;)) or even Soulhunter's V3;
- for 16:9 or 1:2.35 source I would give Didee's SixOfNine, Didee's SixOfNine HVS or Heini's SixOfNine a try.
the source is always 720x576 after that I crop top bottom borders, then I resize it to 640 width.... latest video was 640 x 292 ... it always depends upon the black borders on top and bottom. I tried V3 HR .... it seems to be good I will continue with that one as of now. :)
btw, have u tried avisynth? is it better than VduB ?? or is it just another GUI like VDUB??
HeadBangeR77
5th February 2007, 02:49
btw, have u tried avisynth? is it better than VduB ?? or is it just another GUI like VDUB??
Plz, search at least once this time. AviSynth could be understood as sort of a "video-language" (very simplistic, yet describes it rather good imo). Every program I use, every GUI I use, I feed 'em with AVS scripts with whole bunch of different transforming a processing functions inside.
like:
# PLUGINS
LoadPlugin("C:\Program Files\GordianKnot\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\LoadPluginEx.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\DctFilter.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\FFT3dGPU.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\MaskTools.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\RemoveGrain.dll")
LoadPlugin("C:\Program Files\GordianKnot\AviSynthPlugins\WarpSharp.dll")
# SCRIPTS
Import("C:\Program Files\GordianKnot\AviSynthPlugins\DeBlock_QED_mt2.avs")
Import("C:\Program Files\GordianKnot\AviSynthPlugins\BlindDeHalo3_mt2.avs")
Import("C:\Program Files\GordianKnot\AviSynthPlugins\Soothe_mt2.avs")
Import("C:\Program Files\GordianKnot\AviSynthPlugins\LimitedSharpenFaster.avsi")
# SOURCE
mpeg2source("I:\DVD\VTS_01_PGC_01_1.d2v", idct=7)
# TRIM
#trim(0,205325)
# DEBLOCKING
DeBlock_QED_mt2(quant1=18,quant2=24,aOff1=2,bOff1=2,aOff2=4,bOff2=4)
# CROPPING
crop(4,58,712,360,true)
# DENOISING
fft3dgpu(sigma=0.5,bt=3,plane=0,mode=1,degrid=1.0)
# DEHALO
BlindDeHalo3(PPmode=-3,PPlimit=4)
# SHARPENING & SMOOTHING
dull = last.LanczosResize(1024,432)
sharp = dull.LimitedSharpenFaster(ss_x=1.5,ss_y=1.5,dest_x=1024,dest_y=432,strength=100)
Soothe(sharp,dull,77)
and that's not an extreme example ;)
badshah
9th February 2007, 10:36
I understood many things in xvid presets but still a few concepts I wud like to understand
http://maxupload.com/img/89F225E5.jpg
I dint understand anything in above ... how it works?
and in below I didnt understand BVOP sensitivity concept and BVOP option in next image too
http://maxupload.com/img/729B6E28.jpg
http://maxupload.com/img/24362D1C.jpg
HeadBangeR77
9th February 2007, 12:13
Hi ;)
This time I'm gonna point to:
http://www.doom9.org/index.html?/divx-encoding.htm
(a bit outdated, and doesn't go too much into details)
and
http://www.divx-digest.com/articles/xvid_setup_page1.html
(so-so, imo...)
The best faq/guide I've read is unfortunately down, at least the webpage doesn't work for me.
The settings usually do what they mean. :D
* BVOP sensitivity - the higher, the more B-frames will the codec try to use to aid the compression.
* B-frame quantizer = an average from the neighbouring P-frames, multiplied by ratio + offset, e.g.
If P-frames are Q4, then B-frame Q is:
((2 x 4) /2) x 1.5 + 1 = 7
with the default settings or
((2 x 4) /2) x 1.62 + 0 = 6.48 - probably will be rounded down to 6 (at least my experience tells me so).
* Curve compression is a broad topic, and opinion differ, yet the options mean exactly what is written there + there are good tooltips, when you move your mouse over the option's fields. The codec makes decisions based on the statistics from the 1-st pass: takes the given percentage from scenes with the highest bitrate and distributes the bits over other frames; takes the given percentage from all frames and gives the bits to scenes with the lowest bitrate.
That's all for now - I must be going ;)
badshah
9th February 2007, 13:55
thx for ur reply again ...
The best faq/guide I've read is unfortunately down, at least the webpage doesn't work for me.
can u post the link for that page? I also hope that link becomes up soon :)
HeadBangeR77
10th February 2007, 12:31
thx for ur reply again ...
;)
I've been busy recently, haven't answered your PMs yet...
can u post the link for that page? I also hope that link becomes up soon :)
Sure, it was/is a very detailed FAQ, again a bit outdated, but still the best I could find in the web.
http://ronald.vslcatena.nl/docs/xvidfaq.html
cheers
FishTank
13th February 2007, 12:51
heres a silly question.
how long is the first pass supposed to take? lol
mine takes 205 minutes. yikes!
i used the settings above with the suggestions from headbanger77.
its a 96min huffyuv vid (720x560) and encoding on a p4 3gig HT, but vdub only uses 50% cpu :(
(sorry for taking the thread OT)
HeadBangeR77
13th February 2007, 13:21
heres a silly question.
how long is the first pass supposed to take? lol
mine takes 205 minutes. yikes!
Depends on the length of your material and codec's settings (not to mention avisynth's filters, but I assume you're not using any that would influence the encoding speed). You could turn off Qpel in the first pass (only), that would result in so insignificant difference in quality, that it only matters for freaks like me. ;) And the speed would be at least 20% higher.
its a 96min huffyuv vid (720x560) and encoding on a p4 3gig HT, but vdub only uses 50% cpu :(
(sorry for taking the thread OT)
Koepi's XviD 1.1.2 is single-threaded, and I don't have any dual core systems, but browse the forum for some hints - I think there are some compilations out there with support for dual-core CPUs.
cheers,
HDBR77
FishTank
13th February 2007, 13:30
thx for the quick response :)
i dont use any filters and dont even know what qpel is or where
to find it LOL. yes im a n00b :D
i was just looking for a ball park figure and since your post wasnt
like OMG 205 minutes!!! i guess thats not of the deep end then =)
makes sense bout the codec. didnt know there are different
compilations around. will look into it thx :)
i usually encode on the fly when capturing with single pass and
352x288 (cant do it with higher res or it starts to drop frames).
all it takes then is 10 minutes to encode the audio to mp3 and
doing a direct stream copy for the vid.
i take speed over quality for most captures lol.
thx again :)
HeadBangeR77
13th February 2007, 14:00
i was just looking for a ball park figure and since your post wasnt
like OMG 205 minutes!!! i guess thats not of the deep end then =)
On my old system (Athlon XP-M, 11x220 - ain't that bad even nowadays) I could encode with 20-30 fps and medium quality (from my pov), or with 10 fps and high quality, and since I'm a quality freak it the answer is obvious. :)
Much depends on the resolution as well, for instance your encoding on-the-fly in 352x288 is much faster than e.g. my 720x304 wide-screen rips, much faster than encoding at DVD resolution and whole lot faster than upsizing.
Have you tried 2-pass or 1-pass with the given settings?
You could, as already said, turn off QPEL in the first pass by 2-pass encoding, and lower the VHQ from 4 to 1 for the 2nd pass. Have a look at the XviD's presets: there's always a faster and slower profile there to choose. ;)
FishTank
13th February 2007, 14:25
yeah im trying to get the best quality out of this one. its a 20
year old vhs i captured. no dvd available etc.
i was surprised how good the quality of the tape still was.
i dont mind waiting 10 hours if the quality is great, but if i cant
see a differents, i might aswell go the 3 hour 1-pass route :lol:
well i know more once this job is finished and i actually get to
see a result hehe.
thx m8 :)
Selur
14th February 2007, 07:17
In the 3rd window, under "Overflow" option, set strength to 0, improvement to 8, degradation to 4 (0,8,4).
Where does this especially the strength value come from?
Personally I would recommend to better set strength a bit higher than the default to be sure that Xvid hits the filesize more precise.
Cu Selur
HeadBangeR77
14th February 2007, 12:21
@ FishTank
You're welcome. I wouldn't have a need to explain things, if we had at least one complete guide I could link to, but we don't. ;)
@ Selur
From 3 different sources, and it works, at least for me.
1) Since we haven't heard anything from Syskin or Koepi for a long time, I think I might rely on Didee then:
http://forum.doom9.org/showthread.php?p=784273#post784273
2) I think that setting the strength to "0" doesn't turn the function off, since the tool-tip from the Vfw-version says: "0 -default from core (let XviD decide)", so I imagine we leave it up to codec to decide, instead of defining a certain percentage (e.g. 5-10%) on per frame basis, hence modulating codec's decisions.
3) With the value I've given I've never had an undersized (nor oversized) encode, unless it clearly resulted from quantizers' restrictions for the 2nd pass, what happens very seldom.
Btw. what are your experiences with overflow control strength then? I'm trying to gather people's opinions on settings, which are rarely even touched by most of users.
cheers,
HDBR77
Blue_MiSfit
16th February 2007, 02:56
If you're capturing from a VHS tape, you should really capture to a fast lossless codec like HuffYUV first, and then load this AVI into VirtualDub/AviSynth to do a proper 2 pass. This will result in much better quality than settling for low resolution and reduced features so that you can capture live.
It will take a lot longer, and it may not look a LOT better to you if it's a shite VHS source :D
~MiSfit
badshah
6th March 2007, 22:43
Btw. what are your experiences with overflow control strength then? I'm trying to gather people's opinions on settings, which are rarely even touched by most of users.
cheers,
HDBR77
ya... me too wud love to read and learn more on that subject
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.