PDA

View Full Version : Cropping Issues.


DNL
3rd May 2008, 11:38
Cropping Issues.

Hello everyone,

Recently I've been messing around with a few of AviSynth's filters, especially Crop and Lanczos4Resize. In general the language seems to make sense, however I can't seem to figure out the logic behind Crop. I've read several tutorails, walkthroughs, guides, even AviSynth's own documentation, and still can't make it work properly.
Apparently the colors are YUV, which can be quite triggy to crop - if I got it right? Whenever I try to crop black borders or letterboxes I'm told "YUV images can only be cropped by even numbers...", if I use even numbers only it'll mess up the output completely as it'll be overcropped.

Would someone mind to break it down for me? Is it possible to crop using uneven numbers without converting from YUV to RGB? And how should I use Crop properly?

I've read through a great number of threads on the forum too without any luck. Hopefully my "issue" isn't considered a dupe.

Best regards,
DNL

stax76
3rd May 2008, 12:23
Maybe StaxRip beta could help you or you could learn from the code it generates. It tries to make cropping as convenient as possible, by default cropps automatically and forces mod 4 or mod16 if no resize filter is used afterwards. Here are screenshots showing AviSynth related features:

http://planetdvb.net/non_drupal/images/StaxRip_crop.jpg

http://planetdvb.net/non_drupal/images/StaxRip_script_editor.png

http://planetdvb.net/non_drupal/images/StaxRip_script_editor_preview.png

http://planetdvb.net/non_drupal/images/StaxRip_filter_editor.png

http://planetdvb.net/non_drupal/images/StaxRip_options.png

http://planetdvb.net/non_drupal/images/StaxRip_options_advanced_aspect_ratio.png

http://planetdvb.net/non_drupal/images/StaxRip_options_advanced_assistant.png

http://planetdvb.net/non_drupal/images/StaxRip_options_advanced_misc.png

http://planetdvb.net/non_drupal/images/StaxRip_filter_profiles.png

neuron2
3rd May 2008, 13:24
You consider one extra pixel to be severe overcropping?

stax76
3rd May 2008, 14:31
It's quite common to encode anamorphic cropping mod 16...

unskinnyboy
3rd May 2008, 15:41
DNL, read this (http://avisynth.org/DataStorageInAviSynth) to understand all the technical details. In short, you are not allowed to crop in odd numbers, because you'd be splitting color information which is shared across pixels (two pixels for YUY2 and four pixels for YV12), and this can have a disastrous effects like chroma shifts on your video down the filter/encoding chain.

If you do want to crop in odd numbers, do it when resizing. This will also be faster.

e.g. Lanczos4Resize(720,400,6,0,-3,0) is the same as if you were allowed to do crop(6,0,-3,0).LanczosResize(720,400).

The reason is that, when resizing, the color information of the frame is resampled anyway, so the resizer can accommodate odd crop values. If you are using crop(..), you can't crop incorrectly even if you want to, because Avisynth will enforce the cropping rules.

DNL
7th May 2008, 22:02
Thank you all for your quick replies. I think I finally get it ;)