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 18th January 2017, 16:44   #81  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by Reel.Deel View Post
Thanks, I'll add it to the list.

Did you compile it with ICL?
Built with VC10_64, ICL didn't yield any advantage. I only tested it very briefly but it should be working fine.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 18th January 2017, 20:01   #82  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thanx g2k4, no probs with that here. No surprise that ICL gives no advantage,, all work done before frame serving starts.
Mobile.
__________________
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 23rd October 2017, 18:43   #83  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
By the way, I eventually found out why I was having probs installing SDK 7.1 for VS 2008 (with 64bit), seems the SDK ISO I had was corrupt, with much of it missing but still occupying blank space, it failed on accessing some html file (whose name existed), but the file contents did not exist in the ISO (so install failed and uninstalled again).

Guess I really should check MD5's
__________________
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; 23rd October 2017 at 22:34.
StainlessS is offline   Reply With Quote
Old 7th January 2019, 06:43   #84  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
RoboCrop v1.11, new version see 1st post.
For v1.11 Docs, see post #37:- https://forum.doom9.org/showthread.p...03#post1696703

Code:
	v1.09, Added reticule when Show=true..
	v1.10, Added Exact line marker when show.
	v1.11, 07 Jan  2019. Added Version Resource, Move to VS2008, Added x64, Changed default Align=True.
Code:
    Align: Default True. If true, then aligns frames in memory when cropping, for eg SSE2 16-byte alignment required by some
      filters, particularly smoothing filters (filters following RoboCrop). See Docs for Crop().
      Only Applies if Cropping, ie Blank==false AND Show==false.
	  v1.11, changed Default to True, avoid Avs+ problems which can put up an error if False.
EDIT:
Quote:
SSE2 16-byte alignment
Actually, I think AVS+ might align to either 32 or 64 bytes(think 64, not sure).
__________________
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 06:47.
StainlessS is offline   Reply With Quote
Old 30th January 2019, 01:06   #85  |  Link
spoRv
Registered User
 
Join Date: Nov 2016
Posts: 151
Dear StainlessS, first of all, thanks for all your scripts!



