How to Use the FFmpeg Mandelbrot Filter
This article provides a quick guide on how to use the
mandelbrot video source filter in FFmpeg to generate
fractal animations. You will learn the basic command syntax, key
parameters for customization, and practical examples to render your own
Mandelbrot video sequences.
What is the FFmpeg Mandelbrot Filter?
The mandelbrot filter is a library filter (lavfi) source
in FFmpeg that generates an animated video of the Mandelbrot set.
Instead of processing an existing input video file, it procedurally
generates frames on the fly, making it an excellent tool for testing
render speeds, generating visuals, or creating motion graphics.
Basic Command Syntax
To generate a default Mandelbrot video, you must tell FFmpeg to use
the lavfi virtual input format. Here is the simplest
command to create a 10-second video:
ffmpeg -f lavfi -i mandelbrot -t 10 output.mp4In this command: - -f lavfi specifies the library filter
input container. - -i mandelbrot calls the Mandelbrot
source generator. - -t 10 sets the duration of the output
video to 10 seconds.
Customizing Parameters
You can customize the resolution, frame rate, zoom level, and
rendering depth of the fractal by passing parameters to the filter. The
options are appended to the filter name using an equals sign
= and separated by colons :.
Here are the key parameters:
size(ors): Sets the output resolution. Default is640x480.rate(orr): Sets the frame rate. Default is25.maxiter: Sets the maximum number of iterations. Higher values increase render detail but require more CPU power. Default is7189.start_scale: The initial zoom scale. Default is3.0.end_scale: The final zoom scale. Decreasing this value zooms into the fractal. Default is0.3.
Practical Examples
1. Generating a High-Definition Video
To generate a 1080p video at 30 frames per second, use the following command:
ffmpeg -f lavfi -i mandelbrot=size=1920x1080:rate=30 -t 15 hd_mandelbrot.mp42. Creating a Deep Zoom Animation
To create a dramatic zoom effect, adjust the start_scale
and end_scale values. Lower scale numbers represent a
deeper zoom:
ffmpeg -f lavfi -i mandelbrot=s=1280x720:start_scale=3.0:end_scale=0.0005 -t 20 zoom.mp43. Increasing Fractal Detail
If you zoom in deeply, the fractal might lose detail. You can
increase the maxiter parameter to keep the edges sharp,
though this will increase rendering time:
ffmpeg -f lavfi -i mandelbrot=s=1280x720:maxiter=20000:start_scale=1.5:end_scale=0.001 -t 12 detailed_zoom.mp4