How to Generate Audio Spectrum Videos from MP3 songs with FFmpeg

Sometimes I need a simple way to convert an MP3 file into a video suitable for YouTube. Instead of using a static image.

I created a small Bash script that generates an animated frequency spectrum using FFmpeg.

The script uses FFmpeg’s showfreqs filter to generate an animated frequency spectrum from the audio.

How to use the script?

Step 1 : Download the script from gist

wget -c https://gist.githubusercontent.com/mypapit/37817eab6988fe05b87c64025409a894/raw/c04a917e12e9b89e6784783d19061dc771dbed99/spectrum.sh


Step 2: make it executable chmod +x spectrum.sh

Step 3: Use the script – ./spectrum.sh song.mp3

Alternatively you can also convert/export multiple mp3 files : ./spectrum.sh *.mp3

Why Use This Script?

The main advantage is simplicity. There is no video editor, GUI application, or complicated workflow involved. FFmpeg handles the audio analysis, visualization, video encoding, and audio encoding in a single operation.

It is also easy to modify the showfreqs parameters if you want different spectrum sizes, positions, frame rates, scaling methods, or visual styles.

For batch processing MP3 files into simple spectrum videos, this small Bash script provides a practical solution.

Sample Videos

Leave a Reply

Your email address will not be published. Required fields are marked *