Back to topic: DynaCrop (https://forum.doom9.org/showthread.p...85#post1633485)

I have a video with variable vertical borders; they are pixel perfect (no "smearing" like in analog captures).
I want to get fixed borders for the whole video, so it seems your DynaCrop is the right script.

Some questions:
Quote:
Return SC_ShowMetrics().ConvertToYV12() # Show metrics to get best Threshold 'th', use before SC_MakeTrimFile()
Borders are pure black ($000000); could I skip this step?

Quote:
return SC_MakeTrimFile().ConvertToYV12() # Make Trims file for DynaCrop(), Must Play all way through.
This writes actually the crop info file, right?

Quote:
DynaCrop(CropThresh=CROPTHRESH,show=SHOW,debug=DEBUG).ConvertToYV12(
Then at the end this produces the script needed to crop and resize the video, right?

Now, let's say that I want the video to be resized at 1920x816, where should I set these figures?

Last thing:
Quote:
x,y,w,h sets border to ignore crud
not understood, can you explain?

Thanks a lot in advance, hope to not abuse (well, not too much!) of your infinite patience!
spoRv is offline   Reply With Quote
Old 30th January 2019, 01:57   #86  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Sorry, but I aint gonna go back to look at that, was long Superceded by DBSC:- https://forum.doom9.org/showthread.p...highlight=DBSC

Quote:
x,y,w,h sets border to ignore crud
Crud, maybe VHS with borders but also with VHS tracking crud, otherwise crud would look like NOT border, allows script to assume the crud at least is border. x,y,w,h are crop type coords.

I dont know of anything else that can do what DBSC can do, but it aint automatic.
The current version is somewhat diferent to posted, but is not really suitable for posting yet.

EDIT: You defo need DebugView, and need to use 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 24th April 2019, 16:45   #87  |  Link
Dreamject
Registered User
 
Join Date: Dec 2018
Posts: 140
Why is it not working or even can not detect borders? I use potplayer

Code:
PPcheck=1#WIDTH
PPcheck==1? eval ("""
SetFilterMTMode("ffdshow_source",3)
ffdshow_source()
ConvertToYV12()
global threads=2 #for regular player
""") : eval ("""
global threads=round(1.83 * #CPUS) #valid only for PotPlayer. You can calculate and input numbers of CPU Cores*2 manually
SetFilterMTMode("potplayer_source",3)
potplayer_source()
""")
LoadPlugin("avisynth\RoboCrop_x86.dll")
LoadPlugin("autocrop.dll")
#autocrop(mode=1)
RoboCrop(Samples=10,show=true) #RoboCrop(potplayer_source/ffdshow_source,show=true)
Potplayer does not support resizing, but I need to crop black borders for better motion interpolation
If I just use crop, it works, but still can not get why robocrop/autocrop can not even recognize black borders (i've used pc level too)
LoadPlugin("avisynth\RoboCrop_x86.dll")
crop(100,100,400,376)
RoboCrop(show=true)

Last edited by Dreamject; 24th April 2019 at 17:02.
Dreamject is offline   Reply With Quote
Old 25th April 2019, 13:12   #88  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
What does the debug output tell you, post it. [ RoboCrop(show=true,debug=true) # you need DebugView, google]
Try in something other than Potplayer, I've never even heard of PotPlayer_Source, Suggest Vdub2.
Does your clip have sections without any border, if so then it is doing exactly what its supposed to do.
Absolutely no idea what is happening with your 2nd image, I would say that result is impossible.
(dont have any idea what the blue stuff says either).
Also, suggest that you do not change Samples, default 40 samples would probably take less than a second to scan.

EDIT: What is the clip length ?
RoboCrop deliberately alters thresh for short clips (when using Default autothresh, Thresh = -32.0 or thresh = -40). [to avoid overcrop on short dark clips]
If your clips are dark (and they look like they are), and also short, then set a non DEFAULT_AUTOTHRESH.

Code:
   Thresh: Default= -40.0 (==DEFAULT AUTOTHRESH, any -ve (or 0.0) Thresh is AUTOTHRESH where Thresh adjustments are automatic).
    v1.06, Changed DEFAULT AUTOTHRESH from -32.0 to -40.0.
    v1.07, Changed to recognise a Thresh of either -32.0 or -40.0 as DEFAULT_AUTOTHRESH (fully automatic).

    Thresh > 0: (Explicit Threshold)
      A user supplied +ve Thresh should be at correct TV/PC levels for the the clip being worked on ie 16->235 for TV levels and
      0->255 for PC Levels (RGB, as appropriate for matrix being used).

    Thresh <= 0: (AUTOTHRESH)
      When Thresh <= 0, the clip will be sampled over Samples frames to find the minimum YPlaneMin (using Matrix if RGB) which
      we will call MINLUMA and an Explicit Threshold calculated by adding MINLUMA to abs(Thresh), after that it is processed
      as for Thresh > 0: (Explicit Threshold) as noted above, but, before adding MINLUMA, some AUTOTHRESH massaging and scaling occurs.

      Here AUTOTHRESH Thresh massaging and scaling occurs in sequence:-
      1 ) if (Thresh == DEFAULT AUTOTHRESH && ATM < abs(thresh))
              (DEFAULT AUTOTHRESH = exactly -40.0, defaulted OR user supplied, v1.07 also recognises -32.0 as DEFAULT_AUTOTHRESH):
            Let sampstart and sampend, be starting and ending frames numbers after any Auto Credits skipping and/or user set Start or End.
            Let Samples be limited to sampend-sampstart+1.
            Let SampRange (Sample Range) = SampEnd-SampStart+1.
            samples_massage =(Samples>=20)           ? 1.0 : (Samples-1)   * (1.0/(20-1))           # No massaging if Samples >= 20
            range_massage   =(SampRange >= (250*20)) ? 1.0 : (SampRange-1) * (1.0/((250*20)-1))     # No massaging if SampRange >= 5000
             Both samples_massage and range_massage will be in range 0.0 to 1.0.
             Thresh = -(((samples_massage * range_massage) * (abs(Thresh) - ATM)) + ATM)
              This adjustment to Auto Thresh is to reduce the possibility of overcropping on eg a dark low 'Samples' clip, or where
              source SampRange (ie temporal frame set) is too small to take a reliable sample from.
              Resulting massaged Thresh will range between -ATM and DEFAULT_AUTOTHRESH.
              Although massaging is intended to reduce overcropping, it could result in not cropping enough border (less disastrous),
              its a bit of a balancing act really. See also ATM.
      2 ) If RGB AND PC matrix(default) AND ScaleAutoThreshRGB==True(default) then
            Thresh= Thresh*(255.0/(235-16))
      3 ) If YUV AND ScaleAutoThreshYUV==True(default=false) then
            Thresh= Thresh*(255.0/(235-16))

      Steps 2) and 3) above, by default treat a -ve AUTOTHRESH as being @ TV Levels and so Scale RGB Thresh to PC levels but not YUV.
      If you want to supply a PC levels AUTOTHRESH Thresh for RGB, then simply set ScaleAutoThreshRGB=false to inhibit scaling.
      Note, if a TV levels Matrix is supplied for RGB, then scaling will always be inhibited.
       If your clip is YUV at PC levels and you want to use eg DEFAULT AUTOTHRESH (-40.0, which is considered to be @ TV levels),
      then set ScaleAutoThreshYUV=True to enable Thresh scaling.
       If your clip is YUV at PC levels and you want to use a PC levels AUTOTHRESH (-ve) then leave ScaleAutoThreshYUV at default false
      which does not scale Thresh.
      After any scaling, MINLUMA is then added to abs(Thresh) and processed as for +ve Explicit Threshold as noted above.
      NOTE, Above RoboCrop step 1) 'massages' DEFAULT_AUTOTHRESH (exactly -40.0 or v1.07 exactly -32.0) if low samples count or if short clip.
      Reason being to avoid overcropping when insufficient data available for reliable cropping. It is considered better to not crop enough
      or at all, than to overcrop. You can override by simply setting an explicit threshold (+ve) of eg 40.0, or setting a NON-DEFAULT auto thresh
       (-ve) eg -16.0 or -40.1, where YPlaneMin is established for the sampled frames and then abs(thresh) is added to that value which
       is then used as an explicit thresh.
      NOTE, v1.07 recognises a Thresh of either -40.0 OR -32.0 as DEFAULT_AUTOTHRESH, so user can provide either value and
      DEFAULT_AUTOTHRESH massaging will be applied for low samples count and/or low frame ranges.
