XAMPP (Windows) 上的 PECL 扩展安装
PECL extension installation on XAMPP (Windows)
我需要一些帮助,我已经尝试过了,但还没有想到要赢。
我需要在 XAMPP(v7.4.5) 上获取 ID3 PECL 运行 Windows。
我昨天花了一天时间尝试浏览 PHP.net 网站上的 PECL articles ,不幸的是,这对我来说意义不大,因为我的知识还没有达到那个水平。我也曾尝试为 ID3 扩展寻找一个 dll 文件,但找不到任何文件。 ID3 PECL 页面只有源文件可供下载。
是否有足够耐心的人可以用更通俗易懂的术语解释这个过程...为我简化一下?
我们将不胜感激任何帮助。
编辑
有人可以帮忙吗?
在 Lelio 的帮助下,我现在有办法从 MP3 中提取信息,我添加了两行来访问 Genre 以及 Attached图片 块。 流派 块有效。然而,附加图片 块没有。
这是更新后的代码,保存为单独的 php 文件,名为 script-mp3-tag-reader.php:
<?php
function tagReader($file)
{
$id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT","TCON","APIC");
$id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT","TCO");
$fsize = filesize($file);
$fd = fopen($file,"r");
$tag = fread($fd,$fsize);
$tmp = "";
fclose($fd);
if (substr($tag,0,3) == "ID3")
{
$result['FileName'] = $file;
$result['TAG'] = substr($tag,0,3);
$result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
}
if($result['Version'] == "4.0" || $result['Version'] == "3.0")
{
for ($i=0;$i<count($id3v23);$i++)
{
if (strpos($tag,$id3v23[$i].chr(0))!= FALSE)
{
$pos = strpos($tag, $id3v23[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+5),3)));
$data = substr($tag, $pos, 9+$len);
for ($a=0;$a<strlen($data);$a++)
{
$char = substr($data,$a,1);
if($char >= " " && $char <= "~")
{
$tmp.=$char;
}
}
if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
if(substr($tmp,0,4) == "TPE1") $result['Artist'] = substr($tmp,4);
if(substr($tmp,0,4) == "TRCK") $result['TrackNo'] = substr($tmp,4);
if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
if(substr($tmp,0,4) == "TCON") $result['Genre'] = substr($tmp,4);
if(substr($tmp,0,4) == "APIC") $result['AttachedPicture'] = substr($tmp,4);
$tmp = "";
}
}
}
if($result['Version'] == "2.0")
{
for ($i=0;$i<count($id3v22);$i++)
{
if (strpos($tag,$id3v22[$i].chr(0))!= FALSE)
{
$pos = strpos($tag, $id3v22[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+3),3)));
$data = substr($tag, $pos, 6+$len);
for ($a=0;$a<strlen($data);$a++)
{
$char = substr($data,$a,1);
if($char >= " " && $char <= "~")
{
$tmp.=$char;
}
}
if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
if(substr($tmp,0,3) == "TP1") $result['Artist'] = substr($tmp,3);
if(substr($tmp,0,3) == "TRK") $result['TrackNo'] = substr($tmp,3);
if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
if(substr($tmp,0,3) == "TCO") $result['Genre'] = substr($tmp,3);
if(substr($tmp,0,3) == "PIC") $result['AttachedPicture'] = base64_encode(substr($tmp,3));
$tmp = "";
}
}
}
return $result;
}
?>
然后在我的 index.php 文件中加载并使用上面的 PHP 脚本,如下所示:
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/script/php/script-mp3-tag-reader.php');
$mp3 = $_SERVER['DOCUMENT_ROOT'].'/media/audio/mp3/test_audio.mp3';
$myResult = tagReader($mp3);
print_r($myResult);
?>
当查看 print_r($myresult);
时,可以看到信息确实存在并且是正确的...只是不是附件图像部分。我似乎正在提取远远超过需要的东西,并且不知道如何只访问我需要的东西。
像这样的东西应该可以解决问题。它最近没有经过测试,但应该可以从 mp3 文件中读取您要查找的数据。
function tagReader($file){
$id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT");
$id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT");
$fsize = filesize($file);
$fd = fopen($file,"r");
$tag = fread($fd,$fsize);
$tmp = "";
fclose($fd);
if (substr($tag,0,3) == "ID3") {
$result['FileName'] = $file;
$result['TAG'] = substr($tag,0,3);
$result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
}
if($result['Version'] == "4.0" || $result['Version'] == "3.0"){
for ($i=0;$i<count($id3v23);$i++){
if (strpos($tag,$id3v23[$i].chr(0))!= FALSE){
$pos = strpos($tag, $id3v23[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+5),3)));
$data = substr($tag, $pos, 9+$len);
for ($a=0;$a<strlen($data);$a++){
$char = substr($data,$a,1);
if($char >= " " && $char <= "~") $tmp.=$char;
}
if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
if(substr($tmp,0,4) == "TPE1") $result['Author'] = substr($tmp,4);
if(substr($tmp,0,4) == "TRCK") $result['Track'] = substr($tmp,4);
if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
$tmp = "";
}
}
}
if($result['Version'] == "2.0"){
for ($i=0;$i<count($id3v22);$i++){
if (strpos($tag,$id3v22[$i].chr(0))!= FALSE){
$pos = strpos($tag, $id3v22[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+3),3)));
$data = substr($tag, $pos, 6+$len);
for ($a=0;$a<strlen($data);$a++){
$char = substr($data,$a,1);
if($char >= " " && $char <= "~") $tmp.=$char;
}
if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
if(substr($tmp,0,3) == "TP1") $result['Author'] = substr($tmp,3);
if(substr($tmp,0,3) == "TRK") $result['Track'] = substr($tmp,3);
if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
$tmp = "";
}
}
}
return $result;
}
我需要一些帮助,我已经尝试过了,但还没有想到要赢。
我需要在 XAMPP(v7.4.5) 上获取 ID3 PECL 运行 Windows。
我昨天花了一天时间尝试浏览 PHP.net 网站上的 PECL articles ,不幸的是,这对我来说意义不大,因为我的知识还没有达到那个水平。我也曾尝试为 ID3 扩展寻找一个 dll 文件,但找不到任何文件。 ID3 PECL 页面只有源文件可供下载。
是否有足够耐心的人可以用更通俗易懂的术语解释这个过程...为我简化一下?
我们将不胜感激任何帮助。
编辑
有人可以帮忙吗?
在 Lelio 的帮助下,我现在有办法从 MP3 中提取信息,我添加了两行来访问 Genre 以及 Attached图片 块。 流派 块有效。然而,附加图片 块没有。
这是更新后的代码,保存为单独的 php 文件,名为 script-mp3-tag-reader.php:
<?php
function tagReader($file)
{
$id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT","TCON","APIC");
$id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT","TCO");
$fsize = filesize($file);
$fd = fopen($file,"r");
$tag = fread($fd,$fsize);
$tmp = "";
fclose($fd);
if (substr($tag,0,3) == "ID3")
{
$result['FileName'] = $file;
$result['TAG'] = substr($tag,0,3);
$result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
}
if($result['Version'] == "4.0" || $result['Version'] == "3.0")
{
for ($i=0;$i<count($id3v23);$i++)
{
if (strpos($tag,$id3v23[$i].chr(0))!= FALSE)
{
$pos = strpos($tag, $id3v23[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+5),3)));
$data = substr($tag, $pos, 9+$len);
for ($a=0;$a<strlen($data);$a++)
{
$char = substr($data,$a,1);
if($char >= " " && $char <= "~")
{
$tmp.=$char;
}
}
if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
if(substr($tmp,0,4) == "TPE1") $result['Artist'] = substr($tmp,4);
if(substr($tmp,0,4) == "TRCK") $result['TrackNo'] = substr($tmp,4);
if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
if(substr($tmp,0,4) == "TCON") $result['Genre'] = substr($tmp,4);
if(substr($tmp,0,4) == "APIC") $result['AttachedPicture'] = substr($tmp,4);
$tmp = "";
}
}
}
if($result['Version'] == "2.0")
{
for ($i=0;$i<count($id3v22);$i++)
{
if (strpos($tag,$id3v22[$i].chr(0))!= FALSE)
{
$pos = strpos($tag, $id3v22[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+3),3)));
$data = substr($tag, $pos, 6+$len);
for ($a=0;$a<strlen($data);$a++)
{
$char = substr($data,$a,1);
if($char >= " " && $char <= "~")
{
$tmp.=$char;
}
}
if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
if(substr($tmp,0,3) == "TP1") $result['Artist'] = substr($tmp,3);
if(substr($tmp,0,3) == "TRK") $result['TrackNo'] = substr($tmp,3);
if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
if(substr($tmp,0,3) == "TCO") $result['Genre'] = substr($tmp,3);
if(substr($tmp,0,3) == "PIC") $result['AttachedPicture'] = base64_encode(substr($tmp,3));
$tmp = "";
}
}
}
return $result;
}
?>
然后在我的 index.php 文件中加载并使用上面的 PHP 脚本,如下所示:
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/script/php/script-mp3-tag-reader.php');
$mp3 = $_SERVER['DOCUMENT_ROOT'].'/media/audio/mp3/test_audio.mp3';
$myResult = tagReader($mp3);
print_r($myResult);
?>
当查看 print_r($myresult);
时,可以看到信息确实存在并且是正确的...只是不是附件图像部分。我似乎正在提取远远超过需要的东西,并且不知道如何只访问我需要的东西。
像这样的东西应该可以解决问题。它最近没有经过测试,但应该可以从 mp3 文件中读取您要查找的数据。
function tagReader($file){
$id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT");
$id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT");
$fsize = filesize($file);
$fd = fopen($file,"r");
$tag = fread($fd,$fsize);
$tmp = "";
fclose($fd);
if (substr($tag,0,3) == "ID3") {
$result['FileName'] = $file;
$result['TAG'] = substr($tag,0,3);
$result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
}
if($result['Version'] == "4.0" || $result['Version'] == "3.0"){
for ($i=0;$i<count($id3v23);$i++){
if (strpos($tag,$id3v23[$i].chr(0))!= FALSE){
$pos = strpos($tag, $id3v23[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+5),3)));
$data = substr($tag, $pos, 9+$len);
for ($a=0;$a<strlen($data);$a++){
$char = substr($data,$a,1);
if($char >= " " && $char <= "~") $tmp.=$char;
}
if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
if(substr($tmp,0,4) == "TPE1") $result['Author'] = substr($tmp,4);
if(substr($tmp,0,4) == "TRCK") $result['Track'] = substr($tmp,4);
if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
$tmp = "";
}
}
}
if($result['Version'] == "2.0"){
for ($i=0;$i<count($id3v22);$i++){
if (strpos($tag,$id3v22[$i].chr(0))!= FALSE){
$pos = strpos($tag, $id3v22[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+3),3)));
$data = substr($tag, $pos, 6+$len);
for ($a=0;$a<strlen($data);$a++){
$char = substr($data,$a,1);
if($char >= " " && $char <= "~") $tmp.=$char;
}
if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
if(substr($tmp,0,3) == "TP1") $result['Author'] = substr($tmp,3);
if(substr($tmp,0,3) == "TRK") $result['Track'] = substr($tmp,3);
if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
$tmp = "";
}
}
}
return $result;
}