我正在尝试为没有它们的 .mp3 文件编写元标记。使用http://getid3.sourceforge.net/,我可以分析文件,但是当我尝试编写标签时,我得到:
写标签失败!“mp3.mp3”上不允许使用标签格式“曲目标题”
有没有人成功编写过 mp3 元标签?
编辑:我有一个错误,$tagwriter->tagformats
现在已修复。代码现在“成功写入标签”,但新标签“Track Title”标签不在$info = $getID3->analyze($filepath);
...
<?php
require_once 'getid3/getid3.php';
$filepath = '../../mp3/5231239/Gold_Jesus_Culture_Bryan_Katie_Tornwalt_.mp3';
$TaggingFormat = 'UTF-8';
$getID3 = new getID3;
$getID3->setOption(array('encoding'=>$TaggingFormat));
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__, true);
$tagwriter = new getid3_writetags;
$tagwriter->filename = $filepath;
$tagwriter->tagformats = array('id3v2.3');
$tagwriter->tag_encoding = $TaggingFormat;
$tagwriter->tag_data = ["Track title"=>"Gold"];
if ($tagwriter->WriteTags()) {
echo 'Successfully wrote tags<BR>';
if (!empty($tagwriter->warnings)) {
echo 'There were some warnings: '.implode('<br><br>', $tagwriter->warnings);
}
} else {
echo 'Failed to write tags! '.implode('<br><br>', $tagwriter->errors);
}
ini_set("xdebug.var_display_max_children", -1);
ini_set("xdebug.var_display_max_data", -1);
ini_set("xdebug.var_display_max_depth", -1);
$info = $getID3->analyze($filepath);
var_dump($info);