Log in

View Full Version : Avisynth and VapourSynth cropping preview functions


hello_hello
29th January 2022, 08:46
The cropping preview function now comes in both Avisynth and VapourSynth flavours.
The examples below use Avisynth syntax, but the VapourSynth version works in much the same manner (see the help file for exact details).
The name of the script has been changed to CPreview for both versions.
See post #5 for the additional functions added.

CPreview 2025-03-25 (Cropping Preview).zip (https://files.videohelp.com/u/210984/CPreview%202025-03-25%20%28Cropping%20Preview%29.zip)

This function is based on the previews from the CropResize (https://forum.doom9.org/showthread.php?t=176667) script.
I thought I'd upload it for anyone who's interested. Sometimes it's easier to look at what you're cropping before actually cropping it.

It's very simple to use, although there is a help file. When using the Crop() function, you can use pCrop() for a cropping preview (naturally when you adjust the cropping you need to refresh the preview), and when you're happy, remove the "p" from the beginning of the function name to crop.

There's three cropping previews, and the other two are enabled by adding more "p"s.
Obviously this image doesn't really need cropping, but to demonstrate...

pCrop shows the cropping preview as yellow lines.

pCrop(18,20,-26,-36)

https://i.postimg.cc/N0T6tMp3/Crop-Preview-Preview-1.jpg


ppCrop shows the cropping preview as yellow transparent borders.

ppCrop(18,20,-26,-36)

https://i.postimg.cc/4dgzxg0m/Crop-Preview-Preview-2.jpg


And pppCrop shows the cropping preview as the inverse of the picture, much like AvsPmod (https://www.videohelp.com/software/AvsP)'s preview.

pppCrop(18,20,-26,-36)

https://i.postimg.cc/768NJ75P/Crop-Preview-Preview-3.jpg


Naturally when you're happy, you just remove the "p"s to crop.

Crop(18,20,-26,-36)

https://i.postimg.cc/rsgGHPQz/Crop-Preview-Cropped.jpg


Because sometimes it's handy, there's also wrapper functions for displaying the current frame number and/or time over the video. The help file has details, but they work by appending letters to the other side of the function name, and can be used with or without a cropping preview enabled.

CropP(18,20,-26,-36)

https://i.postimg.cc/1380WM65/Crop-Preview-Position.jpg

hello_hello
29th January 2022, 22:29
And a quick update to change the cropping to unnamed arguments to match the Crop function as it makes more sense.
Also changed the default behaviour of the CropF, CropT and CropP functions so they apply the cropping. New version dated 2022-01-30.

hello_hello
25th September 2023, 15:51
There's a link for a new version dated 2023-09-25 in the opening post.

The Avisynth version hasn't changed in functionality (just cleaned up the syntax a bit) but there's now also a VapourSynth flavour.

hello_hello
1st October 2023, 18:10
There's a link for a new version dated 2023-10-02 in the opening post.

hello_hello
10th June 2024, 14:32
There's a link for a new version dated 2024-06-10 in the opening post.
I've added some additional wrapper functions for displaying the cropping previews, but without displaying any text.
The new wrapper functions are used by prefixing Crop() with "q" instead of "p", because I couldn't think of a more appropriate letter to use and alphabetically "q" comes after "p".

So now you can also use
qCrop(18,20,-26,-36)
or
qqCrop(18,20,-26,-36)
or
qqqCrop(18,20,-26,-36)

hello_hello
14th June 2024, 22:41
There's a link for a new version dated 2024-06-15 in the opening post.

For the Avisynth version I fixed not being able to specify right and bottom cropping as a positive value.
For both versions there's a small function added to the end of the scripts. Modifying the return value will change the thickness of the lines used for the first cropping preview.

hello_hello
3rd October 2024, 18:52
There's a link for a new version dated 2024-10-04 in the opening post.

For the VapourSynth version the included RGBColor function has been updated (it's used to create the yellow lines for the cropping preview).
The cropping text now displays the modulus of the video as well as the dimensions.

https://imgur.com/0CBLfKd.png

hello_hello
16th October 2024, 08:42
There's a link for a new version dated 2024-10-16 in the opening post.

The Vapoursynth version now fully supports half float formats by converting to 32 bit float before adding any text, then converting back to half float.
No changes to the Avisynth version

hello_hello
27th March 2025, 13:30
There's a link to a new version of the cropping preview function dated 2025-03-25 in the opening post.

The Avisynth version hasn't changed if I remember correctly.

VapourSynth version:
The SubText plugin is now used by default for displaying text, however it's not a strict requirement as CPreview will fall back to using VapourSynth's Text function if the SubText plugin isn't loaded.