MP3 的可视化 - PHP [英] Visualization of MP3 - PHP

查看:23
本文介绍了MP3 的可视化 - PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JavaScript(以及任何相关的插件/框架(jQuery)/库)为我的网站构建一个 mp3 播放器 &html5.所以我构建了播放器(更准确地说,我实现了 jPlayer),现在我想做一个可视化工具.

好吧,也许它不是一个可视化工具(所有可视化声音的方法的名称总是让我感到困惑),我想我想要的是这样的东西(更新:我刚刚发现这被称为
(来源:anthonymattox.com)

或者只是用图表表示 MP3 的振幅(响度).

有人告诉我无法使用 javascript 做到这一点.

那么有谁知道如何用 php 做到这一点?

更准确地说,有人知道如何使用 PHP 绘制 MP3 的响度/幅度吗?我知道,一旦获得响度,我就可以使用 GD 或 Google 图形图像 API 制作图表.

任何 API、想法、框架都将不胜感激!

解决方案

您是否反对使用 PHP 调用系统上的命令行工具?如果没有,那么我建议使用 mpg123 将 mp3 临时转换为 .wav,然后使用名为 wav2png.py 将波形生成为 .png 图像.

这会很慢,很耗内存,而且很耗磁盘,因为它需要先转换为 .wav.

exec("mpg123 -w outfile.wav infile.mp3");//不确定 wav2png 的语法...exec("wav2png.py outfile.wav");

免责声明:我没有使用 wave2png.py 的经验,只知道它的存在.

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!

解决方案

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.

这篇关于MP3 的可视化 - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