How to Use FFmpeg Mandelbrot Filter for Fractal Video
This guide explains how to use FFmpeg’s built-in
mandelbrot video source filter to generate stunning,
animated fractal videos. You will learn the basic command structure,
explore key parameters for customizing the fractal’s appearance and
motion, and see practical examples to render your own high-definition
fractal animations directly from your command line interface.
The Basic Command
Because the Mandelbrot generator is a virtual input device (a source
filter), you must tell FFmpeg to use the Libre-AV filtergraph
(lavfi) library as the input format.
Here is the simplest command to generate a 10-second Mandelbrot fractal video:
ffmpeg -f lavfi -i mandelbrot=s=1280x720:r=30 -t 10 output.mp4-f lavfi: Specifies the input format as Libavfilter.-i mandelbrot: Loads the mandelbrot source filter.s=1280x720: Sets the resolution (width x height) to 720p.r=30: Sets the frame rate to 30 frames per second.-t 10: Sets the output duration to 10 seconds.
Customizing the Fractal with Parameters
The mandelbrot filter accepts several parameters to
customize the position, depth, and zoom level of the fractal. You append
these parameters to the filter name using a colon (:)
separator.
Key Parameters:
start_xandstart_y: The coordinate center point of the render. The default values are-0.743643887037158704752191506114774and0.131825904205311970493132056385139respectively.start_scale: The initial zoom scale. The default is3.0.end_scale: The final zoom scale. Setting this lower than thestart_scalecauses the video to zoom in over time. Setting it to0.000000001results in a deep, continuous zoom.maxiter: The maximum number of iterations. Higher values yield much higher detail but require more CPU processing power to render. The default is7189.inner: Controls the rendering of the inner “lake” of the Mandelbrot set. Options includeblack(default),white,period, andmin.
Creating a Deep Zoom Animation
To generate a dynamic video that continuously zooms into the fractal,
you must set an end_scale value that is significantly
smaller than the start_scale.
The following command generates a high-definition (1080p), 60 FPS zoom animation lasting 15 seconds:
ffmpeg -f lavfi -i mandelbrot=s=1920x1080:r=60:end_scale=0.00000005:maxiter=5000 -t 15 -c:v libx264 -pix_fmt yuv420p fractal_zoom.mp4end_scale=0.00000005: Instructs the camera to zoom deep into the coordinates over the 15-second duration.-c:v libx264: Encodes the video using the H.264 codec.-pix_fmt yuv420p: Ensures the output video file is compatible with standard media players.