Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th December 2015, 01:09   #41  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,189
I'm using RoboCrop like this to get the auto-crop dimensions
RoboCrop(LogFn="Preview_Temp.txt")

then I run it with avs2yuv.exe

It takes a long time to get the result because it is processing the whole file. Is there a way to just get the coordinates to the file and then stop any further processing?
MysteryX is offline   Reply With Quote
Old 4th December 2015, 01:16   #42  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,054
Quote:
Originally Posted by MysteryX View Post
I'm using RoboCrop like this to get the auto-crop dimensions
RoboCrop(LogFn="Preview_Temp.txt")

then I run it with avs2yuv.exe

It takes a long time to get the result because it is processing the whole file. Is there a way to just get the coordinates to the file and then stop any further processing?
Code:
AVSMeter script.avs -i
Groucho2004 is offline   Reply With Quote
Old 4th December 2015, 01:53   #43  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
Or something like,

Code:
AviSource("Cabaret.avi")
WMOD=4
LACED=False
SHOW=True          # Whatever
DEBUG=True         # DebugView
RoboCrop(WMod=WMOD,Laced=LACED,Show=SHOW,LogFn="Coord.Txt",Debug=DEBUG)
Trim(0,-1)         # Curtail Avs2YUV scan
EDIT:
Produces This coords.txt:
Code:
28 90 668 394 2 2 4 2 720 576 28 89 696 484 2 28 89 696 484
Code:
    LogFn: Default "" (unset). Filename of Log file.
      Will output crop coords, crop coords will be output whether cropping or not (Blank/Show), format as within quotes below.

      '28 92 668 392 2 4 2 4 720 576 27 89 696 484 2 27 89 696 484 '

      Where in order:
        CropX CropY CropW CropH     :  Crop coords mod XMod, YMod, WMod, HMod.
        XMod YMod WMod HMod         :  As used for above crop coords
        Width Height                :  Original frame width and height
        ORG_X1 ORG_Y1 ORG_X2 ORG_Y2 :  Exact coords of found image, not rounded according to x/y/w/h mod (Before User Adjust)
        CropMode                    :  1 = CropLess, 2 = CropMore(default)
        X1 Y1 X2 Y2                 :  Coords after any User adjustments eg ORG_X1+LeftAdd etc and before applying XMod etc.
      All values output are single SPACE separated.