__________________
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; 25th April 2019 at 14:15.
StainlessS is offline   Reply With Quote
Old 6th February 2020, 19:02   #89  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
RoboCrop v1.12, update, see first post.

Added ScanPerc, allows detect when image is wholly one or other side of clip center.
Code:
Function RoboCrop(clip c,int "Samples"=40,Float "Thresh"=-40.0,bool "Laced"=true,int "WMod",int "HMod",int "RLBT"=15,bool "Debug"=false, \
    float "Ignore"=0.4,int "Matrix"=(c.Width>1100||c.Height>600?3:2), int "Baffle"=4, bool "ScaleAutoThreshRGB"=true,
    bool "ScaleAutoThreshYUV"=false, int "CropMode"=2,bool "Blank"=false,bool "BlankPC"=false,bool "Align"=True,bool "Show"=false, \
    String "LogFn"="",bool "LogAppend"=false, Float "ATM"=4.0,int "Start"=Undefined,Int "End"=Undefined, \
    Int "LeftAdd"=0,Int "TopAdd"=0,Int "RightAdd"=0,Int "BotAdd"=0, \
    Int "LeftSkip"=0,Int "TopSkip"=0,Int "RightSkip"=0,Int "BotSkip"=0 \
    Float "ScanPerc=49.0 )
Code:
    Float ScanPerc, Default 49.0, Range 1.0->99.0. Precentage of clip dimensions to scan for border edges.
      Default 49.0%, Starts scan from nearly the middle of frame to outer edge of frame looking for borders.
      Specialist use, might use eg 99.0% when image wholly to one of other side of the middle of frame.
      eg, when 99.0, starts scan for TOP edge at nearly bottom of frame, scanning upwards.
                     starts scan for BOT edge at nearly top of frame, scanning downwards.
                     starts scan for LFT edge at nearly RHS of frame, scanning leftwards.
                     starts scan for RGT edge at nearly LHS of frame, scanning rightwards.

Code:
BlankClip(width=1024,height=768,Pixel_type="YV12").trim(0,-1)
W=Last.BlankClip(width=320,height=240,color=$FF00FF)
OverLay(W,x=680,y=416)
RoboCrop(Samples=1,debug=true,ScanPerc=99,show=true)
Return Last#.info
ScanPerc=99.0 [Show=True]


Show=true [from old version 1.06]

Show=true [from old version 1.10]

Bottom image above: Left edge, single dots line, other edges a bit wiggly ie cropping moved inwards [CROPMORE] to adhere to X/Y/W/H Mod requirements.

EDIT: AutoCrop() fails badly [with defaults] on a 10 mins clip surrounding above frame from Cabaret. [chops off half of frame, not much image left]
__________________
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; 6th February 2020 at 22:56.
StainlessS is offline   Reply With Quote
Old 6th February 2020, 19:20   #90  |  Link
Hotte
Registered User
 
Join Date: Oct 2014
Posts: 209
Thanks, StainlessS, for your nice support in Avs Dev-Forum and for this this new version of RoboCrop. Its great to have this option now for to crop frames away wherever they show up.
Hotte is offline   Reply With Quote
Old 6th February 2020, 23:42   #91  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
StainlessS,
Does RoboCrop only support 8 bit video? If that's the case do you have any plans?
Being all new and shiny I assumed it would support high bitdepths, so I was going to replace AutoCrop with RoboCrop in my script, but I appear to have assumed incorrectly.

I also have a feature request if it's not hard to do. For a future version would it be possible to display the cropping in human-speak in addition to the current method? ie
Crop(8,52,-16,-52)
and
Crop(8,52,1256,616)

The dimensions in human-speak would be great too. Something like:
Source Dimensions 1280x720
Cropped Dimensions 1256x616

I realise the information is already there. It's just a habit thing, or maybe I'm an idiot, but I don't see it displayed in other ways regularly, so I invariably need to down-tools for a bit while I think about it.

Cheers.

Last edited by hello_hello; 6th February 2020 at 23:49.
hello_hello is offline   Reply With Quote
Old 7th February 2020, 00:31   #92  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
You are welcome Hotte

Hello_Hello,
Quote:
Crop(8,52,-16,-52)
Look in above image, next to CROPMORE [Cabaret Image] ie
Crop(28,90,668,394) [CROPMORE]

From prev posted script for lob-sided borders (Debug=True)
Code:
00000146    23:22:07.597    RoboCrop: v1.12 - 06 Feb 2020 - By StainlessS
00000147    23:22:07.597    Input: Width=1024 Height=768 FrameCount=1
00000149    23:22:07.597    Thresh defaulting to DEFAULT AUTOTHRESH -40.00
00000150    23:22:07.597    Thresh -40.00 recognised as DEFAULT AUTOTHRESH
00000151    23:22:07.597    Potential Auto Credits Skip Start@5%=0 End @90%=0 : Range=1
00000152    23:22:07.597    No Skip Start(0), No Skip End(0) : Range=1 [Skip range < 250]
00000153    23:22:07.597    Low Samples count(1), Massaging Auto Thresh(samples scaler=0.000000)
00000154    23:22:07.597    Low Frames Range(1), Massaging Auto Thresh(range scaler=0.000000)
00000155    23:22:07.597    Combined Thresh Massage Scaler=0.000000
00000156    23:22:07.597    Auto Thresh reduced from DEFAULT -40.000000 to -4.000000
00000158    23:22:07.597    Samples=1 Thresh=-4.000 Laced=True Matrix=3
00000159    23:22:07.597    WMod=4 HMod=4 {Colorspace/Laced Restricted XMod=2 YMod=4}
00000160    23:22:07.597    RLBT=15 Ignore=0.400 Baffle=4
00000161    23:22:07.597    ScaleAutoThreshRGB=Yes ScaleAutoThreshYUV=No
00000162    23:22:07.597    CropMode=2(CropMore) Blank=No Align=Yes Show=Yes Log=No
00000163    23:22:07.597    Atm=4.000 SampStart=0 SampEnd=0 SampRange=1
00000164    23:22:07.597    LeftAdd=0 TopAdd=0 RightAdd=0 BotAdd=0
00000165    23:22:07.597    LeftSkip=0 TopSkip=0 RightSkip=0 BotSkip=0
00000166    23:22:07.597    ScanPerc=99.000000
00000168    23:22:07.597    AutoThresh   1) [     0] YPlaneMin = 16 (16)
00000170    23:22:07.597    YPlaneMin=16 : Automatic set Thresh=20.000
00000172    23:22:07.597    Top   1) [     0]  AveY= 44.13  Y1=416
00000173    23:22:07.597    Bot   1) [     0]  AveY= 44.13  Y2=655
00000174    23:22:07.597    Lft   1) [     0]  AveY=106.00  X1=680
00000175    23:22:07.597    Rgt   1) [     0]  AveY=106.00  X2=999
00000177    23:22:07.597    Active Frames (where image coords first found) = 1
00000178    23:22:07.597    Sampled ImageEdge:  X1=680  Y1=416  X2=999(W=320,-24)  Y2=655(H=240,-112)
00000180    23:22:07.597    Crop(ModW/H):  X =680   Y =416   W =320(-24)   H =240(-112)
00000181    23:22:07.597    Constructor Scan Total Time=0.000 secs
As far as hi bit depth thing is concerned, there are not I think, many plugins that support HBD. [well some by Pinterf, and Source filters, maybe a few more].
I aint had enough play as yet to do a plug, and first one would have to be DDigit text renderer, which I would need in a lot of my plugs.
[Info.h Metrics text renderer from Avs+ source does not support HBD either, leastwise last time I looked.]

