#1 2010-04-13 18:33

Syborg
Member
Registered: 2010-04-13
Posts: 8

Reading multiple genres from MP3 (ID3)

Hi, this is my first post here.

I've got a collection of mp3 files each one containing a list of genres (recognized as different genres by Mp3Tag & Foobar).
I've been able to use Pascal Scripts using CalculateMetaTag to read genres from them, but I dont know how to read more than the first genre of each file ...

It's possible to read the whole 'string' of genres contained in a mp3 file from Pascal Script? … I've searched for the information overthere but I didn't found the solution and I would like to use ReNamer's ability to move files and change (create) folder structures.

Thanks in advance

And thanks to Denis for this GREAT tool: easy, powerful & efficient.

Offline

#2 2010-04-14 19:52

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Re: Reading multiple genres from MP3 (ID3)

Can you provide a sample file?

You can remove the audio content (or fill it with silence), i just need the meta information.

ID3v1 allows to specify only 1 genre and ID3v2 allows to specify any text as genre. ReNamer should be able to get both of them in full and ID3v2 allays have the priority over ID3v1. It is possible that Mp3Tag & Foobar are extracting 2nd genre from a different type of meta data.

Offline

#3 2010-04-16 07:39

Syborg
Member
Registered: 2010-04-13
Posts: 8

Re: Reading multiple genres from MP3 (ID3)

No problem. I'll send you a file in a few hours (I've no time now)
I think it's ID3v2.
Thanks.

Offline

#4 2010-04-16 19:33

Syborg
Member
Registered: 2010-04-13
Posts: 8

Re: Reading multiple genres from MP3 (ID3)

Here is a 5seconds file.

http://www.mediafire.com/file/ozzyd25dk … xample.mp3

Mp3Tag shows ID3_Genre like this: FirstGenre\\SecondGenre\\ThirdGenre ... (ID3v2.3 ID3v1).
When I put the file in foobar2000 library, this 'string' is recognized as three different genres.

And this is the Pascal Script.

------------------------------------------
var
Genre : WideString;

begin
  Genre := CalculateMetaTag(FilePath, 'ID3_Genre');
  showmessage(Genre);
  FileName := Genre + WideExtractFileExt(FileName); 
end.
------------------------------------------

You'll see that CalculateMetaTag returns just the first instance: FirstGenre


¿Is There any way to get the rest of them ...?

Thank you very much

Offline

#5 2010-04-17 13:47

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Reading multiple genres from MP3 (ID3)

Are you sure the ID3v2 specs state that multiple genres are allowed? FWIW, Winamp also displays just "FirstGenre".

Offline

#6 2010-04-18 09:21

Syborg
Member
Registered: 2010-04-13
Posts: 8

Re: Reading multiple genres from MP3 (ID3)

Thank you, Andrew. I don't use winamp (for me it's very heavy compared to foobar), so I don't know how it displays it, but (my installation of) Mp3Tag says exactly:

ID3v2.3 (ID3v1 ID3v2.3)

So I think this is ok with v2.3 specs.

(and foobar displays all of them)

Wikipedia (http://en.wikipedia.org/wiki/ID3) says:

... ID3v2.3 expanded the frame identifier to four characters, and added a number of frames. A frame could contain multiple values, separated with a / character. This is the most widely used version of ID3v2 tags ....

It's true that my 'string' uses \\ as separator ... not / ... (?) I don't know why ... I'm really far to be an ID3 specs expert.

Offline

#7 2010-04-18 21:20

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Reading multiple genres from MP3 (ID3)

This is what I found. Check out TCON as defined in section 4.2.1 here. So it is possible to mention multiple genres in the TCON frame, though I don't see either the "/" or the "\\" separators mentioned there. All I see is multiple genre index numbers in parentheses, i.e. "(51)(39)" and so on.

So if this is the spec, then I guess CalculateMetaTag() should indeed be able to retrieve all of the specified genres.

Offline

#8 2010-04-19 22:28

Syborg
Member
Registered: 2010-04-13
Posts: 8

Re: Reading multiple genres from MP3 (ID3)

Thank you, Andrew. It's Ok.
Maybe this is a special feature by Mp3Tag & Foobar out of the official ID3 specs.
As the genres I manage are not the indexed ones (just ID3v1) official specs and it seems to be impossible to read all of them from Pascal script, I will try to build a Pascal script for ReNamer from a modified export txt file from Mp3Tag.

Thanks again.

Offline

#9 2010-04-22 21:09

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Re: Reading multiple genres from MP3 (ID3)

Thanks to all of the information you guys dug up I was able to investigate further and I found out how multiple genres were stored in ID3 tags. I have modified the code for retrieving ID3 tags and now it picks up all 3 genres from the example uploaded by Syborg.

The only problem is that my hosting company is having technical difficulties and I can't upload the new version at the moment. I will post here as soon as the latest dev version is uploaded.

Offline

#10 2010-04-23 14:42

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Offline

Board footer

Powered by FluxBB