Here is what you suggest (it aint good, somewhat jumpy, feel free to improve), [req RT_Stats, GScript, Grunt]
Code:
GSCript("""
Function Katie(clip c,int n,Int WKill) {
c
XMod = c.RT_ColorSpaceXMod
WKill = (WKill + XMod-1) / XMod * XMod # Round UP Will return WRONG SIZE and Error Alert of WKill not multiple of XMod.
Lft=0 Rgt=0
While(Lft+Rgt<WKill) {
LAve=RT_AverageLuma(n=n,x=Lft,y=0,w=XMod,H=0)
RAve=RT_AverageLuma(n=n,x=Width-XMod-Rgt,y=0,w=XMod,H=0)
if(LAve<RAve) {Lft = Lft + XMod}
else {Rgt = Rgt + XMod}
}
Crop(Lft,0,-Rgt,-0)
RT_Subtitle("Lft=%d Rgt=%d",Lft,Rgt,Align=5)
Return Last
}
""")
SCRIPT = "return Katie(ORG,current_frame,WKill)"
AvisourcE("CabaretUncropped.avi")
ORG = Last # Uncropped source (clip2)
WKILL = 16
Crop(WKILL,0,0,0) # Scriptclip can ONLY return same size clip as arg
Return ScriptClip(SCRIPT,Args="ORG,WKILL") # Import ORG clip into Scriptclip (req Grunt)
By the way, you would want to get this working in script before attempting to learn CPP, and implementing.
EDIT: Only left and right implemented.