Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I get ID3 tags of my mp3 file with php?

Tags:

php

tags

id3

I'm surprised not to find more questions about it, I might be the one on stackoverflow. How do I need to go to extract ID3 basic tags of one mp3 file with php ? Without downloading any librairies (I just want a neat function that returns an associative array key=a string that specifies the tag, value=a string that specifies the value of the tag).

I found many ways to do it but all require to download libraries with many functions that I don't need necessarily.

I don't want kiddyscripting. I want to build this function using fopen and reading the first bytes of the file according to the length of each tags (reading in the rfc).

Which functions will I need to use to get the bits (or the bytes converted in bits) ? But not the characters which are in the mp3, cause of course they are not text file.

like image 242
vdegenne Avatar asked Nov 04 '22 20:11

vdegenne


1 Answers

Reading ID3-Tags is not as easy as "reading the first few bytes" (btw. ID3-V1 would be at the end and not the beginning) because most mp3's have ID3-V2 tags which are eighter at the beginning or the end of the file and they have dynamic lenght and encoding.

Why don't you just use an exsiting library, which does all the work for you (e.g. this)?

like image 78
Christoph Fink Avatar answered Nov 14 '22 01:11

Christoph Fink