Search code examples
c++binarymp3binaryfilesid3

cant read id3tag correctly


i want to read id3tag from mp3 file. I know that the place of this in the last 128 bytes of mp3 file.

So i do this code:

#include <stdio.h>
#include <iostream>

using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    FILE *pFile = fopen("1.mp3", "r");
    fseek(pFile, -128, SEEK_END);
    char artist;
    for (int i = 0; i < 128; i++)
    {
        fread(&artist, sizeof(char), 1, pFile);
        cout << "A: " << artist << endl;
    }
    getchar();
    return 0;
}

Dont worry about the output, its only a sample.

After googling, i find this info:

enter image description here

My problem, i dont understand why:

I working on Windows, for example i open the mp3 file properties (wich i want to read) and set the title more than 30 symbols. After using my programm, in output i have only 30 symbols in title, but in prop of file its again more. Please help me, i want to know only why?


Solution

  • Sry, i found a problem. The mp3 file have id3v1 tag in the end of the file in last 128 bytes and it have an id3v2.x tag in the start of file.