linux - 如何在 Linux 中创建 MP3 的波形图像?

标签 linux audio mp3 package

给定一个 MP3,我想从文件中提取波形到图像 (.png)

是否有可以满足我需要的软件包?

最佳答案

使用 soxgnuplot 您可以创建基本的波形图像:

sox audio.mp3 audio.dat #create plaintext file of amplitude values
tail -n+3 audio.dat > audio_only.dat #remove comments

# write script file for gnuplot
echo set term png size 320,180 > audio.gpi #set output format
echo set output \"audio.png\" >> audio.gpi #set output file
echo plot \"audio_only.dat\" with lines >> audio.gpi #plot data

gnuplot audio.gpi #run script

enter image description here

要创建更简单/更漂亮的内容,请使用以下 GNU Plot 文件作为模板(将其保存为 audio.gpi):

#set output format and size
set term png size 320,180

#set output file
set output "audio.png"

# set y range
set yr [-1:1]

# we want just the data
unset key
unset tics
unset border
set lmargin 0             
set rmargin 0
set tmargin 0
set bmargin 0

# draw rectangle to change background color
set obj 1 rectangle behind from screen 0,0 to screen 1,1
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "#222222"

# draw data with foreground color
plot "audio_only.dat" with lines lt rgb 'white'

然后运行:

sox audio.mp3 audio.dat #create plaintext file of amplitude values
tail -n+3 audio.dat > audio_only.dat #remove comments

gnuplot audio.gpi #run script

enter image description here

基于 this answer一个类似的问题,该问题在文件格式方面更为普遍,但在所用软件方面则不太普遍。

关于linux - 如何在 Linux 中创建 MP3 的波形图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4468157/

相关文章:

linux - 在ubuntu中检查进程的启动时间后,有没有办法在一定时间后杀死进程?

c++ - 从 AudioInputIOProc 创建 CMSampleBufferRef

android - 使用 Goertzel 算法检测特定频率

c# - 用于 MP3 编辑的音频库

mp3 - Chromium嵌入式框架MP3支持

linux - 保持事件流式ffmpeg rtmp

linux - 如何 SED 到下一行值

linux - bash 将控制权从 expect 返回给用户

java - 如何在Java中循环播放*.wav?

python - 这是在 Python 中列出目录(包括最终子目录)中所有 .mp3 文件的有效方法吗?