我如何在Linux中创建一个MP3的波形图像? [英] How can I create a waveform image of an MP3 in Linux?
本文介绍了我如何在Linux中创建一个MP3的波形图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个MP3,我想从文件中提取波形成一个图片(.png)
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 ?
推荐答案
使用 SOX
和 gnuplot的
您可以创建基本波形图像:
Using sox
and gnuplot
you can create basic waveform images:
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
要创建简单的东西/ prettier,使用下面的GNU绘图文件作为模板(保存为 audio.gpi )
To create something simpler/prettier, use the following GNU Plot file as a template (save it as 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
这篇关于我如何在Linux中创建一个MP3的波形图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文