Configure FFmpeg Mandelbrot Zoom and Iterations

This article explains how to customize the visual output of the FFmpeg mandelbrot source filter by adjusting its zoom level and maximum iterations. You will learn the specific parameters required to control the depth of the fractal magnification and the rendering detail of the final video output.

To configure the zoom level and maximum iterations in the FFmpeg mandelbrot filter, you must pass the zoom and max_iter options inside the filter argument. The basic syntax for invoking this filter is -f lavfi -i mandelbrot=option1=value1:option2=value2.

The Zoom Parameter (zoom)

The zoom option sets the magnification level of the fractal. It accepts a double-precision floating-point value or an expression. * Static Zoom: To set a fixed zoom level, assign a static number. For example, zoom=500. * Dynamic Zoom: To create an animation that zooms into the fractal over time, use an expression containing n (the frame number) or t (the time in seconds). For example, zoom='300*1.05^n' increases the zoom by 5% every frame.

The Maximum Iterations Parameter (max_iter)

The max_iter option defines the maximum number of iterations used to determine if a point belongs to the Mandelbrot set. * Detail Level: Higher values yield finer details and sharper boundaries, especially at high zoom levels. Lower values render faster but result in a less detailed, blockier image. * Performance: Increasing this number significantly increases CPU usage. The default value is 7181. You can set it using max_iter=10000.

Example Command

The following command generates a 10-second MP4 video starting with a default zoom that progressively magnifies, using a high iteration count for maximum detail:

ffmpeg -f lavfi -i mandelbrot=zoom='300*1.02^n':max_iter=10000 -t 10 -pix_fmt yuv420p output.mp4

In this command: * zoom='300*1.02^n' starts at a zoom level of 300 and multiplies it by 1.02 for each subsequent frame n. * max_iter=10000 increases the rendering depth from the default to 10,000 iterations. * -t 10 limits the output video duration to 10 seconds. * -pix_fmt yuv420p ensures the output video is compatible with standard media players.