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

Semi-automatic bash script for triggering NVIDIA GPU fan in Linux

https://gist.github.com/mypapit/01770a1fa47826db1f50caf45f6a9035.js

Hello everybody. I’m sharing a handy script I use to semi-automatically check my GPU temperature and turn on the fan if things get a bit too warm.

I run this on my dedicated SoHo PC server, which hosts a modest LLM and a Minecraft server (yes, both at the same time).

Feel free to drop any suggestions or ideas in the comments. I’d love to hear how you’d improve it!

p/s: I’ve used GWE and CoolerControl, but it doesn’t fit my use case.