View Full Version : Is this the correct way to crop?
orion44
23rd May 2011, 15:28
I haven't used AviSynth for a while, so I'm not sure if I'm using the crop filter correctly.
I have a 720x480 video, and I need to crop 64 pixels top, and 64 pixels bottom.
Is the following setting correct:
Crop(0,64,720,352)
TheSkiller
23rd May 2011, 16:21
Yes that does what you want it to. However, you could also do it like this:
Crop(0,64,-0,-64)
I find this way more convenient. You just have to add a minus in front of the last two crop values (right and bottom) and insert the amount of pixels to crop off.
orion44
23rd May 2011, 16:36
Thanks.
Gavino
23rd May 2011, 18:13
Note also that 0 and -0 are the same (just as in mathematics).
The minus sign is superfluous, though some people like to use it just to emphasise that the value represents a crop value rather than a width (and many probably do it without thinking).
johnmeyer
23rd May 2011, 19:46
I have a follow-up question: what is the correct way to resize back to 720x480 after cropping so that aspect ratio is maintained? I think that I know the answer, namely that I need to crop so that the resulting x/y has the same aspect ratio as 720x480 (assuming PAR=1.0, which is probably not correct for 720x480). However, if there is a simpler way that doesn't require me to do this computation each time, I'd love to know about it.
TheSkiller
23rd May 2011, 21:25
To go back to 480 lines maintaining the aspect ratio you need to add the borders back (?).
AddBorders(0,64,0,64)
I think that I know the answer, namely that I need to crop so that the resulting x/y has the same aspect ratio as 720x480 (assuming PAR=1.0, which is probably not correct for 720x480).No, that would be correct as there is no conversion between square and non-square pixels so things are that easy. What you do by that is zooming into the picture (keeping the aspect ratio by cutting off also the sides). The amount of pixels to crop off from either side in that case would be:
(720 - (352 * 1.5)) / 2 = 96 (inner brackets not really needed but looks better)
Crop(96,64,-96,-64)
Resize(720,480)
TinTime
23rd May 2011, 21:51
720x480 is 3x2. So for every 2 you take off the height you need to take 3 off the width. As TheSkiller says you don't have to worry about PAR.
An alternative would be to do it in the resizer. For example, if you wanted to take 5 off the top and 5 off the bottom:
crop_amount = 2.5
BilinearResize(720, 480, crop_amount*3, crop_amount*2, -crop_amount*3, -crop_amount*2)
The advantage is that you get fine control over the zoom amount. The disadvantage is that Crop is recommended for hard borders, rather than cropping in the resizer. So, depends on what you want to do.
If you use Crop you can add the calculations to TheSkiller's example:
Crop(0, 12, -0, -16)
crop_amount = Float(480 - Height())*(3.0/2)/2
BilinearResize(720, 480, crop_amount, 0, -crop_amount, -0)
johnmeyer
23rd May 2011, 22:45
Many thanks for both replies. Very helpful.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.