Maybe one day, but not today, sorry.
__________________
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 February 2020 at 02:37.
StainlessS is offline   Reply With Quote
Old 7th February 2020, 02:27   #93  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by StainlessS View Post
Look in above image, next to CROPMORE [Cabaret Image] ie
Crop(28,90,668,394) [CROPMORE]
I know it's there, but chances are some GUI users would have no idea you can crop that way, and to know what was cropped right and bottom you have to know the source dimensions, or check X,Y co-ordinates. The actual width and height might have been better than W and H there, but not to worry, it was just an idea.

Quote:
Originally Posted by StainlessS View Post
Maybe one day, but not today, sorry.
I rarely work with HBD video anyway, but while I was playing with RoboCrop I thought I'd ask.

Cheers.
hello_hello is offline   Reply With Quote
Old 7th February 2020, 06:14   #94  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
RoboCrop v1.13, update, see first post.
Full docs here:- https://forum.doom9.org/showthread.p...03#post1696703

Added Prefix Arg.
Code:
Function RoboCrop(clip c,int "Samples"=40,Float "Thresh"=-40.0,bool "Laced"=true,int "WMod",int "HMod",int "RLBT"=15,bool "Debug"=false, \
    float "Ignore"=0.4,int "Matrix"=(c.Width>1100||c.Height>600?3:2), int "Baffle"=4, bool "ScaleAutoThreshRGB"=true,
    bool "ScaleAutoThreshYUV"=false, int "CropMode"=2,bool "Blank"=false,bool "BlankPC"=false,bool "Align"=True,bool "Show"=false, \
    String "LogFn"="",bool "LogAppend"=false, Float "ATM"=4.0,int "Start"=Undefined,Int "End"=Undefined, \
    Int "LeftAdd"=0,Int "TopAdd"=0,Int "RightAdd"=0,Int "BotAdd"=0, \
    Int "LeftSkip"=0,Int "TopSkip"=0,Int "RightSkip"=0,Int "BotSkip"=0 \
    Float "ScanPerc=49.0,String "Prefix"="ROBOCROP_" )
Code:
    String Prefix,   Default "ROBOCROP_". Prefix for Local vars set by the filter, crop coordinates. Setting to "" disables Local vars.
                     With Prefix="ROBOCROP_" (Default)
                         ROBOCROP_X  = X coord
                         ROBOCROP_Y  = Y coord
                         ROBOCROP_W  = +ve Width
                         ROBOCROP_H  = +ve Height
                         ROBOCROP_W2 = -ve Width relative crop coord
                         ROBOCROP_H2 = -ve Height relative crop coord

                   Example use:
                    <<<<<<<<< CODE START <<<<<<<
                        BlankClip(Length=1,width=1024,height=768,Pixel_type="YV12")
                        Wid=Width
                        Hit=Height
                        BLK=Last.BlankClip(width=320,height=240,color=$FF00FF)
                        OverLay(BLK,x=680,y=416)
                        RoboCrop(ScanPerc=99,show=true,debug=true,Prefix="ROBOCROP_")
                        X=ROBOCROP_X  # Get Local Vars as set by RoboCrop (Using Prefix, above using Prefix same as Default Prefix)
                        Y=ROBOCROP_Y
                        W=ROBOCROP_W
                        H=ROBOCROP_H
                        W2=ROBOCROP_W2
                        H2=ROBOCROP_H2
                        Subtitle("Source: Width="+String(Wid)+",Height="+String(Hit),Y=4)
                        Subtitle("Crop("+String(X)+","+String(Y)+","+String(W)+","+String(H)+")",Y=24)
                        Subtitle("Crop("+String(X)+","+String(Y)+","+String(W2)+","+String(H2)+")",Y=44)
                        Return Last
                    >>>>>>>>>> CODE END >>>>>>>
Test script
Code:
BlankClip(Length=1,width=1024,height=768,Pixel_type="YV12")
Wid=Width
Hit=Height
BLK=Last.BlankClip(width=320,height=240,color=$FF00FF)
OverLay(BLK,x=680,y=416)
RoboCrop(ScanPerc=99,show=true,debug=true,Prefix="ROBOCROP_")
X=ROBOCROP_X  # Get Local Vars as set by RoboCrop (Using Prefix, above using Prefix same as Default Prefix)
Y=ROBOCROP_Y
W=ROBOCROP_W
H=ROBOCROP_H
W2=ROBOCROP_W2
H2=ROBOCROP_H2
Subtitle("Source: Width="+String(Wid)+",Height="+String(Hit),Y=4)
Subtitle("Crop("+String(X)+","+String(Y)+","+String(W)+","+String(H)+")",Y=24)
Subtitle("Crop("+String(X)+","+String(Y)+","+String(W2)+","+String(H2)+")",Y=44)
Return Last


debug output
Code:
00000123	04:58:04.155	RoboCrop: v1.13 - 07 Feb 2020 - By StainlessS
00000124	04:58:04.155	Input: Width=1024 Height=768 FrameCount=1	
00000126	04:58:04.155	Samples (40) limited to FrameCount(1)	
00000127	04:58:04.155	Thresh defaulting to DEFAULT AUTOTHRESH -40.00	
00000128	04:58:04.155	Thresh -40.00 recognised as DEFAULT AUTOTHRESH	
00000129	04:58:04.155	Potential Auto Credits Skip Start@5%=0 End @90%=0 : Range=1	
00000130	04:58:04.155	No Skip Start(0), No Skip End(0) : Range=1 [Skip range < 250]	
00000131	04:58:04.155	Low Samples count(1), Massaging Auto Thresh(samples scaler=0.000000)	
00000132	04:58:04.155	Low Frames Range(1), Massaging Auto Thresh(range scaler=0.000000)	
00000133	04:58:04.155	Combined Thresh Massage Scaler=0.000000	
00000134	04:58:04.155	Auto Thresh reduced from DEFAULT -40.000000 to -4.000000	
00000136	04:58:04.155	Samples=1 Thresh=-4.000 Laced=True Matrix=3	
00000137	04:58:04.155	WMod=4 HMod=4 {Colorspace/Laced Restricted XMod=2 YMod=4}	
00000138	04:58:04.155	RLBT=15 Ignore=0.400 Baffle=4	
00000139	04:58:04.155	ScaleAutoThreshRGB=Yes ScaleAutoThreshYUV=No 	
00000140	04:58:04.155	CropMode=2(CropMore) Blank=No Align=Yes Show=Yes Log=No	
00000141	04:58:04.155	Atm=4.000 SampStart=0 SampEnd=0 SampRange=1	
00000142	04:58:04.155	LeftAdd=0 TopAdd=0 RightAdd=0 BotAdd=0	
00000143	04:58:04.155	LeftSkip=0 TopSkip=0 RightSkip=0 BotSkip=0	
00000144	04:58:04.155	ScanPerc=99.000000	
00000145	04:58:04.155	Prefix='ROBOCROP_'	
00000147	04:58:04.155	AutoThresh   1) [     0] YPlaneMin = 16 (16)	
00000149	04:58:04.155	YPlaneMin=16 : Automatic set Thresh=20.000	
00000151	04:58:04.155	Top   1) [     0]  AveY= 44.13  Y1=416	
00000152	04:58:04.155	Bot   1) [     0]  AveY= 44.13  Y2=655	
00000153	04:58:04.155	Lft   1) [     0]  AveY=106.00  X1=680	
00000154	04:58:04.155	Rgt   1) [     0]  AveY=106.00  X2=999	
00000156	04:58:04.155	Active Frames (where image coords first found) = 1	
00000157	04:58:04.155	Sampled ImageEdge:  X1=680  Y1=416  X2=999(W=320,-24)  Y2=655(H=240,-112)	
00000159	04:58:04.155	Crop(ModW/H):  X =680   Y =416   W =320(-24)   H =240(-112)	
00000160	04:58:04.155	Input: Width=1024 Height=768	
00000161	04:58:04.155	Crop(680,416,320,240)	
00000162	04:58:04.155	Crop(680,416,-24,-112)	
00000163	04:58:04.155	Constructor Scan Total Time=0.000 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 ???
StainlessS is offline   Reply With Quote
Old 8th February 2020, 05:32   #95  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
That was speedy service. Thanks.
Is it always possible to get plugin variables that way, or is it something you've specifically had to configure?

