Visualization of MP3 - PHP

偶尔善良 提交于 2019-12-09 12:58:16

问题


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):


(source: anthonymattox.com)

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

I've been told I can't do that 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!


回答1:


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.



来源:https://stackoverflow.com/questions/6638871/visualization-of-mp3-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!