Debugview
Code:
00000174	262.95639038	[2148] RoboCrop: RoboCrop: v1.06 - 22 Apr 2015 - By StainlessS	
00000175	262.95642090	[2148] RoboCrop: Input: Width=720 Height=576 FrameCount=15285	
00000176	262.95642090	[2148] RoboCrop: 	
00000177	262.95648193	[2148] RoboCrop: Thresh defaulting to DEFAULT AUTOTHRESH -40.00	
00000178	262.95651245	[2148] RoboCrop: Potential Auto Credits Skip Start@5%=764 End @90%=13756 : Range=12993	
00000179	262.95654297	[2148] RoboCrop: Skip Start(764) and End(13756) : Range=12993	
00000180	262.95657349	[2148] RoboCrop: 	
00000181	262.95660400	[2148] RoboCrop: Samples=40 Thresh=-40.000 Laced=False Matrix=2	
00000182	262.95663452	[2148] RoboCrop: WMod=4 HMod=2 {Colorspace/Laced Restricted XMod=2 YMod=2}	
00000183	262.95666504	[2148] RoboCrop: RLBT=15 Ignore=0.400 Baffle=4	
00000184	262.95669556	[2148] RoboCrop: ScaleAutoThreshRGB=Yes ScaleAutoThreshYUV=No 	
00000185	262.95669556	[2148] RoboCrop: CropMode=2(CropMore) Blank=No Align=No Show=Yes Log=Yes	
00000186	262.95672607	[2148] RoboCrop: Atm=4.000 SampStart=764 SampEnd=13756 SampRange=12993	
00000187	262.95672607	[2148] RoboCrop: LeftAdd=0 TopAdd=0 RightAdd=0 BotAdd=0	
00000188	262.95675659	[2148] RoboCrop: LeftSkip=0 TopSkip=0 RightSkip=0 BotSkip=0	
00000189	262.95678711	[2148] RoboCrop: 	
00000190	262.98403931	[2148] RoboCrop: AutoThresh   1) [   764] YPlaneMin = 14 (14)	
00000191	263.04266357	[2148] RoboCrop: AutoThresh   2) [  1097] YPlaneMin = 14 (14)	
00000192	263.07455444	[2148] RoboCrop: AutoThresh   3) [  1430] YPlaneMin = 14 (14)	
00000193	263.09149170	[2148] RoboCrop: AutoThresh   4) [  1763] YPlaneMin = 14 (14)	
00000194	263.10733032	[2148] RoboCrop: AutoThresh   5) [  2097] YPlaneMin = 14 (14)	
00000195	263.12109375	[2148] RoboCrop: AutoThresh   6) [  2430] YPlaneMin = 15 (14)	
00000196	263.13745117	[2148] RoboCrop: AutoThresh   7) [  2763] YPlaneMin = 14 (14)	
00000197	263.15515137	[2148] RoboCrop: AutoThresh   8) [  3096] YPlaneMin = 14 (14)	
00000198	263.17474365	[2148] RoboCrop: AutoThresh   9) [  3429] YPlaneMin = 13 (13)	
00000199	263.21542358	[2148] RoboCrop: AutoThresh  10) [  3762] YPlaneMin = 14 (13)	
00000200	263.24392700	[2148] RoboCrop: AutoThresh  11) [  4095] YPlaneMin = 14 (13)	
00000201	263.25967407	[2148] RoboCrop: AutoThresh  12) [  4428] YPlaneMin = 14 (13)	
00000202	263.32559204	[2148] RoboCrop: AutoThresh  13) [  4762] YPlaneMin = 14 (13)	
00000203	263.35232544	[2148] RoboCrop: AutoThresh  14) [  5095] YPlaneMin = 14 (13)	
00000204	263.38153076	[2148] RoboCrop: AutoThresh  15) [  5428] YPlaneMin = 14 (13)	
00000205	263.42202759	[2148] RoboCrop: AutoThresh  16) [  5761] YPlaneMin = 14 (13)	
00000206	263.48983765	[2148] RoboCrop: AutoThresh  17) [  6094] YPlaneMin = 14 (13)	
00000207	263.55682373	[2148] RoboCrop: AutoThresh  18) [  6427] YPlaneMin = 14 (13)	
00000208	263.59436035	[2148] RoboCrop: AutoThresh  19) [  6760] YPlaneMin = 14 (13)	
00000209	263.62008667	[2148] RoboCrop: AutoThresh  20) [  7093] YPlaneMin = 14 (13)	
00000210	263.64840698	[2148] RoboCrop: AutoThresh  21) [  7427] YPlaneMin = 15 (13)	
00000211	263.66235352	[2148] RoboCrop: AutoThresh  22) [  7760] YPlaneMin = 14 (13)	
00000212	263.67373657	[2148] RoboCrop: AutoThresh  23) [  8093] YPlaneMin = 14 (13)	
00000213	263.70022583	[2148] RoboCrop: AutoThresh  24) [  8426] YPlaneMin = 14 (13)	
00000214	263.73031616	[2148] RoboCrop: AutoThresh  25) [  8759] YPlaneMin = 14 (13)	
00000215	263.74728394	[2148] RoboCrop: AutoThresh  26) [  9092] YPlaneMin = 14 (13)	
00000216	263.75781250	[2148] RoboCrop: AutoThresh  27) [  9425] YPlaneMin = 14 (13)	
00000217	263.77706909	[2148] RoboCrop: AutoThresh  28) [  9758] YPlaneMin = 14 (13)	
00000218	263.79431152	[2148] RoboCrop: AutoThresh  29) [ 10092] YPlaneMin = 14 (13)	
00000219	263.81048584	[2148] RoboCrop: AutoThresh  30) [ 10425] YPlaneMin = 14 (13)	
00000220	263.83358765	[2148] RoboCrop: AutoThresh  31) [ 10758] YPlaneMin = 14 (13)	
00000221	263.85678101	[2148] RoboCrop: AutoThresh  32) [ 11091] YPlaneMin = 14 (13)	
00000222	263.86941528	[2148] RoboCrop: AutoThresh  33) [ 11424] YPlaneMin = 14 (13)	
00000223	263.89089966	[2148] RoboCrop: AutoThresh  34) [ 11757] YPlaneMin = 14 (13)	
00000224	263.90399170	[2148] RoboCrop: AutoThresh  35) [ 12090] YPlaneMin = 14 (13)	
00000225	263.92401123	[2148] RoboCrop: AutoThresh  36) [ 12423] YPlaneMin = 14 (13)	
00000226	263.94082642	[2148] RoboCrop: AutoThresh  37) [ 12757] YPlaneMin = 14 (13)	
00000227	263.96194458	[2148] RoboCrop: AutoThresh  38) [ 13090] YPlaneMin = 14 (13)	
00000228	263.98049927	[2148] RoboCrop: AutoThresh  39) [ 13423] YPlaneMin = 14 (13)	
00000229	264.00881958	[2148] RoboCrop: AutoThresh  40) [ 13756] YPlaneMin = 14 (13)	
00000230	264.00885010	[2148] RoboCrop: 	
00000231	264.00888062	[2148] RoboCrop: YPlaneMin=13 : Automatic set Thresh=53.000	
00000232	264.00891113	[2148] RoboCrop: 	
00000233	264.01147461	[2148] RoboCrop: Top   1) [   764]  AveY= 53.14  Y1=177	
00000234	264.01153564	[2148] RoboCrop: Bot   1) [   764]  AveY= 57.44  Y2=484	
00000235	264.01156616	[2148] RoboCrop: Lft   1) [   764]  AveY= 54.72  X1=154	
00000236	264.01162720	[2148] RoboCrop: Rgt   1) [   764]  AveY= 54.73  X2=695	
00000237	264.01531982	[2148] RoboCrop: Lft   3) [  1430]  AveY= 54.32  X1= 28	
00000238	264.01910400	[2148] RoboCrop: Top   5) [  2097]  AveY= 53.28  Y1=110	
00000239	264.02890015	[2148] RoboCrop: Rgt  10) [  3762]  AveY= 63.56  X2=696	
00000240	264.03656006	[2148] RoboCrop: Top  14) [  5095]  AveY= 54.04  Y1= 89	
00000241	264.09036255	[2148] RoboCrop: 	
00000242	264.09039307	[2148] RoboCrop: Active Frames (where image coords first found) = 5	
00000243	264.09042358	[2148] RoboCrop: Sampled ImageEdge:  X1=28  Y1=89  X2=696(W=669,-23)  Y2=484(H=396,-91)	
00000244	264.09069824	[2148] RoboCrop: 	
00000245	264.09078979	[2148] RoboCrop: Crop(ModW/H):  X = 28   Y = 90   W =668(-24)   H =394(-92)	
00000246	264.09085083	[2148] RoboCrop: Constructor Scan Total Time=1.140 secs
__________________
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; 7th January 2019 at 07:09.
StainlessS is offline   Reply With Quote
Old 4th December 2015, 02:21   #44  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,189
Trim(0,-1)