"Usage" looked a bit hard, so I made a wrapper function and sexed it up a bit, although I'm not sure what font you're using normally.
I couldn't think of a better name, so it's called RoboCropped. It just calls RoboCrop with the options at their default values, but you can specify them as you can for RoboCrop, so to show the cropping preview it's Show=true as usual. The subtitles should sit in the bottom left corner. There's a link below.

Have you used RoboCrop with much h264 video? It's really, really slow to open for me with the default settings. Your example avs and mpeg2 are okay, but the 720p sources I've been playing around with take between 30 seconds to 1 minute to open. If I reduce Samples to 1 it's okay, so I guess there's a lot of decoding that needs to be done when checking lots of frames.

Cheers.

RoboCropped.avsi
(function edited 2020-02-29 to change scaling of subtitle text)


Last edited by hello_hello; 28th February 2020 at 20:18.
hello_hello is offline   Reply With Quote
Old 8th February 2020, 06:37   #96  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
or is it something you've specifically had to configure?
This is it
Code:
    if(debug) {
        dprintf("Crop(ModW/H):  X =%3d   Y =%3d   W =%3d(%d)   H =%3d(%d)",
            crop_x,crop_y,crop_w,crop_x+crop_w-w,crop_h,crop_y+crop_h-h);
        dprintf("Input: Width=%d Height=%d",w,h);
        dprintf("Crop(%d,%d,%d,%d)",crop_x,crop_y,crop_w,crop_h);
        dprintf("Crop(%d,%d,%d,%d)",crop_x,crop_y,crop_x+crop_w-w,crop_y+crop_h-h);    // debug output
        if(isplanar && crop_w % 4)
            dprintf("*** WARNING *** Some players and VDubMod may require WMod=4");
        double duration =  (double(clock()) / double(CLOCKS_PER_SEC)) - start_time;
        dprintf("Constructor Scan Total Time=%.3f secs",duration);
    }
    if(prefix !="") {
        const char *p;
        int pfixlen=int(strlen(prefix));
        if(pfixlen>128)
            pfixlen=128;
        char bf[128+32];
        memcpy(bf,prefix,pfixlen);
        char *d;
        AVSValue var;

        d=bf+pfixlen;
        for(p="X";*d++=*p++;);          // strcat variable name part
        var  =  GetVar(env,bf);
        env->SetVar(var.Defined()?bf:env->SaveString(bf),crop_x);

        d=bf+pfixlen;
        for(p="Y";*d++=*p++;);          // strcat variable name part
        var  =  GetVar(env,bf);
        env->SetVar(var.Defined()?bf:env->SaveString(bf),crop_y);

        d=bf+pfixlen;
        for(p="W";*d++=*p++;);          // strcat variable name part
        var  =  GetVar(env,bf);
        env->SetVar(var.Defined()?bf:env->SaveString(bf),crop_w);

        d=bf+pfixlen;
        for(p="H";*d++=*p++;);          // strcat variable name part
        var  =  GetVar(env,bf);
        env->SetVar(var.Defined()?bf:env->SaveString(bf),crop_h);

        d=bf+pfixlen;
        for(p="W2";*d++=*p++;);         // strcat variable name part
        var  =  GetVar(env,bf);
        env->SetVar(var.Defined()?bf:env->SaveString(bf),crop_x+crop_w-w);

        d=bf+pfixlen;
        for(p="H2";*d++=*p++;);         // strcat variable name part
        var  =  GetVar(env,bf);
        env->SetVar(var.Defined()?bf:env->SaveString(bf),crop_y+crop_h-h);
    }
