Configure FFmpeg Mandelbrot Zoom and Iterations

The mandelbrot video filter in FFmpeg serves as a source filter that dynamically renders the Mandelbrot fractal. This article demonstrates how to control the visual detail and the camera zoom animation of the fractal by configuring the maxiter, start_scale, and end_scale parameters.

Key Parameters for Zoom and Iterations

FFmpeg's mandelbrot filter provides specific options to handle detail depth and zoom range:

  • maxiter: Sets the maximum iteration count for each rendered point. Higher values produce greater edge detail and finer fractal boundaries at deep zoom levels, but require more processing time.
  • start_scale: Defines the initial scale (zoom level) at the start of the video. Lower values represent a closer zoom. The default is 3.0.
  • end_scale: Defines the terminal scale (zoom level) at the end of the video timeline. Setting this significantly lower than start_scale produces a continuous zoom-in effect. The default is 0.3.

Basic Command Structure

Because mandelbrot is a source filter, it is loaded via the lavfi virtual device using the -f lavfi input flag. Parameters are passed as key-value pairs separated by colons:

ffmpeg -f lavfi -i mandelbrot=maxiter=1500:start_scale=3.0:end_scale=0.005 -t 10 output.mp4

In this command:

  • maxiter=1500 increases calculation depth to prevent the edges from turning into flat black blobs as the camera zooms in.
  • start_scale=3.0 begins rendering with the standard full view of the Mandelbrot set.
  • end_scale=0.005 magnifies the fractal view significantly by the end of the duration.
  • -t 10 limits the output video to 10 seconds, which dictates the speed of the zoom transition between start_scale and end_scale.

Setting a Static Zoom Level

If you want a static, non-moving image or a stationary video without zooming, set both start_scale and end_scale to the same value:

ffmpeg -f lavfi -i mandelbrot=maxiter=2000:start_scale=0.01:end_scale=0.01 -t 5 -r 30 static_mandelbrot.mp4

Targeting a Specific Zoom Coordinate

Deep zooms require steering the camera toward an interesting boundary point rather than the center of the set. Use coordinates alongside your iteration and scale settings:

  • start_x and start_y: The starting coordinates on the complex plane (defaults are -0.743643887037158704752191506114774 and -0.131825904205311970493132056385139).
  • end_x and end_y: The ending coordinates to shift the frame position over time.

Example with targeted coordinates and deep iterations:

ffmpeg -f lavfi -i "mandelbrot=maxiter=5000:start_scale=2.0:end_scale=0.00005:start_x=-0.74364388703715:start_y=0.13182590420531:end_x=-0.74364388703715:end_y=0.13182590420531" -t 15 -c:v libx264 zoom_deep.mp4