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.
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 |
Ross Thomas <ross@grinfinity.com>
Version | Description |
---|---|
0.1 | First release. Alpha code. Danger, Will Robinson! |