I did not bother to check for valid Prefix variable name, so if you provide something like "a!35434342123:'^%$", I've no idea if it will go BANG!!!.
Dont think I've ever seen anybody else check valid var name, I did it in one plug but forgot which one.

RoboCrop scans from start to end of video clip, Samples number of frames [default 40], spread evenly throughout the clip.
Is your source filter Indexing the thing, if so then that is where the pause is. [I usually use it with Ut_Video AVI, where it takes maybe less than 1.0 sec for 2 hr Movie].
LSMashVideoSource source does not index, although I dont know how well it does where seeking in big jumps through the video clip.
RoboCrop tries to get the OutMost borders, so if borders change will try to find the least crop borders.

"Usage" looked a bit hard"
I usually just call as RoboCrop(), is intended to be mostly autonomous. [might want to set WMod, HMod, and Laced].

Quote:
If I reduce Samples to 1
Not a terribly good idea, dark single frame like the prev Cabaret frame might chop up your clip. [just as Autocrop with default settings of 5 samples frames (as I posted in Cabaret post)]
Quote:
Originally Posted by StainlessS View Post
EDIT: AutoCrop() fails badly [with defaults] on a 10 mins clip surrounding above frame from Cabaret. [chops off half of frame, not much image left]
__________________
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; 8th February 2020 at 06:48.
StainlessS is offline   Reply With Quote
Old 8th February 2020, 08:39   #97  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Thanks for the info.

