AddBorders: Difference between revisions

From Avisynth wiki
Jump to navigationJump to search
add link to avs+ documentation
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<div {{BlueBox2|40|0|3px solid purple}} >
{{AvsPlusFullname}}<br>
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/addborders.html https://avisynthplus.readthedocs.io]
</div>
Add black or colored borders, increasing frame size. This has several common uses:  
Add black or colored borders, increasing frame size. This has several common uses:  
* Adjust the [[Aspect_ratios|aspect ratio]] (make a 4:3 clip into 16:9 without stretching)
* Adjust the [[Aspect_ratios|aspect ratio]] (make a 4:3 clip into 16:9 without stretching)
Line 8: Line 14:
== Syntax and Parameters ==
== Syntax and Parameters ==
{{FuncDef
{{FuncDef
|AddBorders( clip ''clip'', int ''left'', int ''top'', int ''right'', int ''bottom'' [, int ''color'' ] )
|AddBorders( clip ''clip'', int ''left'', int ''top'', int ''right'', int ''bottom'' [, int ''color'' ] [, int ''color_yuv'' {{AvsPluscon}}])
}}
}}


Line 20: Line 26:
::Border color; specified as an RGB value. See [[Colors|this page]] for more information on specifying colors.
::Border color; specified as an RGB value. See [[Colors|this page]] for more information on specifying colors.
::*For YUV clips, colors are converted from full-range (0&ndash;255) to tv-range (16&ndash;235).
::*For YUV clips, colors are converted from full-range (0&ndash;255) to tv-range (16&ndash;235).
:{{Par2|color_yuv|int|}} {{AvsPluscon}}
::Specifies the color of the border using YUV values. It requires setting pixel_type to one of the YUV formats; otherwise it doesn't do anything.
::Similar to {{FuncArg|color_yuv}} in BlankClip


== Examples and Notes ==
== Examples and Notes ==
<div style="max-width:54em" >
<div style="max-width:54em" >
* Add ''letterbox'' (top and bottom) borders:
* Add ''letterbox'' (top and bottom) borders:
<div {{BoxWidthIndent|36|2}} >
<div {{BoxWidthIndent|42|2}} >
  ## add dark blue borders, using [[Colors|hex color notation]]
  ## add dark blue borders, using [[Colors|hex color notation]]
  AddBorders(0, 86, 0, 86, $00008B)  
  AddBorders(0, 86, 0, 86, $00008B)  
Line 30: Line 40:
  ## same as above, using [[Preset_colors|named preset color]]
  ## same as above, using [[Preset_colors|named preset color]]
  AddBorders(0, 86, 0, 86, color_darkblue)  
  AddBorders(0, 86, 0, 86, color_darkblue)  
## full scale black border using color_yuv [[Colors|hex color notation]]
AddBorders(0, 86, 0, 86, color_yuv = $008080)
</div>
</div>



Latest revision as of 05:33, 18 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io


Add black or colored borders, increasing frame size. This has several common uses:

  • Adjust the aspect ratio (make a 4:3 clip into 16:9 without stretching)
  • Splice a smaller resolution clip to a larger one without resizing
  • Together with Crop, shift a clip horizontally or vertically – see below.

See also: Letterbox, which adds borders without changing frame size.


Syntax and Parameters

AddBorders( clip clip, int left, int top, int right, int bottom [, int color ] [, int color_yuv AVS+])

int  left, top, right, bottom = (required)
Border width in pixels.
  • For YUY2 and YV16 sources, left and right must be mod2 (divisible by 2).
  • For YV411 sources, left and right must be mod4 (divisible by 4).
  • For YV12 sources, all four border widths must be mod2.
int  color = (black)
Border color; specified as an RGB value. See this page for more information on specifying colors.
  • For YUV clips, colors are converted from full-range (0–255) to tv-range (16–235).
int  color_yuv =
AVS+
Specifies the color of the border using YUV values. It requires setting pixel_type to one of the YUV formats; otherwise it doesn't do anything.
Similar to color_yuv in BlankClip

Examples and Notes

  • Add letterbox (top and bottom) borders:
## add dark blue borders, using hex color notation
AddBorders(0, 86, 0, 86, $00008B) 

## same as above, using named preset color
AddBorders(0, 86, 0, 86, color_darkblue) 

## full scale black border using color_yuv hex color notation
AddBorders(0, 86, 0, 86, color_yuv = $008080) 
  • Be aware that many older lossy compression algorithms don't deal well with solid-color borders, unless the border happens to fall on a macroblock boundary (16 pixels for MPEG).
  • Use AddBorders in combination with Crop to shift an image without changing the frame size:
# Shift an image 2 pixels to the right
Crop(0, 0, Width-2, Height)
AddBorders(2, 0, 0, 0)
Note, shifting this way must be done in 1- or 2-pixel increments, depending on color format.
You can shift in sub-pixel increments with Resize.