Skip to main content
Glitch effects create digital distortion and artifacts for stylistic purposes. MovieLite provides three glitch effect classes: Glitch, ChromaticAberration, and Pixelate.

Glitch

Create digital distortion artifacts simulating VHS glitches, digital corruption, and RGB channel shifts.

Constructor

Glitch(
    intensity: float = 0.5,
    rgb_shift: bool = True,
    horizontal_lines: bool = True,
    scan_lines: bool = False
)
intensity
float
default:"0.5"
Intensity of the glitch effect, from 0.0 (no effect) to 1.0 (maximum glitch). Automatically clamped to [0.0, 1.0].
rgb_shift
bool
default:"True"
Enable RGB channel shifting. Separates red and blue channels horizontally.
horizontal_lines
bool
default:"True"
Enable horizontal displacement lines that create scanline-like glitches.
scan_lines
bool
default:"False"
Enable scan line artifacts (alternating dark lines).

Examples

from movielite import VideoClip, vfx

# Full glitch effect
clip = VideoClip("input.mp4")
clip.add_effect(vfx.Glitch(
    intensity=0.7,
    rgb_shift=True,
    horizontal_lines=True,
    scan_lines=True
))

# Subtle RGB shift only
clip.add_effect(vfx.Glitch(
    intensity=0.3,
    rgb_shift=True,
    horizontal_lines=False,
    scan_lines=False
))

# VHS-style scan lines
clip.add_effect(vfx.Glitch(
    intensity=0.5,
    rgb_shift=False,
    horizontal_lines=True,
    scan_lines=True
))

How It Works

RGB Channel Shift

  • Shifts red channel right by 2% × intensity of frame width
  • Shifts blue channel left by the same amount
  • Creates chromatic separation effect

Horizontal Displacement Lines

  • Generates random horizontal bands
  • Number of bands: 5 × intensity
  • Each band shifts horizontally by random amount
  • Shift range: ±10% × intensity of frame width

Scan Lines

  • Creates alternating dark lines (every other line)
  • Darkness: 15% × intensity
  • Simulates CRT/VHS scan line artifacts
The glitch effect uses time-based seeding for pseudo-random patterns. This ensures consistency - the same frame at the same time will always have the same glitch pattern.
Source: src/movielite/vfx/glitch.py:6-82

ChromaticAberration

Chromatic aberration effect that separates RGB channels, simulating lens distortion.

Constructor

ChromaticAberration(intensity: float = 5.0)
intensity
float
default:"5.0"
Intensity of the aberration in pixels. How far to shift the RGB channels. Minimum value is 0 (automatically enforced).

Examples

from movielite import VideoClip, vfx

# Subtle aberration
clip = VideoClip("input.mp4")
clip.add_effect(vfx.ChromaticAberration(intensity=3.0))

# Strong aberration
clip.add_effect(vfx.ChromaticAberration(intensity=10.0))

How It Works

  • Shifts red channel right by intensity pixels
  • Shifts blue channel left by intensity pixels
  • Green channel remains unchanged
  • Creates color fringing effect similar to lens distortion
Unlike the Glitch effect’s RGB shift (which is percentage-based), ChromaticAberration uses absolute pixel values. This makes it more predictable and consistent across different resolutions.
Source: src/movielite/vfx/glitch.py:84-120

Pixelate

Pixelate effect that reduces resolution to create a blocky, retro appearance.

Constructor

Pixelate(block_size: int = 10)
block_size
int
default:"10"
Size of pixelation blocks in pixels. Larger values = more pixelated. Minimum value is 1 (automatically enforced).

Examples

from movielite import VideoClip, vfx

# Light pixelation
clip = VideoClip("input.mp4")
clip.add_effect(vfx.Pixelate(block_size=8))

# Heavy pixelation
clip.add_effect(vfx.Pixelate(block_size=20))

# Extreme pixelation (8-bit style)
clip.add_effect(vfx.Pixelate(block_size=40))

How It Works

  1. Downscale: Resize frame to (width/block_size, height/block_size) using linear interpolation
  2. Upscale: Resize back to original dimensions using nearest-neighbor interpolation
  3. The nearest-neighbor upscaling creates the blocky effect
The pixelate effect uses OpenCV’s fast resize operations. Even with large block sizes, performance remains excellent.
Source: src/movielite/vfx/glitch.py:122-156

Combining Glitch Effects

Layered Glitch

clip = VideoClip("input.mp4")
clip.add_effect(vfx.ChromaticAberration(intensity=5.0))
clip.add_effect(vfx.Glitch(
    intensity=0.4,
    rgb_shift=False,  # Already have aberration
    horizontal_lines=True,
    scan_lines=True
))

Retro Digital Look

clip = VideoClip("input.mp4")
clip.add_effect(vfx.Pixelate(block_size=12))
clip.add_effect(vfx.Saturation(1.4))  # Boost colors
clip.add_effect(vfx.Contrast(1.2))

VHS Tape Distortion

clip = VideoClip("input.mp4")
clip.add_effect(vfx.Glitch(
    intensity=0.6,
    rgb_shift=True,
    horizontal_lines=True,
    scan_lines=True
))
clip.add_effect(vfx.Saturation(0.8))  # Slightly desaturate
clip.add_effect(vfx.Contrast(0.9))    # Lower contrast

Creative Use Cases

Cyberpunk Aesthetic

clip = VideoClip("input.mp4")
clip.add_effect(vfx.ChromaticAberration(intensity=8.0))
clip.add_effect(vfx.Saturation(1.5))
clip.add_effect(vfx.Contrast(1.3))

Glitch Transition

clip = VideoClip("input.mp4")
# Apply stronger glitch at specific moments
clip.add_effect(vfx.Glitch(intensity=0.8))
clip.add_effect(vfx.FadeOut(0.5))

Censorship/Privacy Effect

# Pixelate faces or sensitive content
clip = VideoClip("input.mp4")
clip.add_effect(vfx.Pixelate(block_size=25))

Performance Considerations

All glitch effects use NumPy array operations which are highly optimized. However, they do process every frame:
  • Pixelate: Very fast (just resize operations)
  • ChromaticAberration: Fast (simple channel shifts)
  • Glitch: Moderate (multiple operations per frame)

Intensity Impact

EffectLow IntensityHigh IntensityPerformance Impact
Glitch0.0 - 0.30.7 - 1.0Low to Moderate
ChromaticAberration1 - 5px15 - 30pxVery Low
Pixelate5 - 1030+Very Low

Technical Details

Glitch Random Seed

The Glitch effect uses time-based seeding:
seed = int(t * 1000) % 1000
np.random.seed(seed)
This ensures:
  • Consistent glitches at the same timestamp
  • Variation between frames (different t values)
  • Reproducible results

Color Channel Order

OpenCV uses BGR color order, so:
  • Channel 0 = Blue
  • Channel 1 = Green
  • Channel 2 = Red
Effects shift channels 0 and 2, leaving channel 1 unchanged.

See Also

Build docs developers (and LLMs) love