开发者

Visualization of MP3 - PHP

开发者 https://www.devze.com 2023-03-18 08:29 出处:网络
I\'m trying to build an mp3 player for my site using JavaScript (and any plugins/frameworks(jQuery)/libraries that are relevant) & html5. So I built the player (more accurately, I implemented jPla

I'm trying to build an mp3 player for my site using JavaScript (and any plugins/frameworks(jQuery)/libraries that are relevant) & html5. So I built the player (more accurately, I implemented jPlayer), and now I want to make a visualizer.

Ok maybe it's not a visualizer (all the names for ways to visualize sound always confused me), I guess what I want is something like this (Update: I just found out this is called a waveform):

Visualization of MP3 - PHP

(source: anthonymattox.com)

Or just something that graphs the amplitude (loudness) of an MP3.

I've been told I can't do th开发者_开发问答at with javascript.

So does anyone know how to do it with php?

More accurately, does anyone know how to graph the loudness/amplitude of an MP3 using PHP? I know that once I get the loudness I can make a graph using GD or the Google graphs image API.

Any API's, ideas, frameworks will all be much appreciated!


Are you adverse to using PHP to call out to command line tools on the system? If not, then I would suggest using mpg123 to convert the mp3 temporarily to .wav, and then a utility called wav2png.py to generate the waveform as a .png image.

This is going to be slow, memory-hungry, and disk-hungry, since it requires conversion to .wav first.

exec("mpg123 -w outfile.wav infile.mp3");

// Not sure of the syntax for wav2png...
exec("wav2png.py outfile.wav");

Disclaimer: I have no experience with wave2png.py, and am merely aware of its existence.

0

精彩评论

暂无评论...
验证码 换一张
取 消