Below a bit of code to show cropped DAR (Display Aspect Ratio) and also signal to MeGUI.
Req, RT_Stats.
Code:
AvisourcE("CabaretUncropped.avi")
FULLFRAME_DAR = 4.0/3.0 # Display Aspect Ratio of FULL FRAME
SAR = Last.RT_GetSAR(FULLFRAME_DAR) # Gets Sample (pixel) Aspect Ratio from full frame DAR Display Aspect Ratio.
RoboCrop(WMod=4, Laced=false, debug=true)
DAR = Last.RT_GetDAR(SAR) # Gets cropped DAR Display Aspect Ratio from SAR, Sample (pixel) Aspect Ratio.
RT_SignalDAR(DAR) # Signal DAR to MEGUI.
# Sets Global vars MeGUI_darX and MeGUI_darY which are read during MEGUI loading of AVS file.
RT_DebugF("Cropped DAR = %.3f",DAR,name="ShowDAR: ") # To DebugView
RT_Subtitle("Cropped DAR = %.3f",DAR,align=5)
NOTE, Dont miss post #45, RoboCrop is updated today.
EDIT: For Cabaret shows "Cropped DAR = 1.808".
EDIT Added explicit Last in places, might not be obvious that it is using clip to calc DAR and SAR.
EDIT: Above RT_ Aspect ratio functions converted from script, below original script
Code:
Function GetCropDAR(clip c,float DAR,float "X",float "Y",float "W",float "H") {
# Call prior to Crop/Resize with (possibly fractional) cropping to calc resultant DAR, X,Y,W,H are cropping coords
# DAR = FAR * SAR ::: FAR = DAR / SAR ::: SAR = DAR / FAR
#
X=Float(Default(X,0.0)) Y=Float(Default(Y,0.0)) W=Float(Default(W,0.0)) H=Float(Default(H,0.0))
W=W<=0.0?c.width+W-X:W H=H<=0.0?c.height+H-Y:H
# Irrespective of what various resizers in various Avisynth versions silently correct, we dont allow eg -ve X
Assert(X>=0.0&&X < c.width, "GetCropDAR: Invalid X("+String(X)+")")
Assert(Y>=0.0&&Y < c.height,"GetCropDAR: Invalid Y("+String(Y)+")")
Assert(W> 0.0&&X+W<=c.width, "GetCropDAR: Invalid W("+String(W)+")")
Assert(H> 0.0&&Y+H<=c.height,"GetCropDAR: Invalid H("+String(H)+")")
Return c.GetSAR(DAR) * W / H
}
#--------------
# From MeGUI Wiki:
Function GetDAR(clip c, float SAR) { return Float(c.width) * SAR / Float(c.height)} # Gets the DAR from the SAR
Function GetSAR(clip c, float DAR) { return DAR * Float(c.height) / Float(c.width) } # Gets the SAR from the DAR
Function SignalDAR(float DAR){ # Signal DAR for MEGUI (Name change from SetDar)
Assert(DAR>0.0, "SignalDAR: Error, DAR must be greater than zero")
Global MeGUI_darx=Round(1000*DAR) Global MeGUI_dary=1000
}
Function SignalDAR2(int DARX,int DARY){
Assert(DARX>0 && DARY>0, "SignalDAR2: Error, DARX and DARY must be greater than zero")
Global MeGUI_darx=DARX Global MeGUI_dary=DARY
}
Cropping keeps original SAR. Resizing (without crop) keeps original DAR.