View Full Version : Suggestions for improvements?
Frexxia
2nd April 2026, 03:06
Lately I've been trying to hone my script for encoding DVDs like Stargate SG-1 and various Star Trek shows
This is what I've eventually ended up with after a lot of tinkering:
TFM(mode=0,pp=1,slow=2).TDecimate(mode=0,hybrid=1)
#- mode=0 since I can't stand stuttering
#- hybrid=1 for the same reason
#- I would eventually like to do VFR, but it's such a pain. Plus there aren't that many 30 fps sections.
fmtc_bitdepth(bits=32)
c = BilinearResizeMT(%source_width%, %source_height%*3/2, prefetch=8,range=0)
nn = c.nnedi3cl(field=-2,nns=4,nsize=3,qual=2,pscrn=0)
dbl = mt_average(selecteven(nn),selectodd(nn),U=3,V=3)
dblD = mt_makediff(c,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
DD = shrpD.repair(dblD,11)
dbl.mt_adddiff(DD,U=3,V=3)
DeBilinearResizeMT(%source_width%, %source_height%, prefetch=8,range=0,accuracy=2)
# This is essentially daa3mod for decombing (my primary goal) and antialiasing, but with some changes:
#- Highest possible quality nnedi3 options
#- Repair mode 11 instead of 13
#- Debilinear to undo the initial bilinear upscale
# The result is very sharp
fmtc_bitdepth(bits=16,dmode=8,patsize=1024,dyn=true,tpdfo=true,tpdfn=true)
# Need to sacrifice precision here because QTGMC cannot operate on float (because of mvtools)
QTGMC(preset="Placebo", InputType=1,sharpness=0.2, tr1=1, tr2=0, NoisePreset="Slower",SubPel=4,BlockSize=8,Refinemotion=true,search=3,searchparam=4,pelsearch=4)
# Goal is image stabilization and artifact removal while introducing a minimum of temporal artifacts and preserving as much noise as possible. Ideally I wouldn't want any temporal filters at all, but I don't see any way around it.
fmtc_bitdepth(bits=10,dmode=8,patsize=1024,dyn=true,tpdfo=true,tpdfn=true)
I'm reasonably happy now, but I'm also fairly new to Avisynth. So I'd be grateful for any input.
Obviously many options here can be viewed as "overkill", but I'm still encoding at 50% real time.
If performance of QTGMC still too high - you can try functions from M_QTGMC wrapper. But you need to pass the 'special' params you need to underlying QTGMC. Or make a manual script part like
ps1=QTGMC(params_set1)
ps2=QTGMC(params_set2)
ps3=QTGMC(params_set3)
ps4=QTGMC(params_set4)
GetSharpest(ps1, ps2(.., ps3, ps4)
The MAnalyse fails in different ways with different settings (and also different prefiltering in QTGMC) so user can attempt to run several different versions of QTGMC with different motion analysis params and process results for getting better output (like with GetSharpest simple function or others). Typical params variations for mvtools you can see in M_QTGMC presets. Most typical different results are produced with blcksize 8 or 16 and truemotion true or false. Search method also may make some difference. It is easy to collect many combinations of even few params variations to get 10..100+ times slower processing.
For 'max source match' processing of the resulted clips ps1..psN with 'src' may be possible to make simple Expr-based function or simple compiled filter like SelectBestMatchingSource() like:
Function SelectBestMatchingSource(clip src, clips vector ps1..psN)
{
select sample from ps1 to psN clip with best similarity metric (lowest absolute difference for sample-granularity) with src source clip
}
Also you may try to play with Source Match / Lossless settings in the QTGMC (see http://avisynth.nl/index.php/QTGMC ).
Frexxia
4th April 2026, 04:14
If performance of QTGMC still too high - you can try functions from M_QTGMC wrapper.
Unfortunately I'm already CPU bound because of QTGMC. Presumably because mvtools is quite slow.
But you need to pass the 'special' params you need to underlying QTGMC. Or make a manual script part like
ps1=QTGMC(params_set1)
ps2=QTGMC(params_set2)
ps3=QTGMC(params_set3)
ps4=QTGMC(params_set4)
GetSharpest(ps1, ps2(.., ps3, ps4)
The MAnalyse fails in different ways with different settings (and also different prefiltering in QTGMC) so user can attempt to run several different versions of QTGMC with different motion analysis params and process results for getting better output (like with GetSharpest simple function or others). Typical params variations for mvtools you can see in M_QTGMC presets. Most typical different results are produced with blcksize 8 or 16 and truemotion true or false. Search method also may make some difference. It is easy to collect many combinations of even few params variations to get 10..100+ times slower processing.
For 'max source match' processing of the resulted clips ps1..psN with 'src' may be possible to make simple Expr-based function or simple compiled filter like SelectBestMatchingSource() like:
Function SelectBestMatchingSource(clip src, clips vector ps1..psN)
{
select sample from ps1 to psN clip with best similarity metric (lowest absolute difference for sample-granularity) with src source clip
}
Also you may try to play with Source Match / Lossless settings in the QTGMC (see http://avisynth.nl/index.php/QTGMC ).
Note that I'm using inputtype=1, so lossless wouldn't work. I've experimented with both other inputtypes and sourcematch, but in my experience it just made clean frames so much worse that it wasn't worth it.
Maybe it would be worth it with the kind of approach you're discribing, but I fear it would be extremely slow. (Unless there is a way to use the GPU for mvtools)
real.finder
4th April 2026, 04:41
Note that I'm using inputtype=1, so lossless wouldn't work. I've experimented with both other inputtypes and sourcematch, but in my experience it just made clean frames so much worse that it wasn't worth it.
Maybe it would be worth it with the kind of approach you're discribing, but I fear it would be extremely slow. (Unless there is a way to use the GPU for mvtools)
you can try SRFBob
To make quality better we need more computer work. It is in most cases slower. QTGMC really can try to use hardware MPEG encoder from DX12 for MAnalyse acceleration but may be unstable (with other filters). Sadly that project was not yet debugged for production ready state. Or at least export most wanted already working features in the separate branches. Pinterf promised to export the DX12-ME feature to his mvtools2 version in this year (possibly). Also hardware quality is not as good as full featured MAnalyse onCPU search. The ME from MPEG encoder is of limited quality but it is compensated with some increase of bitrate for a given quality preset.
Several more features from MAnalyse for possibly better quality: trymany=true (refine search around all predictors, will be up to times slower) and temporal=true (use temporal predictor too, will disable MT and somehow decrease performance around MAnalyse filter). But as I see in current version of QTGMC https://github.com/realfinder/AVS-Stuff/blob/Community/avs%202.6%20and%20up/QTGMC.avsi both these settings are not controlled (and not enabled in 'placebo' preset). So to test it we need some addition to the QTGMC script too.
Edit: trymany and temporal for QTGMC added in the update https://github.com/realfinder/AVS-Stuff/commit/156aabfa2aa9613af0e6d893bf54114114a9efc3 and can be enabled manually in addition to 'placebo' preset.
Edit2: QTGMC updated to v.3.390 with RefineMotionAll true/false - if true set thSAD for MRecalculate to 0 to force refine search of all new blocks. Default: false (leave some blocks in the interpolated only state without MV refining attempt as in previous versions).
RefineMotionSearch - search method for MRecalculate separately (may be more simple to have more performance with larger radius). Default: equal to Search.
RefineMotionRadius - search param for MRecalculate (recommended to be > search param for initial MAnalyse). Default: equal to SearchParam.
Current performance test results with PAL DVCAM capture:
at i5-9600K CPU (Prefetch(6)) from starting filter call
QTGMC(preset="slow", BlockSize=8, SubPel=4, Search=3, SearchParam=2, Overlap=4, ChromaMotion=true, GlobalMotion=true, TrueMotion=true, RefineMotion=true) - 38 fps
QTGMC(preset="slow", BlockSize=8, SubPel=4, Search=3, SearchParam=2, Overlap=4, ChromaMotion=true, GlobalMotion=true, TrueMotion=true, RefineMotion=true, trymany=true) - 35 fps
QTGMC(preset="slow", BlockSize=8, SubPel=4, Search=3, SearchParam=2, Overlap=4, ChromaMotion=true, GlobalMotion=true, TrueMotion=true, RefineMotion=true, trymany=true, RefineMotionAll=true) - 25 fps
QTGMC(preset="slow", BlockSize=8, SubPel=4, Search=3, SearchParam=2, Overlap=4, ChromaMotion=true, GlobalMotion=true, TrueMotion=true, RefineMotion=true, trymany=true, RefineMotionAll=true, RefineMotionSearch=3, RefineMotionRadius=8) - 12 fps.
It looks like real forcing of all blocks refining search in MRecalculate really significantly drops performance and the old default thSAD = halfthSAD for MRecalculate causes lots of blocks to be skipped from real refining. Also addition of larger radius search in MRecalculate with all blocks refining forces causes additional significant performance drop.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.