Glitch.avsi — Video “glitch” effects

Functions that provide a sort of “glitched video” effect. These are intended to be used in combination with mask overlays to selectively apply the effect on the video. They include things like letting the video “roll”.

RollHorizontal(c, amount)
Parameters:
  • c (clip) – the clip to roll
  • amount (int) – how many pixels to “roll” - negative moves left, positive moves right (0 returns the original clip).
Returns:

a clip with the image shifted the given number of pixels

Return type:

clip

“Rolls” a clip left or right the given number of pixels.

Note

YUV clips likely use chroma subsampling, meaning that moving them by an amount that isn’t a multiple of the subsampling may cause some weird chroma blending. However it should still work as YUV clips are handled by Overlay.

RollSectionHorizontal(c, top, bottom, amount)
Parameters:
  • c (clip) – the clip to roll
  • top (int) – top y coordinate (inclusive) to include
  • heightOrBottom (int) – when positive, the height, when negative, the y coordinate from the bottom
  • amount (int) – how many pixels to “roll” - negative moves left, positive moves right (0 returns the original clip).

Rolls only a certain section of the clip left or right. This works by overlaying only a certain portion of the clip over itself. As with RollHorizontal(), any amount should work with YUV clips, but choosing one that isn’t a multiple of the chroma subsampling may introduce some blurriness.

Warning

When using this with YUV clips, top and heightOrBottom have to be valid crop values (they’re sent to Crop as-is). For certain YUV formats, this means they must be a multiple of two.

RollVertical(c, amount)
Parameters:
  • c (clip) – the clip to roll
  • amount (int) – how many pixels to “roll” - negative moves up, positive moves down (0 returns the original clip). Note that YUV clips likely use chroma subsampling, meaning that moving them by an amount that isn’t a multiple of the subsampling may cause some weird chroma blending. However it should still work as YUV clips are handled by Overlay.
Returns:

a clip with the image shifted the given number of pixels

Return type:

clip

“Rolls” a clip up or down the given number of pixels.

RollSectionVertical(c, top, bottom, amount)
Parameters:
  • c (clip) – the clip to roll
  • left (int) – top y coordinate (inclusive) to include
  • widthOrRight (int) – when positive, the width, when negative, the number of pixels from the right edge
  • amount (int) – how many pixels to “roll” - negative moves up, positive moves down (0 returns the original clip).

Rolls only a certain section of the clip up or down. This works by overlaying only a certain portion of the clip over itself. As with RollVertical(), any amount should work with YUV clips, but choosing one that isn’t a multiple of the chroma subsampling may introduce some blurriness.

Warning

When using this with YUV clips, left and widthOrRight have to be valid crop values (they’re sent to Crop as-is). For certain YUV formats, this means they must be a multiple of two.

Roll(c, x, y)
Parameters:
  • c (clip) – the clip to roll
  • x (int) – how many pixels to “roll” left or right
  • y (int) – how many pixels to “roll” up or down
Returns:

a clip with the image shifted the given number of pixels

Return type:

clip

“Rolls” a clip by the given number of pixels. This simply combines the effects of RollHorizontal() and RollVertical().

Posterize(c, red[, green[, blue]])
Parameters:
  • c (clip) – an RGB clip to posterize
  • red (int) – the red level - how many “bits” of red should remain - 1 means either 100% or 0%, 2 means 100%, 66%, 33%, 0%, etc.
  • green (int) – if given, the green level, otherwise uses the same value red does
  • blue (int) – if given, the blue level, otherwise uses the same value red does
Returns:

a clip with the image posterized

Return type:

clip

Posterizes an RGB clip. (This only works on RGB clips because it doesn’t really make sense in a YUV clip.) Values past 255 start introducing rounding effects, and 255 does effectively nothing but waste time.

SplitRGB(c, amount)
Parameters:
  • c (clip) – an RGB clip to split RGB channels in
  • amount (int) – the amount to move the different channels by
Returns:

a clip with the RGB channels moved by the given number of pixels

Return type:

clip

Splits RGB channels by amount. The green channel doesn’t move, red is moved amount pixels left, and blue is moved amount pixels right. Amount may be negative, in which case red is moved right and blue is moved left.

This is simply:

amount == 0 ? c : MergeRGB(c.RollHorizontal(-amount), c, c.RollHorizontal(amount))

Similar code can be used to move RGB channels in other directions, but since the horizontal split is the most frequent “glitch” effect it’s provided.

SplitChroma(c, amount)
Parameters:
  • c (clip) – a YUV clip to split chroma channels in
  • amount (int) – the amount to move the different channels by - note that because this is moving the chroma planes, this is by pixels in in the chroma plane and not the luma plane. So in YV12, a value of 1 will actually shift the planes 2 pixels apart.
Returns:

a clip with the chroma planes shifted

Return type:

clip

Splits the UV channels by amount. Luma is not moved.

This is simply:

amount == 0 ? c : YToUV(c.UToY().RollHorizontal(-amount), c.VToY().RollHorizontal(amount), c)

Similar code can be used to move the chroma planes in other directions, but since the horizontal split is the most frequent “glitch” effect it’s provided.