是否有(某处)用于 Windows 的命令行程序,可以从 MP3/WAV 创建 PNG/JPEG 视觉效果?
5 回答
Sox是“音频处理的瑞士军刀”,可以从声音文件中生成准确的 PNG 频谱图。它几乎可以播放任何东西,并且二进制文件可用于 Windows。在最基本的层面上,你会使用这样的东西:
sox my.wav -n spectrogram
如果您想要一个没有轴、标题、图例和 100 像素高的浅色背景的频谱图:
sox "Me, London.mp3" -n spectrogram -Y 130 -l -r -o "Me, London.png"
例如,如果您只想分析单个频道,Sox 接受很多选项。如果您需要更酷的视觉效果,您可以对生成的 PNG 进行后处理。
这是命令行中有关所有可用参数的简短概述,联机帮助页有更多详细信息:
-x num X-axis size in pixels; default derived or 800
-X num X-axis pixels/second; default derived or 100
-y num Y-axis size in pixels (per channel); slow if not 1 + 2^n
-Y num Y-height total (i.e. not per channel); default 550
-z num Z-axis range in dB; default 120
-Z num Z-axis maximum in dBFS; default 0
-q num Z-axis quantisation (0 - 249); default 249
-w name Window: Hann (default), Hamming, Bartlett, Rectangular, Kaiser
-W num Window adjust parameter (-10 - 10); applies only to Kaiser
-s Slack overlap of windows
-a Suppress axis lines
-r Raw spectrogram; no axes or legends
-l Light background
-m Monochrome
-h High colour
-p num Permute colours (1 - 6); default 1
-A Alternative, inferior, fixed colour-set (for compatibility only)
-t text Title text
-c text Comment text
-o text Output file name; default `spectrogram.png'
-d time Audio duration to fit to X-axis; e.g. 1:00, 48
-S time Start the spectrogram at the given time through the input
我创建了一个小型 PHP 库来执行此操作:https ://github.com/jasny/audio
它的工作原理如下。它使用
sox TRACK.mp3 -t raw 4000 -c 1 -e floating-point -L -
这会将轨道下采样到 4k 并将所有内容放在 1 个通道中。
接下来,我获取大量样本(每个像素)并计算最小值和最大值。使用它们来绘制波形。
我在这里发现这个很好(来自网络档案,原来的已经不见了): http ://web.archive.org/web/20140715171716/http://andrewfreiday.com/2011/12/04/optimizing-the -php-mp3-波形发生器/
它基于 PHP,并通过 shell 使用跛脚。
更新:该网站似乎不时死去,但是这里是回购:https ://github.com/afreiday
Wander Nauta 的更新的批处理版本,它为文件夹中的所有 wav 文件生成直方图 (BASH/DASH):
for i in *.wav; do ./sox $i -n spectrogram -y 130 -l -r -o ${i%%.wav}.png; done