MP3 and OGG tags in PHP

2020-06-25 04:51发布

Except http://us3.php.net/manual/en/book.ktaglib.php and http://getid3.sourceforge.net/ does anyone know of any other way to work from PHP with tags on audio files?

I need to read and write them, and KTagLib seems a little too much for the job, and also don't really get the documentation, and getID3 seems to only write ID3v1 tags.

4条回答
▲ chillily
2楼-- · 2020-06-25 05:30

with ktaglib:

$tag = new KTaglib_MPEG_File('test.mp3')->getID3v2Tag()->getFrameList();
echo "Album: " . $tag["TIT2"];
echo "Album: " . $tag["TALB"];
echo "Artist: " . $tag["TPE1"];
查看更多
女痞
3楼-- · 2020-06-25 05:41

There are also other ID3 functions in PHP just for reading: http://php.oregonstate.edu/manual/en/book.id3.php

You should try stable version of getID3(), there is this comment for beta:

v2.0.0-b5 can write only some tag formats:

ID3v1

APEtag

FLAC

Ogg

Vorbis

Lyrics3

In stable, they should be supported (if the don't lie):

Tag formats:

ID3v1 (v1.0 & v1.1)

ID3v2 (v2.2, v2.3 & v2.4)

APE tags (v1 & v2)

(Ogg) VorbisComment

Lyrics3 (v1 & v2)

查看更多
姐就是有狂的资本
4楼-- · 2020-06-25 05:42

At the moment, to write vorbis tags to an ogg/vorbis file, GetId3 requires vorbiscomment installed on the server.

查看更多
Lonely孤独者°
5楼-- · 2020-06-25 05:44

If you can't use the php module for the id3 tags (sometimes you can't install modules on some hostings), you can use this function:

http://www.barattalo.it/2010/02/22/reading-mp3-informations-with-php-id3-tags/

查看更多
登录 后发表回答