Avisynth and VapourSynth cropping preview functions
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.
CPreview 2023-10-02 (Cropping Preview).zip
This function is based on the previews from the CropResize 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)
ppCrop shows the cropping preview as yellow transparent borders.
ppCrop(18,20,-26,-36)
And pppCrop shows the cropping preview as the inverse of the picture, much like AvsPmod's preview.
pppCrop(18,20,-26,-36)
Naturally when you're happy, you just remove the "p"s to crop.
Crop(18,20,-26,-36)
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)
![]()
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 9 of 9
Thread
-
Last edited by hello_hello; 1st Oct 2023 at 13:11.
-
New version dated 2022-01-29 in the opening post. Functionality hasn't changed. Just cleaned up the syntax and adjusted the text display a little.
Last edited by hello_hello; 29th Jan 2022 at 02:55.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
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.Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
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.Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Had a quick look at the Vapoursynth script (haven't tested it):
Code:Source444 = vc.resize.Bicubic(Source, format=vs.RGB48) \ if (Source_Sample_Type != 0) and (SCFamily == vs.RGB) else \ vc.resize.Bicubic(Source, format=vs.GRAY16) \ if (Source_Sample_Type != 0) and (SCFamily == vs.GRAY) else \ vc.resize.Bicubic(Source, format=vs.YUV444P16) \ if (Source_Sample_Type != 0) and (SCFamily == vs.YUV) else \ eval("vc.resize.Bicubic(Source, format=vs.YUV444P" + str(Source_Bits)+ ")") \ if (SCFamily == vs.YUV) and (Is444 is False) else Source
Cu Selurusers currently on my ignore list: deadrats, Stears555 -
Did I do a silly or does that syntax convert float to integer?
The reason float is converted to integer for the preview is because the mask clip used for MaskMerge has to be full range, so the appropriate scaling must be used for Levels when converting YUV masks to full range and I'm not sure how to best do it for float. I wasn't sure if YUV float is always full range anyway, and the Levels function description says
Note that the range behavior is unintuitive for YUV float formats since the assumed range will be 0-1 even for the UV-planes.
In the end the easy/lazy way to deal with float seemed to be to just convert it to 16 bit for the preview. I'm pretty sure I tested it, but if the result is incorrect I guess I should change it.
Thinking about it now, VapourSynth makes previewing cropping while splicing clips easier because it supports splicing of clips with different dimensions. It's probably not needed when using the Cropping Preview function but a similar function is built into CropResize, the idea being you can splice clips while enabling a single copping preview this way:
clip = core.std.Splice([
CR.CropResize(clip[0:99], 640,480, 8, 10, 2, 4),
CR.CropResize(clip[100:199], 640,480, 16, 10, 6, 4, CPreview=1),
CR.CropResize(clip[200:299], 640,480, 8, 10, 2, 4)
], mismatch=True)
I guess that'd fail for float because the clip with the cropping preview enabled is converted to integer and clips of different bitdepths can't be spliced.
You could work around it by temporarily converting the source clip to integer before splicing, but it's a scenario I hadn't considered. It's the only time converting float to 16 bit for a preview might be an issue but it probably isn't a problem for the stand-alone cropping preview function.
I kind-of remember another reason for float being a pain but that could be wishful thinking. Maybe I should re-think the float conversion at some stage though.Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
There's a link for a new version dated 2023-10-02 in the opening post.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview)
Similar Threads
-
Create a function in Avisynth to apply this denoiser
By zerowalk in forum EditingReplies: 3Last Post: 19th Aug 2019, 08:45 -
Avisynth - How to define default values for function parameters?
By CoralMan in forum EditingReplies: 5Last Post: 1st Aug 2019, 12:09 -
Avisynth Loop function
By pooksahib in forum Video ConversionReplies: 16Last Post: 29th May 2016, 13:03 -
Using avisynth's 'amplify' function
By pooksahib in forum Video ConversionReplies: 53Last Post: 25th May 2016, 03:23 -
Any ffmpeg GUI that has a video preview cropping?
By imdaman in forum EditingReplies: 2Last Post: 12th Jul 2015, 01:57