Posted: . At: 11:58 AM. This was 5 years ago. Post ID: 13267
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to get a nice waveform display with the MPV media player on Linux.

Play a music file in your terminal with a nice visualization, using this one-liner. This is very nice way to get a simple animation whilst playing a music file. MPV does support a massive amount of playing options, and using a visualization while playing music is another hidden feature.

mpv --config=no --quiet --vo=tct --lavfi-complex='[aid1]asplit[ao][a1];[a1]avectorscope=r=25:m=lissajous_xy:bc=200:gc=100:rc=75:bf=5:gf=3:rf=1:zoom=2[vo]' https://www.gnu.org/music/markushaist-free-software-song.ogg

Use this version for a traditional waveform visualization.

mpv --config=no --quiet --vo=tct --lavfi-complex='[aid1]asplit[ao][a1];[a1]showwaves=mode=cline:colors=white:rate=25[vo]' https://www.gnu.org/music/markushaist-free-software-song.ogg

This is what the second example looks like in the Konsole terminal. It might look different depending on the terminal you use, whether it is urxvt or xterm.

MPV visualization example on Linux.
MPV visualization example.

This is a tweaked version of the first example, this works very well for playing music in a terminal.

mpv --config=no --quiet --vo=tct --lavfi-complex='[aid1]asplit[ao][a1];[a1]avectorscope=r=25:m=lissajous_xy:bc=100:gc=100:rc=75:bf=5:gf=3:rf=1:zoom=1[vo]' https://www.gnu.org/music/markushaist-free-software-song.ogg

This is a very cool trick for playing music in a terminal. It is a good alternative to other music players. Maybe play around with the filters and see if you can get a more random result.

6 thoughts on “How to get a nice waveform display with the MPV media player on Linux.”

  1. mpv –config=no –audio-device=pulse/alsa_output.usb-0c76_USB_PnP_Audio_Device-00.analog-stereo –quiet –vo=tct –lavfi-complex='[aid1]asplit[ao][a1];[a1]showcqt[vo]’ /media/sdc2/Projects/Music/NSF/amazingmusic/NSF_Archive/Chiptune_Artists/Originals/*

    showcqt ftw!

    thanks!

    Reply
  2. i already had a small mpv script with custom status but this made it miles better.Thanks for the amazing one-liner!

    Reply
  3. The above commands were meant for audio. However, with some tweaks, the waveform can be overlaid on the original video. I find this useful for detecting the exact frame for some scene changes. I also prefer log scale to maximize the height of the graph. Example:

    --lavfi-complex='[aid1] asplit [ao] [a1] ; [a1] showwaves=size=1920x1080:rate=24000/1001:mode=cline:colors=white:scale=log [vida] ; [vid1] [vida] overlay [vo]'
    Reply
  4. both filters fail for me with mpv 0.32.0

    [ffmpeg] AVFilterGraph: No such filter: ‘[aid1]asplit[ao][a1];[a1]avectorscope=r=25:m=lissajous_xy:bc=100:gc=100:rc=75:bf=5:gf=3:rf=1:zoom=1[vo]’
    [lavfi] parsing the filter graph failed

    Reply
    • I am using this version, maybe you have a different version?

      4.4 Sun Mar 29 jason@Yog-Sothoth 0: $ mpv --version
      mpv 0.27.2 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
       built on UNKNOWN
      ffmpeg library versions:
         libavutil       55.78.100
         libavcodec      57.107.100
         libavformat     57.83.100
         libswscale      4.8.100
         libavfilter     6.107.100
         libswresample   2.9.100
      ffmpeg version: 3.4.6-0ubuntu0.18.04.1
      Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.