VideoHelp Forum
+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. For anyone stumbling across this thread, this is an old version of the script.
    The new version can be found
    here.

    Most of the information in this thread is outdated.

    If anyone's interested, I spent a bit more time on this script and it can now replace my previous CropResize script, as well as provide more functionality. As the name says, it auto-crops, resizes and can add borders if required. Once again it keeps any aspect error to as close to zero as possible by cropping if need be to achieve a desired aspect ratio, so it can take a little getting used to, but the original purpose was to enable cropping and resizing a bunch of videos to a common resolution/aspect ratio (somewhat automatically), without having to manually calculate cropping and resizing for each source individually and without distorting the picture.

    The zip file includes autocrop.dll. RGTools and Resize8 are required for the CropResize8Border version of the script.

    CropResizeBorder 2017-04-17.zip
    There's a modified version of the script attached to post #4. Functionality is exactly the same, but I added some wrapper functions to make it easier to use.

    As some of the options can be a little schizophrenic according to how they're used in combination with each other, there's a "Cmode" option to simply enforce some settings so the script operates in the specified mode. It made things less confusing for me.

    CRB(OutWidth=Width, OutHeight=Height, CL=0, CT=0, CR=0, CB=0, Cthresh=30, Cstart=0, Csample=5, PicDAR=0.0, Mod=4, InDAR=0.0, Cpreview=0, Cmode="R", Bcolor=color_black)

    For me the script will mostly be used in normal cropping and resizing mode (Cmode="R") which is the default mode (so it doesn't need to be specified), but there's an error message listing the various modes. Specifying an invalid mode such as Cmode="xx" will result in the error message.



    A few examples with the following 16:9 NTSC DVD as the source:



    In default mode, all that's required to crop the black and resize the width to square pixel dimensions would be the following (if the script is resizing it always resizes to square pixel dimensions). "InDAR" is required for correct resizing of anamorphic sources such as DVDs:

    CRB(InDAR=16.0/9.0) # or specifying a width & height of zero achieves the same thing) ie CRB(0, 0, InDAR=16.0/9.0)



    Possibly the next most common use would be to specify a width and let the script take care of the cropping and height. ie resizing to a width of 640:

    CRB(640, 0, InDAR=16.0/9.0)



    As the main idea of the script is to allow any resizing without distorting the picture (it's cropped accordingly instead) you're free to do all sorts of odd things such as specifying a 4:3 aspect ratio for the above source (640x480) and the script would crop it accordingly.

    CRB(640, 480, InDAR=16.0/9.0) # or instead of specifying a width & height, PicDAR can be used for the same result ie
    CRB(640, 0, PicDar=1.333334, InDAR=16.0/9.0)
    or
    CRB(0, 480, PicDar=1.333334, InDAR=16.0/9.0)



    The next mode is "Add Borders" mode (Cmode="RB") and it works exactly like the normal crop and resize mode, until both OutWidth & OutHeight are specified, in which case the cropping, or PicDAR option, determine the resolution/aspect ratio of the picture itself, and OutWidth & OutHeight determine the final resolution/aspect ratio. If OutWidth/OutHeight produce a different aspect ratio to the "picture" aspect ratio, borders are added to make up the difference. By default the borders are black, but here they're blue.

    As an example, the following would crop the picture as usual then OutWidth & OutHeight are used to specify a 16:9 "frame" (704x396).

    CRB(704, 396, InDAR=1.777778, Cmode="RB", Bcolor=$00008B)



    Or as another example, if the "picture" aspect ratio happened to be 1.5:1 and the same OutWidth and OutHeight were specified, borders would be automatically added to the sides instead:

    CRB(704, 396, InDAR=1.777778, PicDAR=1.5/1.0, Cmode="RB", Bcolor=$00008B)



    Cmode="RW" is mainly intended for cropping and resizing anamorphic sources to square pixel dimensions while ensuring the height is never resized (only cropped). OutWidth & OutHeight are disabled so the result is the same as normal mode with an unspecified width or height (see second screenshot).

    Cmode="NR" is the mode with resizing disabled, so it's intended for use with anamorphic sources where the objective would be to crop any borders but not change the pixel aspect ratio. For non-anamorphic sources it also simply crops. "PicDAR" can still be used to adjust the cropping to a particular "display" aspect ratio (as long as the correct InDAR is specified).
    Whereas the source is cropped and resized in the second screenshot above, for Cmode="NR" it would only be cropped.

    For Cmode="B" resizing is also disabled, but it's the "clean up borders" mode where the output resolution is always the same as the source resolution and the pixel aspect ratio never changes. It's simply intended to crop away messy borders and replace them with clean ones, something like the following (PAL 4:3 DVD as source, screenshots reduced to half):

    CRB(0, 0, InDAR=4.0/3.0, Cthresh=110, Mod=8, Cmode="B", Bcolor=$00008B)



    Finally there's a couple of preview modes. Cpreview=1 previews the cropping (before any resizing) while CPreview=2 shows you what mode you're in and provides some additional information.

    CRB(0, 0, InDAR=4.0/3.0, Cthresh=110, Mod=8, Cmode="B", Bcolor=$00008B, Cpreview=1) # for second screenshot Cpreview=2



    ------------------------------------------------------------------------------------------------------------------------------------------------------------

    The options:

    OutWidth (default, 0)
    Output width of video. If zero or not specified the width of the source video after cropping is used (or for anamorphic sources the width after resizing to square pixel dimensions).
    OutHeight (default, 0)
    Output height of video. If zero or not specified the same height as the source video is used, after cropping.
    CL, CT, CR, & CB (defaults, 0)
    Cropping in addition to the auto-cropping. Left, Top, Right, Bottom. Positive values increase the auto-cropping. Negative values reduce it.
    Cthresh (default, 30)
    How enthusiastically autocrop crops. Cthresh=0 should disable auto-cropping. Range 0-255.
    Cstart (default, 0)
    The first frame checked for auto-cropping.
    Csample (default, 5)
    The number of frames autocrop checks.
    PicDAR (default, determined by auto-cropping)
    Sets the "picture display aspect ratio", which effectively adjusts the cropping to a certain aspect ratio. Must be float (ie 1.777778 or 16.0/9.0 etc). More than six decimal places is probably pointless. In normal cropping/resizing mode (Cmode="R") if OutWidth and OutHeight are both greater than zero it has no effect.
    Mod (default, 4)
    The mod setting doesn't override any specified width or height, so if you specify a width or height and want them to be mod16 (for example) you must make sure they're mod16 yourself. In normal mode, if only the width is specified, the Mod setting effects the height. If only the height is specified, it effects the width. If "PicDAR" is being used to adjust the "picture" display aspect ratio, the Mod setting has "final say".
    In "Add Borders" mode, when left/right or top/bottom borders are added, the mod setting has final say over the width or height of the picture itself (excluding borders).
    Mod=32 is permitted as it can be used to help ensure mod16 borders in "Add Borders" mode. The user must specify a mod32 OutWidth or OutHeight, in which case Mod=32 should help ensure the added borders are mod16.
    InDAR (default, same as source resolution) Required for correct resizing of anamorphic sources.
    The Input Display Aspect Ratio. Must be float (ie 1.777778 or 16.0/9.0 etc). If InDAR is not specified the source is assumed to have square pixels. More than six decimal places is probably pointless. Even in non-resizing mode (Cmode="NR") for anamorphic sources InDAR must be specified for the PicDAR option to work correctly.
    Recommended DVD display aspect ratios for both PAL and NTSC:
    If a 4:3 DVD has a reasonable amount of black down each side (8 or more pixels) InDAR=15.0/11 or InDar=1.363637 is more likely to be correct (it's the display aspect ratio resulting from the mpeg4 pixel aspect ratios). With very little black down each side, InDAR=4.0/3.0 or InDAR=1.333334 is more likely to be correct for a 4:3 DVD.
    For 16:9 DVDs with a lot of black down the sides it'd be InDAR=20.0/11.0 or InDAR=1.818182. Without a lot of black each side, InDar=16.0/9.0 or InDAR=1.777778.
    For either type though, there's no hard and fast rule. Whatever you think looks correct. The difference isn't huge.
    Cpreview (default, 0)
    Cpreview=0 Normal mode.
    Cpreview=1 Displays the autocrop cropping information over the source video. Nothing is cropped. Nothing is resized. No borders are added.
    Cpreview=2 Displays the normal output with info overlayed showing the current "Cmode" as well as providing some additional information.
    Cmode (default, "R")
    Enforces some settings in order for the script to operate in a particular "mode".
    Cmode="R" is the default crop/resize mode. The source is automatically cropped and resized to square pixel dimensions.
    Cmode="RB" is "crop, resize and add borders" mode and much the same as Cmode="R" until both OutWidth and OutHeight are specified, in which case rather than cropping the picture for the specified width and height, borders will be added instead.
    Cmode="RW" is "resize width only" mode and disables OutWidth & OutHeight. It ensures the height of anamorphic sources is never resized (only cropped) and only the width is resized for square pixel dimensions.
    Cmode="NR" is "no resizing" mode and mainly intended for cropping anamorphic sources without changing the pixel aspect ratio. For non-anamorphic sources it simply crops. OutWidth & OutHeight are disabled.
    Cmode="B" is "clean borders" mode and intended to replace existing borders with "clean" borders. The output resolution is always the same as the source resolution. OutWidth & OutHeight are disabled.
    Bcolor (default, color_black or $000000)
    Sets the color of any added borders. See the "colors_rgb.avsi" script in the Avisynth plugins folder for a list of colours.

    The following two options only apply to the CropResize8Border version of the script. It uses the Resize8 script for resizing which in turn requires RGTools. The default resizers are the same as those for the Resize8 script.

    cr8b(OutWidth=Width, OutHeight=Height, CL=0, CT=0, CR=0, CB=0, Cthresh=30, Cstart=0, Csample=5, PicDAR=0.0, Mod=4, InDAR=0.0, Cpreview=0, Cmode="R", Bcolor=color_black, Resizer="Spline36", ResizerC="Spline36")

    Resizer (default, same as Resize8 script)
    Resizer for luma scaling.
    ResizerC (default, same as Resize8 script)
    Resizer for chroma scaling. If only "Resizer" is specified, it's also applied to "ResizerC".
    Last edited by hello_hello; 7th Aug 2019 at 10:20.
    Quote Quote  
  2. I've uploaded a new and improved version of the script. There's a link near the top of the first post.
    Quote Quote  
  3. Bummer. I found an issue with the CropResize8Border - CR8B() - version of the script. Nothing that made it function incorrectly as such, but I borrowed an idea from another script to allow a resizer to be specified as (for example) "Spline36" or "Spline36Resize", but unfortunately I didn't realise it resulted in an error if no resizer was specified at all. That's now fixed. A link for the new version is below and the link in the opening post is updated. The CropResizeBorder - CRB() - version of the script is unchanged.

    CropResizeBorder 2017-04-17.zip
    Last edited by hello_hello; 16th Apr 2017 at 22:27. Reason: spelling
    Quote Quote  
  4. Deleted
    Last edited by hello_hello; 7th Aug 2019 at 10:16.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!