Advanced Multi-threading

From Automkv

Jump to: navigation, search

Contents

WARNING

READ THIS NOW!!!! Using this tweak DOES NOT offer a significant advantage in speed. The loss of stability is just too great. I have lost far to many encodes to MT mode crashing xvid and x264. There for I cannot recommend this as a reliable option anymore.

But I'll leave this here so if you want to be brave and try it, go ahead.

However, I can recommend editing the base.avs file to use some more advanced avs script such as Seesaw (the proper way).

I am ONLY keeping this here as a reference. That does not mean that you should in any way try to use SetMTMode with your script (unless you know what your doing).

This page is still good for seeing were to add extra filters and whatnot (under #test5) since doing that I still think is a good idea.

Advanced Multi-Threading

This is an advanced tweak designed to give more speed to the encoder by using whats called the "SetMTMode" command. This will be added to the base.avs file in the "AutoMKV/exe/filter folder. This only applies if you have a dual core, quad core (lucky mofo) or a hyperthreaded CPU (so hyperthreaded P4's can do this too) MAKE A BACKUP of your base.avs file in the automkv/exe/filter folder first. If anything goes wrong just revert back to the original.

  • NOTE This tweak is unstable and may cause xvid_encraw or x264 to crash or freeze.

However, the benefits of trying this can be a lot on dual core, quad core, or hyperthreaded machines.

I've done some testing and have found a sort of stable code to replace what is in the base.avs file but first a few other changes are needed.

You'll need Avisynth 2.5.7 and the special MT0.7 avisynth.dll To this date (4/15/07), MT_07 was the latest version. You'll need to extract the zip file and copy the avisynth.dll to your windows/system32 folder and overwrite the old one. You don't need to worry about the MT.dll because that is already in the filters folder of automkv.

The following method is neither ideal nor perfect however I think that the good outweighs the bad here.

Code

Your gonna open up your base.avs file in "AutoMKVxxx/exe/filter" (where xxx is the version number) and copy and paste the following into it, overwriting the old stuff.

#loadpluginstart

#test1
Setmemorymax(768) #or 512, depending on how much ram you have. NOTE: encoder WILL use more then this number.
SetMTMode(2, 0) # 2 is the MT mode and 0 is the number of threads. 0 means auto detect, use 3 for dual core, 6 for quad core, works on HT P4's.

#loadpluginend

#importstart

#test2

#importend

#herethesource

#filter1start

#test3

#filter1end

#cropstart

cropclip = autocrop(movie,mode=0,wmultof=4,hmultof=4,samples=40,aspect=0,threshold=34,samplestartframe=0)
fixed_aspect = aspectratio
c_width = width(cropclip)
c_height = Round(height(cropclip) / fixed_aspect)
input_par = float(float(c_width)/float(c_height))
input_par = input_par > 1.4 ? input_par : (4.0/3.0)
out_width = outwidth
out_height = Round(float(out_width) / input_par)
hmod = out_height - (floor(out_height / 16 ) * 16)
out_height = (hmod > 4) ? (out_height + (16 - hmod)) : (out_height - hmod)
new_aspect = (float(out_width) / float(out_height)) / fixed_aspect
autocrop(movie,mode=0,wmultof=4,hmultof=4,samples=40,aspect=new_aspect,threshold=34,samplestartframe=0)

#cropend

#resizestart

#test4

#resizeend

#filter2start

#test5
Insert Filer Here (or select through AutoMKV, it will get MTed either way)

#filter2end 

Well, it seems that I've even simplified it more. Have NO idea why I didn't try this one from the start but I ran through a quick encode and it seems stable. If you get stability problems, then go back to the old one with the SetMTMode(0) and MT("Filter") in their respective places.

Furthermore, I added a Setmemorymax() parameter to the above that might speed up some stuff. You'll want to make sure you know how much RAM windows needs in the background first. Set this number to anything you want (more then half your RAM probably) but MAX use 1024mb. For 2GB of ram, ~768-1024 works well and leaves room for background stuff. Otherwise, avisynth would use half your total amount of FREE ram. With this, you can force it to use more which speeds things up.

512 and 768 are good numbers. On small encodes (>5 minute files, this number really has no effect on speed)

Use to be more here but you don't need it any more. Just select the filter through AutoMKV, like good old times. Or just write up your own.

Benefits

This is all irrelevant now!! (script is too unstable, and the benefits aren't really that great)

The benefits of using this will be obvious the first time you use it in AutoMKV (if it doesn't crash or fail in some way...so cross your fingers). The speed you gain on dual core machines, especially during the first pass in xvid can be enormous. Personally, I've gone from ~25fps to 40+fps and it finishes in almost have the time. However the second pass doesn't gain as much but it might gain a few more fps then the normal script.

Give it a shot, worst that happens is it crashes and you revert to the original (you can keep the custom avisynth.dll though, no harm in that)

The true benefits of this shine when using very heavy CPU filters such as HybridFuPP or fft3dfilter. MT can double the framerate of fft3dfilter.

You only really see a speed improvement when your using lots of filters and your using xvid. x264 seems to multi-thread itself better.

Issues

As I have stated earlier, there are several issues with using this method. Not all filters are compatible with the SetMTMode(2) command but mode 2 is the most compatible mode with the most filters that gives the greatest speed boost. So it's a trade off kinda thing with mode 2 being probably the best.

The main problems with using MT is that

  • Not all filters work with it
  • Can be unstable
  • Sometimes complicated to use
  • Doesn't affect some filters

buzzqw said that he might add in a few MT features into AutoMKV but for now this is the only way to gain some SPEED!!! Personally, I've found that with a partly film source with a hybrid field order does not gain much if anything from using this however, it doesn't cause the script to crash either so you can still use it as far as I know.

Good Luck and happy Speeding... :-)


Updates

UPDATE #2: Simplest script EVER. Unstable but try it. Update #3: This tweak ain't worth it.


Personal tools

sl
טבעות אירוסין, יהלומים  ברלין הדרכות בעברית  יהדות בברלין הדרכות  ברלין המורשת היהודית הדרכות  ברלין ארכיטקטורה הסטוריה הדרכות  וילות בגליל  נדלן בגליל  התיישבות בגליל  ישובים קהילתיים בגליל