Configure ffmpeg showspectrumpic Window and Color Scale

This article provides a straightforward guide on how to configure the window function and color scale of the showspectrumpic filter in FFmpeg. You will learn the specific parameters required to customize the visual resolution and color themes of your generated audio spectrum images, along with practical command-line examples.

The showspectrumpic filter in FFmpeg converts an audio input into a single, high-resolution spectrum image. To customize how the audio frequencies are analyzed and visually represented, you can adjust the window function and the color scale using the win_func and color options.

Configuring the Window Function (win_func)

The window function determines the mathematical formula used to split the audio into segments for Fourier Transform analysis. Different window functions offer various trade-offs between frequency resolution (sharpness of peaks) and leakage (side-lobe levels).

The parameter used is win_func (or the alias w).

Some of the most common available window functions include: * hann (Default) * hamming * blackman * bartlett * welch * flattop

To set the window function to hamming, use the following syntax:

ffmpeg -i input.wav -filter_complex "showspectrumpic=win_func=hamming" output.png

Configuring the Color Scale (color)

The color scale option changes the color mapping of the intensity of the audio frequencies. This allows you to choose a theme that best highlights the details of your audio track.

The parameter used is color (or the alias c).

Popular color scales include: * intensity (Default - gradient based on intensity) * rainbow (Multi-color spectrum) * fire (Hot red, orange, and yellow) * magma (Dark purple to bright orange) * viridis (Blue to yellow-green gradient) * cool (Cyan and magenta) * green (Monochromatic green)

To set the color scale to fire, use the following syntax:

ffmpeg -i input.wav -filter_complex "showspectrumpic=color=fire" output.png

Combining Both Configurations

To configure both the window function and the color scale simultaneously, separate the arguments with a colon (:) inside the filter options.

Here is a complete command that sets the window function to blackman and the color scale to magma:

ffmpeg -i input.wav -filter_complex "showspectrumpic=win_func=blackman:color=magma" output.png