yeah that works.

Oddly enough, I already was using that for another script; somehow I missed that I was already doing it.
MysteryX is offline   Reply With Quote
Old 14th June 2016, 14:39   #45  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
RoboCrop v1.07, new version.

V1.07 Docs overflow 16kb limit, so left first post docs at v1.0.
See post #37 for v1.07 Docs over two posts. Here: http://forum.doom9.org/showthread.ph...03#post1696703

Code:
	v0.20, Changed, range massage switch on frames to below 1500 (from 1000).
	v0.21, Autothresh Massaging changed minimum to -1.5 from -0.5.
	v1.00, Added ATM arg.
	v1.02, Added Start & End args, Changed default rec709 switch to width > 1100 || height > 600.
	v1.03, Minor mods.
	v1.04, Added User adjustments to detected border edges.
	v1.05, Addef LeftSkip, RightSkip, TopSkip, BotSkip (also shown when Show). Changed default Ignore from 0.2 to 0.4.
	v1.06, Changed Default WMod to 4, avoid possible problems in Avisynth v2.58, some media players and VDubMod.
		   Changed Default AutoThresh to -40.0, been wanting to do this for some time.
		   Changed default Samples to 40, paranoia.
	v1.07, Changed to recognise AutoThresh of both -32.0 and -40.0 as DEFAULT AUTOTHRESH (both old and new version args).
