How can I create a waveform image of an MP3 in Linux?

前端 未结 7 1253
旧时难觅i
旧时难觅i 2021-02-01 21:03

Given an MP3 I would like to extract the waveform from the file into an image (.png)

Is there a package that can do what I need ?

7条回答
  •  天命终不由人
    2021-02-01 21:44

    Building on the answer of qubodup

    # install stuff
    apt install gnuplot
    apt install sox
    apt install libsox-fmt-mp3
    
    #create plaintext file of amplitude values
    sox sound.mp3 sound.dat
    
    # run script saved on audio.gpi file
    gnuplot audio.gpi
    

    You can also comment the "set output ..." line in the configuration file and do

    gnuplot audio.gpi > my_sound.png
    

    The configuration file is audio.gpi in this case and inside it has

    #!/usr/bin/env gnuplot
    
    set datafile commentschars ";"
    
    set terminal png #size 800,400
    set output "sound.png"
    
    unset border
    unset xtics
    unset ytics
    
    set key off
    
    plot "sound.dat" with lines
    

    Which produces images like the following

    I wanted no axis, no legend, png (much smaller than svg).

提交回复
热议问题