Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

add_borders

add_borders(
  input: Clip,
  #{
    left?: Int,
    right?: Int,
    top?: Int,
    bottom?: Int,
    color?: String | Array<Int> | Array<Float>,
  }
)

Expands one clip by adding constant-color borders around the input frame.

The input must be one fixed-format, fixed-resolution planar Gray, YUV, or planar RGB clip. Border sizes are measured in full-resolution pixels and must be non-negative. For subsampled YUV formats, border sizes must align to the chroma plane divisors.

color defaults to "#000000". Hex colors use #RRGGBB form and are interpreted as full-range RGB display colors. Gray and YUV clips convert that RGB color with a fixed BT.709-style mapping; the conversion does not inspect clip color metadata. For exact plane values, pass an array whose length matches the input plane count. Integer formats require integer array values in the valid sample range. Float formats accept finite integer or float array values.

Examples

output = source("input.mkv").std.add_borders(#{ left: 16, right: 16, top: 8, bottom: 8 })
output = source("input.mkv").std.add_borders(#{
  left: 2,
  right: 2,
  top: 2,
  bottom: 2,
  color: [16, 128, 128],
})
output = source("input.mkv")
  .std.convert_format(#{ format: "rgbp8" })
  .std.add_borders(#{ left: 24, right: 24, color: "#336699" })

Input

One fixed-format, fixed-resolution planar Gray, YUV, or planar RGB clip.

Output

A clip with the same format, timing, and metadata as the input, expanded by the requested border sizes.

Options

  • left (Int, default: 0) – Set the left border size in full-resolution pixels.
  • right (Int, default: 0) – Set the right border size in full-resolution pixels.
  • top (Int, default: 0) – Set the top border size in full-resolution pixels.
  • bottom (Int, default: 0) – Set the bottom border size in full-resolution pixels.
  • color (String | Array<Int> | Array<Float>, default: "#000000") – Set the border color as #RRGGBB or exact per-plane sample values.