Click to See Complete Forum and Search --> : MP3 / Id3 tags info


jief
07-30-2001, 02:32 PM
Hi everyone :)

I'd like to find some info on how to update/remove a MP3 file's ID3 tag. I plan on writting a small app in C that would do just that, rename a file, change its tag, etc etc.

Anyone knows where I'd find the specs or more info on that ? Thanks !

Jeff

MrNewbie
07-30-2001, 02:52 PM
Here's something I did that wasn't finished and it doesnt read all the ID3 attributes but it'll show you a bit.


#include <stdio.h>
#include <stdlib.h>

struct id3{
char title[31];
char artist[31];
char album[31];
char year[4];
char comment[31];
int track[1];
int genre[1];
};

void printdetails(char *);
void printhelp(char *);

int main(int argc, char *argv[])
{
if(argc > 1 || argc > 2){
printdetails(argv[1]);
}
else{
printhelp(argv[0]);
}
}

void printdetails(char *mp3file)
{
struct id3 mp3;
FILE *mp3fp;
char tag[3];

mp3fp = fopen(mp3file, "rb");
fseek(mp3fp, -128, SEEK_END);
fread(tag, 3, 1, mp3fp);

if(tag[0] == 'T' && tag[1] == 'A' && tag[2] == 'G')
{
printf("\nFilename: %s\n", mp3file);

fread(mp3.title, 30, 1, mp3fp);
mp3.title[30] = '\0';
printf("Title: %s\n", mp3.title);

fread(mp3.artist, 30, 1, mp3fp);
mp3.artist[30] = '\0';
printf("Artist: %s\n", mp3.artist);

fread(mp3.album, 30, 1, mp3fp);
mp3.album[30] = '\0';
printf("Album: %s\n", mp3.album);

fread(mp3.year, 4, 1, mp3fp);
mp3.year[4] = '\0';
printf("Year: %s\n", mp3.year);

fread(mp3.comment, 30, 1, mp3fp);
mp3.comment[30] = '\0';
printf("Comment: %s\n", mp3.comment);

if(mp3.comment[28] == '\0'){
mp3.track[0] = mp3.comment[29];
printf("Track: %d\n\n", mp3.track[0]);
}
else{
printf("Track: \n\n");
}
}
else{
puts("File has no ID3 Tag!");
}
}

void printhelp(char *binname)
{
printf("USAGE: %s <mp3filename>\n", binname);
puts("E.g. mp3id3 foobar.mp3");
}


Also check out the program mp3info, which is what I looked at to make that.

Adrian Papari
08-18-2001, 11:00 AM
Hi,

You might also want to check out www.wotsit.org (http://www.wotsit.org) ... good info on quite a number of file-formats.

Cheers,
//Adrian Papari.