RemoveBorders - An Avisynth filter for removing black borders
By Ross Thomas <ross@grinfinity.com>
There is no copyright on this code, and there are no conditions on its distribution or use. Do with it what you will.
We all know (and, possibly, love) the AddBorders filter. Here's its conceptual opposite: instead of adding black borders to the clip, this filter removes existing black borders. It's as simple as that.
In order to more accurately determine what is a border and what isn't, RemoveBorders looks at a number of sample frames spread throughout the clip. It then uses the most common values it saw for each edge (i.e. the modal average) and crops the frame correspondingly.
Usage
Code:
RemoveBorders(clip clip, int luma_threshold, int samples, int round_width, int round_height)
Parameter | Meaning | Default |
clip | Specifies the clip to affect. | last |
luma_threshold | Pixels on the edges of the frame within this threshold will be considered part of the border. Any pixel above this threshold means "the border ends here". | 60 |
samples | Specifies the number of sample frames to inspect while determining border sizes. Since this is done upon initialization, using too high a number can cause a significant delay before the clip starts playing. | 5 |
round_width, round_height | The filter will ensure that the final width and height of the frame are multiples of these values. | 4 |
Known Issues
- No Avisynth 2.5/YV12 version yet. That's coming next release.
- No MMX optimization. The YUY2 version doesn't really need it, but the YV12 version will.
To-Do
- A "show" mode to display pre- and post-processing frame size, detected borders, etc.
- Perhaps add FitCD-esque functionality.
History
- 0.1 - First release. Alpha code. Danger, Will Robinson!
Download here: SansGrip's Avisynth Filters [DOWNLOADS]