View Single Post
Old 14th June 2016, 23:54   #58  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
All four sides.
Code:
GSCript("""
    Function Katie(clip c,int n,Int WKill,Int HKill) {
        c
        XMod = RT_ColorSpaceXMod  # Left and Right scan Width : eg 1 for RGB, 2 for YV12 & YUY2
        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}      # Lft is darker than Rgt
            else if(RAve<LAve)  {Rgt = Rgt + XMod}      # Rgt is darker than Lft
            else if(Lft<Rgt)    {Lft = Lft + XMod}      # Lft and Rgt same AveLuma AND Lft < Rgt
            else                {Rgt = Rgt + XMod}      # Lft and Rgt same AveLuma AND Rgt <= Lft            
        }
        YMod = RT_ColorSpaceYMod(Laced=False)   # Top and Bot Scan Height : eg 1 for RGB and YUY2, 2 for YV12
        HKill = (HKill + YMod-1) / YMod * YMod  # Round UP  Will return WRONG SIZE and Error Alert of HKill not multiple of YMod.
        Top=0   Bot=0
        While(Top+bot<HKill) {
            TAve=RT_AverageLuma(n=n,x=0,y=Top,w=0,H=YMod)
            BAve=RT_AverageLuma(n=n,x=0,y=Height-YMod-Bot,w=0,H=YMod)
            if(TAve<BAve)       {Top = Top + YMod}      # Top is darker than Bot
            else if(BAve<TAve)  {Bot = Bot + YMod}      # Bot is darker than Top
            else if(Top<Bot)    {Top = Top + YMod}      # Top and Bot same AveLuma AND Top < Bot
            else                {Bot = Bot + YMod}      # Top and Bot same AveLuma AND Bot <= Top             
        }
        Crop(Lft,Top,-Rgt,-Bot)
#       RT_DebugF("Lft=%d Rgt=%d : Top=%d Bot=%d W=%d H=%d",Lft,Rgt,Top,Bot,Width,Height,name="Katie: ")
        RT_Subtitle("Lft=%d Rgt=%d : Top=%d Bot=%d",Lft,Rgt,Top,Bot,Align=5)
        Return Last    
    }
""")

SCRIPT = "return Katie(ORG,current_frame,WKill,HKill)"   # We use ORG clip and simply discard the dummy clip (dont use it for anything)
#####################################
### Katie's Config Below
#Avisource("CabaretUncropped.avi")
mpeg2source("001.d2v")
bob(b=0,c=1)
selecteven()
#
WKILL = 16
HKILL = 0
#####################################
### Katie Hands off below
ORG = Last  # Uncropped source (clip2)
Dummy=Crop(WKILL,HKILL,0,0)                               # Scriptclip can ONLY return same size clip as arg, so we create dummy clip
Dummy.ScriptClip(SCRIPT,Args="ORG,WKILL,HKILL")    # Import ORG (full uncropped) clip into Scriptclip (req Grunt)
### Katie's Postscript
simpleresize(352,240)
###
Return Last
EDIT:
Quote:
I... have no idea what that is or what I'm supposed to do with it...
Change
Code:
 
Avisource("CabaretUncropped.avi")
to whatever you want, it implements your suggested functionality.

WKILL and HKILL are total Width and Height pixels to crop. (Just try it and stop belly aching )

EDIT: Put RT_Stats, GScript and Grunt in Plugins directory, run script.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2016 at 01:02. Reason: Update
StainlessS is offline   Reply With Quote