Skip to main content
The Vignette effect darkens the edges of the frame, creating a classic cinematic look that draws the viewer’s attention to the center of the image.

Constructor

Vignette(intensity: float = 0.5, radius: float = 0.8)
intensity
float
default:"0.5"
Darkness intensity at the edges, from 0.0 to 1.0.
  • 0.0 = no effect (original frame)
  • 1.0 = black edges (maximum vignette)
  • Values between 0 and 1 create varying degrees of darkening
Automatically clamped to [0.0, 1.0].
radius
float
default:"0.8"
Radius of the bright center area, from 0.0 to 1.0.
  • 0.0 = very small bright area (strong vignette)
  • 1.0 = large bright area (subtle vignette)
  • Controls how far the bright area extends before darkening begins
Automatically clamped to [0.0, 1.0].

Examples

Basic Vignette

from movielite import VideoClip, vfx

# Default vignette
clip = VideoClip("input.mp4")
clip.add_effect(vfx.Vignette())

# Subtle vignette
clip.add_effect(vfx.Vignette(intensity=0.3, radius=0.9))

# Strong vignette
clip.add_effect(vfx.Vignette(intensity=0.8, radius=0.6))

Cinematic Look

from movielite import VideoClip, vfx

clip = VideoClip("input.mp4")

# Classic cinema vignette
clip.add_effect(vfx.Vignette(intensity=0.6, radius=0.7))

# Combine with color grading for cinematic feel
clip.add_effect(vfx.Saturation(1.2))
clip.add_effect(vfx.Contrast(1.3))
clip.add_effect(vfx.Vignette(intensity=0.5, radius=0.75))

Extreme Vignette

from movielite import VideoClip, vfx

# Tunnel/spotlight effect
clip = VideoClip("input.mp4")
clip.add_effect(vfx.Vignette(intensity=0.95, radius=0.4))

How It Works

The vignette effect creates a radial gradient that darkens pixels based on their distance from the center:
  1. Calculate distance: For each pixel, compute normalized distance from center
  2. Create mask: Generate radial gradient based on distance and radius
  3. Apply intensity: Scale the mask by the intensity parameter
  4. Multiply: Apply mask to frame to darken edges

Mathematical Formula

# Normalized distance from center
dist = sqrt(((x - cx) / w)² + ((y - cy) / h)²)

# Vignette mask
mask = clip(1.0 - (dist / radius), 0, 1)
mask = 1.0 - (1.0 - mask) × intensity

# Apply to frame
result = frame × mask
Where:
  • (cx, cy) = center of frame
  • (w, h) = frame dimensions
  • clip() = clamp function
Source: src/movielite/vfx/vignette.py:6-69

Parameter Effects

Intensity Comparison

IntensityVisual Effect
0.0No vignette (original)
0.2Very subtle darkening
0.5Moderate vignette (default)
0.8Strong darkening
1.0Black edges

Radius Comparison

RadiusVisual Effect
0.3Small bright center (spotlight)
0.5Medium bright area
0.8Large bright area (default)
1.0Very subtle vignette

Combining with Other Effects

Vintage Film Look

from movielite import VideoClip, vfx

clip = VideoClip("input.mp4")
clip.add_effect(vfx.Sepia(intensity=0.8))
clip.add_effect(vfx.Contrast(0.9))
clip.add_effect(vfx.Vignette(intensity=0.7, radius=0.6))

Modern Cinematic

clip = VideoClip("input.mp4")
clip.add_effect(vfx.Saturation(1.3))
clip.add_effect(vfx.Contrast(1.2))
clip.add_effect(vfx.Brightness(0.95))
clip.add_effect(vfx.Vignette(intensity=0.5, radius=0.75))

Drama/Horror

clip = VideoClip("input.mp4")
clip.add_effect(vfx.Saturation(0.7))  # Desaturate
clip.add_effect(vfx.Brightness(0.8))  # Darken
clip.add_effect(vfx.Contrast(1.4))    # High contrast
clip.add_effect(vfx.Vignette(intensity=0.85, radius=0.5))  # Strong vignette

Soft Focus Portrait

clip = VideoClip("input.mp4")
clip.add_effect(vfx.Blur(intensity=3.0))
clip.add_effect(vfx.Brightness(1.1))
clip.add_effect(vfx.Vignette(intensity=0.4, radius=0.85))

Performance Considerations

The vignette effect uses mask caching for optimal performance:
  • Mask is computed once per frame size
  • Cached masks are reused for subsequent frames
  • Very fast even at high resolutions
  • Negligible performance impact

Caching Behavior

# First frame at 1920×1080: creates mask (~1ms)
# Subsequent frames: uses cached mask (~0.01ms)

# If resolution changes: creates new mask
# Both masks are cached independently
The mask multiplication is the only per-frame operation, which is extremely fast (sub-millisecond for most resolutions).

Advanced Usage

Animated Vignette

While the Vignette effect doesn’t support animation directly, you can create custom animated vignettes:
from movielite import VideoClip, vfx
import math

clip = VideoClip("input.mp4")

# Apply different vignettes to different sections
# (This requires custom implementation or multiple clips)

# Alternative: Combine with fade for gradual vignette
clip.add_effect(vfx.FadeIn(2.0))
clip.add_effect(vfx.Vignette(intensity=0.6, radius=0.7))

Custom Vignette Shapes

The current implementation creates circular/elliptical vignettes. For custom shapes, you would need to:
  1. Extend the Vignette class
  2. Override the mask generation logic
  3. Use custom distance calculations (e.g., rectangular, diamond)

Technical Details

Distance Calculation

The effect normalizes distances by dividing by frame dimensions:
dist_from_center = sqrt(((X - center_x) / w)² + ((Y - center_y) / h)²)
This ensures consistent vignette shape across different aspect ratios.

Mask Generation

The mask is created using NumPy’s ogrid for efficient coordinate grid generation:
Y, X = np.ogrid[:h, :w]
This is more memory-efficient than meshgrid for this use case.

Frame Multiplication

The mask is applied using floating-point multiplication and converted back to uint8:
result = (frame.astype(np.float32) * mask).astype(np.uint8)

Visual Examples

Intensity Variations (radius=0.7)

Intensity 0.0: ⚪⚪⚪⚪⚪  (no vignette)
Intensity 0.3: ⚪⚪⚪⚫⚫  (subtle)
Intensity 0.6: ⚪⚪⚫⚫⚫  (moderate)
Intensity 1.0: ⚪⚫⚫⚫⚫  (strong)

Radius Variations (intensity=0.6)

Radius 0.3: ⚪⚫⚫⚫⚫  (small bright area)
Radius 0.5: ⚪⚪⚫⚫⚫  (medium)
Radius 0.8: ⚪⚪⚪⚫⚫  (large bright area)
Radius 1.0: ⚪⚪⚪⚪⚫  (very subtle)

Common Use Cases

  1. Cinematic Look: intensity=0.5-0.7, radius=0.7-0.8
  2. Portrait Focus: intensity=0.4-0.6, radius=0.8-0.9
  3. Dramatic Effect: intensity=0.7-0.9, radius=0.5-0.6
  4. Subtle Enhancement: intensity=0.2-0.3, radius=0.9-1.0
  5. Spotlight Effect: intensity=0.8-1.0, radius=0.3-0.5

See Also

Build docs developers (and LLMs) love