Quote:
Originally Posted by StainlessS View Post
"Usage" looked a bit hard"
I usually just call as RoboCrop(), is intended to be mostly autonomous. [might want to set WMod, HMod, and Laced].
Sorry, I meant "usage" in respect to adding the subtitles, not RoboCrop in general.

Quote:
Originally Posted by StainlessS View Post
Not a terribly good idea, dark single frame like the prev Cabaret frame might chop up your clip. [just as Autocrop with default settings of 5 samples frames (as I posted in Cabaret post)]
I don't use auto cropping a lot, but I think the main reason AutoCrop's default settings might be more likely to fail isn't because it only takes 5 samples, but because the default for the first sample is the first frame, and the last sample is the second last frame. I'm not sure what the point of starting more than a few hundred frames from the beginning would be, especially for a movie and to avoid the end credits you'd probably want to finish a fair bit before the end too, but you'd no doubt know better than me.
hello_hello is offline   Reply With Quote
Old 8th February 2020, 12:34   #98  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Yes it normally starts at 5% and ends at 90% [below clip is only single frame so that is not gonna happen there, I said starts at beginning and ends at end, I was being economical with words.]

Code:
00000123	04:58:04.155	RoboCrop: v1.13 - 07 Feb 2020 - By StainlessS
00000124	04:58:04.155	Input: Width=1024 Height=768 FrameCount=1	
00000126	04:58:04.155	Samples (40) limited to FrameCount(1)	
00000127	04:58:04.155	Thresh defaulting to DEFAULT AUTOTHRESH -40.00	
00000128	04:58:04.155	Thresh -40.00 recognised as DEFAULT AUTOTHRESH	
00000129	04:58:04.155	Potential Auto Credits Skip Start@5%=0 End @90%=0 : Range=1	
00000130	04:58:04.155	No Skip Start(0), No Skip End(0) : Range=1 [Skip range < 250]
__________________
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 12th February 2020, 15:56   #99  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
HH,

