Digitalnoise.net MP3 Tools

Back

ID3v2 Text Data Extraction

The ID3v2.4.0 frame specification allows for mutiple string values to be stored in a single, text data field. The values are to be separated by a null character in order to be able to distinguish between them. The method in the module MP3-Tag that extracts data from ID3v2 handles multiple strings in text fields by replacing the null separator character with the string " / ". This means that when you extract data from an ID3v2 text data frame that contains multiple string values, there is no guaranteed way to distinguish between the multiple strings (i.e. the string values that make up the data field may already contain the string " / " as part of one of those string values so it cannot be guaranteed to always be the correct string separator).

In order to run any of the scripts provided on this page you will need to be able to reliably distinguish between these mutiple text strings that may be part of a single text data field. To accomplish this you will need to make a change to the Perl module that contains the method for extracting data from ID3v2 tags (or you can download the already changed module from here). You will need to locate the file ID3v2.pm in your Perl version's @INC path. If you are using ActivePerl this path will most likely be C:\Perl\site\lib\MP3\Tag. Open the file in your favorite text editor and locate the subroutine extract_data. The subrountine contains the following block of code:

unless (exists $rule->{data} || !defined $found) { $found =~ s/[\x00]+$//; # some progs pad text fields with \x00 $found =~ s![\x00]! / !g; # some progs use \x00 inside a text string to seperate text strings $found =~ s/ +$//; # no trailing spaces after the text }

Comment out the line as shown below:

unless (exists $rule->{data} || !defined $found) { $found =~ s/[\x00]+$//; # some progs pad text fields with \x00 #$found =~ s![\x00]! / !g; # some progs use \x00 inside a text string to seperate text strings $found =~ s/ +$//; # no trailing spaces after the text }

This will ensure that the null characters are not replaced in text data fields that may contain multiple string values and allow the scripts provided on this site to run correctly.

Back