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

2 Responses

  1. Luka
    Thank you for sharing this … I am many steps behind you, and wondered how I get a native audio file (like, my own music) into what you are describing here. I realize that you may not have the time or inclination to help lead me along. But if so, I would deeply appreciate it.
    I am interested in how music, poetry and visualizations might come together.
    Peace,
    Kevin
    PS — I wandered here via a friend on Mastodon.

    1. hey there! thanks for stopping by. ffmpeg is very powerful command-line tool. it has a lot of options, but with a lot of information online it can be useful without the need to know “everything”. let’s take the discussion on Mastodon. :)

Leave a Reply