Log in

View Full Version : Stainless Script MakeMultiPartScripts.avs, help


avinewbie
30th March 2019, 16:19
Hi,
I have used Stainless's wonderful script to split avs script to help speed up encoding whilst in 32bit avisynth2.6 which worked well.:thanks:

Now on a 64bitPC,win7HP,installed 64bit AVS+ and AVSPmod.I have the needed DLL's installed in C:\Program Files (x86)\AviSynth+\plugins64.
Most of what I need works(qtgmc,etc)
But Unfortunately, the magic script MakeMultiPartScripts.avs requires GScript--no 32 bit version as far as I can tell.
Version() gives: avisynth+0.1(r2772)
Is there any solution to using the script?--(that is not too complicated for newbie to implement? )
thanks
merah

StainlessS
30th March 2019, 17:01
Just comment out the lines

#GScript("""
...
#""")

Same with any GScript script on AVS+.

Below requires Gscript(v2.58/v2.60.Std) ::: OR ::: Avs+/Avs Neo.

MakeMultiPartScripts.avs [Requires most any version of RT_Stats to generate the multipart scripts, not needed during encode of the multipart scripts]

# MakeMultiPartScripts.avs
#######
PARTS=4 # Edit as appropriate
#######
myName="MakeMultiPartScripts: "
Assert(PARTS>1,RT_String("MakeMultiPartScripts.avs: PARTS MUST be greater than 1 (%d)",PARTS))
IsAvsPlus=(FindStr(VersionString, "AviSynth+")>0 || FindStr(VersionString, " Neo")>0)
HasGScript=RT_FunctionExist("GScript")
Assert(IsAvsPlus || HasGScript,RT_String("%sNeed either GScript or AVS+",myName))
#######
FSEL_TITLE="Select AVS files"
FSEL_DIR="."
FSEL_FILT="AVS files|*.AVS"
FSEL_MULTI=True
FILE_LIST = RT_FSelOpen(title=FSEL_TITLE,dir=FSEL_DIR,filt=FSEL_FILT,multi=FSEL_MULTI)
Assert(!(FILE_LIST.IsInt && FILE_LIST==0),RT_String("%sUser Cancelled in FileSelector - No action taken",myName))
Assert(FILE_LIST.IsString,RT_String("%sRT_FSelOpen Error=%s",myName,String(FILE_LIST)))

SCRIPT_TMPT = """
PART = %d
PARTS = %d
Import("%s")
FC = FrameCount
Start = ((part==0 ) ? -1 : part * (FC-1) / PARTS) + 1
End = ((part==PARTS-1) ? FC-1 : (part+1) * (FC-1) / PARTS)
End = (End == Start) ? -1 : End
Trim(Start,End)
# Subtitle("Trim("+String(Start)+","+String(End)+")")
Return Last
"""

GS="""
NLINES = RT_TxtQueryLines(FILE_LIST)
for(i=0,NLINES-1) {
PARTSNAME = RT_TxtGetLine(FILE_LIST,i)
for(part=0,PARTS-1) {
PartName = RT_String("%s_PART_%d.avs",PARTSNAME,part+1)
ScriptInst=RT_String(SCRIPT_TMPT,part,PARTS,PARTSNAME)
RT_WriteFile(PartName,"%s",ScriptInst)
}
}
"""
HasGScript ? GScript(GS) : Eval(GS) # Use GSCript if installed (loaded plugs override builtin)

MessageClip(RT_String("ALL DONE, Processed %d avs files of %d parts each",NLINES,PARTS))

UPDATED:

EDIT: A few comments from users in another thread.
I did a quick test with four instances of Virtualdub, setting CPU affinity in Windows task manager. On a CPU heavy script I went from approximately 3 fps single-threaded to 4 fps combined. The downside is that the system became unresponsive. My CPU is a i5-2500k.

Set each encoder instance's priority to "Low" (Task Manager) / "Idle" (Process Manager (https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx)) / "LOW" (cmd.exe's "start" command when using x264 etc.).

@jriker1

I thought I had a problem (bug) with RT_FSelOpen due to the previous MakeMultiPartScript.avs but turns out not a bug.
I was using Media Player Classic - Home Cinema to open, and if I clicked Cancel then it would immediately bring up another File Selector.
Thought was bug in RT_FSelOpen but seems that MPC-HC will immediately retry because of Assert() alert (due to user Cancel) without any
frames being delivered from script. Does not happen with other players and seems that MPC-HC is just trying to be helpful in re-starting what
it thinks is glitch in the system. Anyway, just pointing it out if you use MPC-HC (just updated to latest stable and still does it), but does not
happen in other players that I've tried.
So because of above quote, to generate the individual multipart scripts, dont use with MPC-HC,
and also dont use with AvsPMod (weird things happen, AvsPMod inserts filename into script [any script using RT_FSelOpen] and buggers up further script functionality).
Ideally use any other player (other than MPC-HC) except VLC (which dont work with avs , leastwise the one I use dont work), or use VDub2.

avinewbie
31st March 2019, 09:46
Hi Stainless

The new script works beautifully.You sir are a wizard:thanks:
With my old i7 920 the 4 splits in MEGUI get me close to 98% CPU load .
It is so much faster.
Sincere thanks

StainlessS
26th April 2019, 11:06
Script in post #2 updated, for avs v2.58/v2.6 with GScript, or Avs+/Avs Neo x86 or x64.

All D9 posted instances of script updated.

StvG
28th April 2019, 04:50
Is it possible splitting on I frames when ffms2 is used? Something like mkvtoolnix splitting - the end of x part is just before I frame and the start of x+1 part from I frame.

StainlessS
28th April 2019, 12:06
Let me think bout that.
My initial thought is separate (but similar usage) script, where "NewMakeMultiPartWhatsit()" will set some specifically named Global variable to eg MultiPart_FFMS2_IFrames_Glb="Sausages",
Where in your source script YOU must enable the ffms2 IFrame stuff [when VarExist("MultiPart_FFMS2_IFrames_Glb")] so that is available to scan frames in the make multi part thing.
If no I frames found, throw error.
Your script would require Avs+ VarExist or RT_VarExist.
[EDIT: Your script might want to use separate routine just for the find I frames stuff, we have to use your script to cope with your eg Trim()'s.]

You see any probs there (long since I used ffms2 Iframes stuff).

EDIT: If I do this, I guess we need new thread for it.

EDIT: New Thread here:- https://forum.doom9.org/showthread.php?p=1873782#post1873782

StvG
29th April 2019, 01:10
Sounds good.