用于php开发的声音库

时间:2012-02-04 10:05:18

标签: php audio

我想在php中使用声音库进行项目。 像

这样的neeed功能
  • 高性能
  • 声音优化
  • 开源
  • 混合声音

是最好的PECL套装吗? 任何github或sourceforge项目?

2 个答案:

答案 0 :(得分:2)

单独使用PHP无法正确进行音频处理,您应该看看以下内容:

http://sox.sourceforge.net/

http://ffmpeg.org/

http://lame.sourceforge.net/

您可以使用shell_exec();

之类的内容通过PHP执行上述应用程序

更好的选择是运行cron作业进行批处理。

答案 1 :(得分:0)

您可以使用此库从音乐文件getID3()

中获取idv3信息

这样的事情:

<?
require_once('../getid3/getid3.php');

// Initialize getID3 engine
$getID3 = new getID3;

// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze($filename);

/*
 Optional: copies data from all subarrays of [tags] into [comments] so
 metadata is all available in one location for all tag formats
 metainformation is always available under [tags] even if this is not called
*/
getid3_lib::CopyTagsToComments($ThisFileInfo);

echo $ThisFileInfo['comments_html']['artist'][0]; // artist from any/all available tag formats
echo $ThisFileInfo['tags']['id3v2']['title'][0];  // title from ID3v2
echo $ThisFileInfo['audio']['bitrate'];           // audio bitrate
echo $ThisFileInfo['playtime_string'];            // playtime in minutes:seconds, formatted string

/*
 if you want to see ALL the output, uncomment this line:
*/
echo '<pre>'.htmlentities(print_r($ThisFileInfo, true)).'</pre>';
?>

如果您要重新取样/重新编码音乐文件,可以使用LAME执行此操作。

Fixed bit rate 128kbps encoding:
lame sample.wav sample.mp3

Fixed bit rate jstereo 128kbps encoding, high quality (recommended):
lame -h sample.wav sample.mp3

Average bit rate 112kbps encoding:
lame --abr 112 sample.wav sample.mp3

Fast encode, low quality (no psycho-acoustics):
lame -f sample.wav sample.mp3

Variable bitrate (use -V n to adjust quality/filesize):
lame -h -V 6 sample.wav sample.mp3