A spectrum image shows the frequency content of an audio signal over time, with the low frequencies at the bottom and the high frequencies at the top. It is the visual style of audio editors and music visualizers, and FFmpeg can render it as a still image or a video.

The command

ffmpeg -i in.wav -filter_complex "[0:a]showspectrum=s=1920x1080:mode=combined:slide=fullframe,format=yuv420p[out]" -map "[out]" -t 30 -c:v libx264 -crf 20 spectrum.mp4

What it does

The `showspectrum` filter computes a short-time Fourier transform of the audio and renders the magnitude as a colored image. The `mode` parameter controls the visualization style (`combined`, `separate`); `slide` controls whether the spectrum scrolls or stays full-frame. The output is a video that updates as the audio plays; for a still image, drop the `-t` and add `-frames:v 1`.

Requirements

Any audio input. The filter is in libavfilter. CPU-only — the FFT is not cheap on long files, so budget for a one-time cost equal to a real decode. The output resolution and color are configurable, so the look can be tuned for the target use.

Things to avoid

  • Rendering a spectrum of a file that is mostly silence. The result will be a dark image with no useful information.
  • Confusing showspectrum with showwaves. showwaves is amplitude over time, showspectrum is frequency over time. They look similar at a glance but convey different information.
  • Using a very long file with `slide=fullframe`. The FFT window slides continuously, so a 1-hour audio file produces 1 hour of spectrum video. Trim the input first.
  • Forgetting that the color scale is in dB. A typical range is -90 dB to 0 dB; a -10 dB signal will saturate the color.