See Mediafire in sig for zip (~148.0 KB)
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 14th June 2016, 15:56   #46  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 778
This reminds me of an idea that I recently had for a plugin that would auto-kill the slight pillarboxing that exists in some fullscreen sources because of overscan. Basically, you'd just give it a number (default = 16), and it would automatically select and crop the "darkest" column of pixels from either the left or right side of the screen, iterated that many times per frame. It could easily be modified to kill letterboxing as well. The easiest way to implement this might be to just give it a target resolution instead of target numbers of rows/columns to kill.

I shall call it... PillKill.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 14th June 2016, 16:30   #47  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,370
I tried it and it works.
I tested it with a "dodgy" source, which is HD - 2.35 LB but has a few captions appearing and disappearing sometimes at the bottom and it worked (it didn't crop them).
Well done!
FranceBB is offline   Reply With Quote
Old 14th June 2016, 16:56   #48  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
FranceBB,
With such a source, I would not recommend auto cropping of bottom, you were perhaps lucky that it just happened to sample a frame
with caption appearing just by chance (only samples 40 frames from entire clip, by default).
Perhaps best to set RLBT flags (which sides to autocrop) for eg top only, and set eg BotAdd to 64 or whatever to manually crop bottom area.
(EDIT: Above I'm assuming you mean that captions appear in bottom border)

EDIT:
@Katie, RoboCrop should deal with your problem clips no bother at all (see image a few posts ahead for all 4 sides cropped).

EDIT: The image is done with Show=True, ie did not do the actual cropping.
EDIT: To crop mod16 width, just set WMod=16 (where will center L+R cropping). Same for height, set HMod (see Laced).
CropLess mode may leave a little border to comply with W/HMod, CropMore[default] may crop a little extra to comply.
EDIT: Or mod8 as filler56789 said is OK for TmpGenc in your thread, set WMod=8.
__________________
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; 14th June 2016 at 18:09.
StainlessS is offline   Reply With Quote
Old 14th June 2016, 17:52   #49  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
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.
__________________
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; 14th June 2016 at 22:47.
StainlessS is offline   Reply With Quote
Old 14th June 2016, 18:37   #50  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 778
Quote:
Originally Posted by StainlessS View Post
@Katie, RoboCrop should deal with your problem clips no bother at all (see image a few posts ahead for all 4 sides cropped).

EDIT: The image is done with Show=True, ie did not do the actual cropping.
EDIT: To crop mod16 width, just set WMod=16 (where will center L+R cropping). Same for height, set HMod (see Laced).
If I'm interpreting the documentation correctly, that won't work. I'm talking about cropping in increments of one pixel until a target resolution is achieved. WMod and HMod seem to set the increments by which the cropping is done, with the final resolution being entirely decided by the filter...

On a side note, the hypothetical filter that I described has some serious flaws that become apparent when the pillarboxing is a few pixels wider or thinner than expected. A better version of the filter would attempt to include equal amounts of black on the edges if the borders are wider than expected, or crop equal amounts of color off the edges if the borders are thinner than expected. I've seen plenty of episodes in which the actual black area was - for example - only 7 pixels on one edge and 3 on the other, and I had to pad the crop values to 10 and 6 respectively. This crap drives me nuts.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 14th June 2016, 19:07   #51  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
Arh, so you mean whether there are borders or not, you remove columns.
Not so sure that is of any use unless only a single frame is being processed (otherwise some serious jumping about is gonna happen
if you have to do that at every frame).

Anyways, just discovered that the mentioned "where will center L+R cropping" dont work proper [dont center],
bug fix version imminent, when I can figure out how to fix it.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 14th June 2016, 22:17   #52  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,370
@StainslesS... Yep, they appear in the bottom line. Anyway, I usually crop sources myself, but I was curious about the filter and I wanted to try it with such a source, mainly for curiosity.
Anyway, thank you
FranceBB is offline   Reply With Quote
Old 14th June 2016, 22:55   #53  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 778
Quote:
Originally Posted by StainlessS View Post
Arh, so you mean whether there are borders or not, you remove columns.
I can't really imagine why anyone would apply this filter to a video without any borders If you need to crop 8 pixels from each side of an image, a simple crop(8,0,-8,-0) should work...

Quote:
Originally Posted by StainlessS View Post
Not so sure that is of any use unless only a single frame is being processed (otherwise some serious jumping about is gonna happen if you have to do that at every frame).
It is intended to be applied on a frame-by-frame basis, but that's perfectly fine, because the only times when pillarboxes substantially change in thickness are when the opening credits end or the end credits start, and then you'll actually WANT the cropped area to shift a bit.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 14th June 2016, 23:05   #54  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
Quote:
until a target resolution is achieved
would seem to imply that presence of real border is unimportant. (dont want an argument here).
RoboCrop crops to the outermost border.

Quote:
to be applied on a frame-by-frame basis
Slowish, Would need to use ScriptClip().
Could use RT_Stats RT_AverageLuma(x=X,y=0,w=1,H=0) to scan vertical colums at X. (inside Scriptclip script).
RT_AverageLuma(n=current_frame) # is the default.

Not too difficult to code that really, go on, have a go

EDIT: Would of course also need GSCript.
__________________
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; 14th June 2016 at 23:08.
StainlessS is offline   Reply With Quote
Old 14th June 2016, 23:20   #55  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 778
Quote:
Originally Posted by StainlessS View Post
would seem to imply that presence of real border is unimportant.
It's important when deciding whether to use Crop(8,0,-8,-0) or a "smart" cropper like Robocrop.

Otherwise, you're correct.

Quote:
Originally Posted by StainlessS View Post
Slowish
LOL. Not compared to resizing, sharpening, blurring, deinterlacing, or many of the other things that AVIsynth can do...

Quote:
Originally Posted by StainlessS View Post
Would need to use ScriptClip().
Could use RT_Stats RT_AverageLuma(x=X,y=0,w=1,H=0) to scan vertical colums at X. (inside Scriptclip script).
RT_AverageLuma(n=current_frame) # is the default.

Not too difficult to code that really, go on, have a go

EDIT: Would of course also need GSCript.
I have no idea what any of that is, does, or means...
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 14th June 2016, 23:40   #56  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
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.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 14th June 2016, 23:47   #57  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 778
I... have no idea what that is or what I'm supposed to do with it...
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 14th June 2016, 23:54   #58  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
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
Old 15th June 2016, 00:30   #59  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 778
Um... okay. While I'm setting this circus up, would you mind letting me know what the script looks like when WKILL is 16 and HKILL is 0? I don't know what I'm supposed to add, or replace, or... seriously, you're breaking my brain here.

EDIT: I plan for my script to look something like this...

Code:
mpeg2source("001.d2v")

bob(b=0,c=1)

selecteven()

[big pile of gobbledygook written by StainlessS]

simpleresize(352,240)
What should "[big pile of gobbledygook written by StainlessS]" be replaced with, assuming that I plan to crop width by 16 and height by 0?
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.

Last edited by Katie Boundary; 15th June 2016 at 00:37.
Katie Boundary is offline   Reply With Quote
Old 15th June 2016, 00:37   #60  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 9,037
Katie, post #58 update.
Is more stable now (so long as WKILL and HKILL are at least total width/height of borders), but still a bit unstable.

Edit, is for Progressive ONLY (holla if Interlaced required).
__________________
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 00:39.
StainlessS is offline   Reply With Quote
Reply

Tags
autocrop, crop

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:18.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.