ffmpeg: audio visualization tricks

Often one wants to share audio online, but it seems like video as a format has many more options: mastodon, twitter, facebook, youtube, all allow to upload video, but not only audio. Here are some ffmpeg tricks, how to add interesting video to your audio file, often autogenerated visuals. All the code is supposed to be used as one line without line-breaks.

 

Audio Vector Scope

The code above creates a mp4 video file with a vectorscope nicely centered inside a 854×480 (480p) video. If you need a 1:1 video, just exclude the pad part:

Documentation on ‘avectorscope’ filter is here: https://ffmpeg.org/ffmpeg-filters.html#avectorscope. One can play with zoom and other options to produce desired form.

 

Show waves

more options: http://www.ffmpeg.org/ffmpeg-filters.html#showwaves

Showspectrum

Above code will create almost completely desaturated spectrum of the audio sliding from right to left. Again, there are various options to tweak, see here: https://ffmpeg.org/ffmpeg-filters.html#showspectrum-1

 

Histogram

Documentation: https://ffmpeg.org/ffmpeg-filters.html#ahistogram

 

Static spectrogram

Sometimes you want to just create a static image.

Above one is in two steps. More info here: http://www.ffmpeg.org/ffmpeg-filters.html#showspectrumpic

 

Drawtext

Add text to any of the above with a “drawtext” filter. More options here: http://www.ffmpeg.org/ffmpeg-filters.html#drawtext-1