monarlte Posted March 11, 2007 Share Posted March 11, 2007 Hi. I run a php web site that allows administrators to upload MP3 files. The form asks for the artist, title, and date as input along with the file to upload. I would like to modify the metadata attributes of the mp3 file that is uploaded. (I want to change the song title, artist name, year, genre of the mp3 file.) I am wondering how I could do this using php? I do not want to install pear modules or anything like that, I would like to do it using just straight php code. Can't I load the file into a binary stream and then some how modify the metadata in the binary stream and save it to a new file? thanks so much, Monarlte Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/ Share on other sites More sharing options...
Psycho Posted March 11, 2007 Share Posted March 11, 2007 Use the getID3() class vailable here: http://getid3.sourceforge.net/ Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/#findComment-204944 Share on other sites More sharing options...
monarlte Posted March 11, 2007 Author Share Posted March 11, 2007 Thanks for your reply. But, I was wondering how I could do it myself from scratch? thanks again, Monarlte Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/#findComment-204959 Share on other sites More sharing options...
ShogunWarrior Posted March 11, 2007 Share Posted March 11, 2007 Look up the ID3/ID3 v2 Specification. AFAIK you just look for "TAG" in the last 128 bytes of the MP3 file. Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/#findComment-204965 Share on other sites More sharing options...
monarlte Posted March 11, 2007 Author Share Posted March 11, 2007 Thank you ShogunWarrior. I really appreciate that. I have worked with text-based files, but I have never worked with binary type files. Would you be able to give me some guidance here? That code that you displayed in your last message... What is it suppose to be doing? How do I modify the artist name and song title in the binary data? When you say I need to search for "TAG": how can I search for a string in a binary stream if it is not text-based? And once I find it what do I do, is there an ending tag (something like "/TAG" or "</TAG>") so I know where the metadata information stops? thanks so much, Monarlte Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/#findComment-204967 Share on other sites More sharing options...
ShogunWarrior Posted March 12, 2007 Share Posted March 12, 2007 There are two main ID3 versions, ID3 and ID3v2. While alot of files use v2, many still use the v1 so for backwards-compatability you should probably implement both. Here is the ID3v2 spec: http://www.id3.org/id3v2.4.0-structure You would need to understand and implement that to parse/edit ID3 tags. Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/#findComment-205524 Share on other sites More sharing options...
Psycho Posted March 13, 2007 Share Posted March 13, 2007 There are two main ID3 versions, ID3 and ID3v2. While alot of files use v2, many still use the v1 so for backwards-compatability you should probably implement both. Here is the ID3v2 spec: http://www.id3.org/id3v2.4.0-structure You would need to understand and implement that to parse/edit ID3 tags. That sure would be a lot of work. You really may want to reconsider using sone of the available classes that have been tried and proven, lest you risk a bug that totally trashes the mp3 files. Whatever your choice, good luck. Quote Link to comment https://forums.phpfreaks.com/topic/42240-modifying-mp3-id3-metadata/#findComment-206024 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.