Something just occurred to me, when you say RoboCrop is slow, maybe you are calling it last, after some heavy duty scripting, eg MCDegrain/QTGMC.
This would cause it to sample eg McDegrain/QTGMC'ed frames, and so slow.
I always use RoboCrop pre [nearly] everything else, just be sure to set Laced [ie interlaced, is default True] arg for interlaced sources.
Cropping first, would take borders out prior to any eg Auto Gain/Levelling, may produce less frame to process.
Deblocking might require a bit more thought, would need pad to mod 8 [usually], and done before cropping. [then remove padding] prior to autocrop]

Prev post not quite correct, finds Potential Auto Credits skip frames at 5% and 90% Framecount [where at least 250 frames],
thereafter spreads out samples frames like so
Code:
00100100

# OR

00100100100

# OR

000010000
Where first and last 0's are credit skip first and last frames, and 1's are sampled frames, if sampling single frame then would be the middle frame [if odd frames].

Also, where default SAMPLES = 40, will actually scan 80 frames, 40 sampled for YPlaneMin [to decide what Auto threshold should be], and then same 40 frames
again to detect borders usng the auto set threshold.

EDIT: I have occasionally come across clips where border color is quite a bit lighter than darkest luma in image part [maybe YPlaneMin=0, border=32], this tends to mess up
the auto thresholding somewhat, and will may cause failure where no border is cropped.

EDIT: You could also crop in YV24 for YMOD, HMod of 2.
__________________
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; 13th February 2020 at 18:31.
StainlessS is offline   Reply With Quote
Old 21st October 2020, 18:12   #100  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Hi StainlessS

is it possible to use RoboCrop to generate a mask instead of cropping? so the mask will be used in ExInpaint or AvsInpaint

and the mask changes every frame of course
__________________
See My Avisynth Stuff
real.finder 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 21:35.


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