Breaking News
You are here : Home / Web development / PHP / Read Mp3 Tags Without Downloading it
Read Mp3 id3 tags

Read Mp3 Tags Without Downloading it

Read Mp3 Tags Without Downloading it:

Howdy Mateys ! Mp3 File Contains the information about itself in id tags ,,these are IDv3  tags.So the information about a mp3 file can be read using the these ID3 tags.Reading mp3 tags without downloading it is good way to get id3 mp3 info.In PHP we can Use the ID3 library to fetch the information about mp3 file.The ID3 Library will generally fetch all ID3v1 ,ID3v2 ID tags.They have information like album,artist,lyrics,track number ,bitrate ,frequency and plenty of more information about the Mp3 file.

This Id3 library which reads mp3 files id3 tags needs an mp3 file present locally to get the mp3 id3 tags.But what we want id the file should not be downloaded.So we will partially download the file .Means we’ll download the part which is required to get the mp3 file information.So we just first 64 KB of file,,which is sufficient to Get info about the mp3 file. So we will be using the PHP curl for download.

But another issue is that ID3v2 is present at the start of mp3 file while ID3v1 is present at the end of the file.SO in some mp3 files there are both ID3v1 and ID3v2 tags but in some there is only one of them present .So to be safe we will also download the last 64 kb of the File using the PHP curl.So we will be downloading the128kb of the file.

So the very first Thing we need is the Id3 Library ,which can be downloaded from the here:

So firstly you need to download the mp3 id3 Library from the link above .and put the library in your project. As this will be used to   read Mp3 id3 tags info.So we now move on to tuet  and see the PHP script which will used here .

Read Mp3 Tags Without Downloading it::Usage-

Lets Get started and See how we read mp3 tags without fully downloading mp3 file.

Read Mp3 Tags Without downloading it::Include Mp3 ID3 Library:-

The very First Step after downloading the library is to include the ID3 mp3 library in the Script were we gonna read mp3 file.Suppose the Id3 Library is present in id3 directory of our project ,So we’ll include in our project script as:


Read Mp3 Tags Without downloading it::The Script:-

So Lets Take a look at  PHP script which partially download the  mp3 file (64 kb start and 64 kb from end) and extract the ID3 information from the mp3 file.We will be using curl in this script.It is the curl which download the mp3 file partially in chunks .and then fopen and fwrite are used to read the chunks and write them in the single we use loop to combine chunk data in to single variable then write that variable to a file.

Lets See the Script:

The Above Script is a function in which we passes our remote mp3 file url.Then this function downloads the first and last 64 kb of that file then we use put all downloaded data in a variable then variable to a file with unique name in our temp folder in the project.Then We use the ID3 library to analyse the file and collect the mp3 id3v1 and ID3v2 tag info in an array then this function just return that array.The array will have all the info about the mp3 file.


Read Mp3 Tags Without downloading it::Calling Function:-

We pass remote mp3 url to the function to read remote mp3 file id3 tags.We can call the above function which is used to fetch an mp3 file info like:

The Above Code will print out the mp3 ID3v1 and ID3v2 tag information .That’s all.

I hope You Enjoyed this Post.If you liked this one please like and share and keep visiting.Thanks for visiting on


Tags : , , , , , ,

1 Reply

  1. nostradamus says:

    your snippet is good, i might use it in one of my project.
    but you have to remove the extra curly bracket cause its causing an error


    // Now $fp should be the first and last 64KB of the file!!

Leave a Reply

Want to join the discussion ? Feel Free to contribute !