@chipset
I don't speak Perl very well, so i know this code sucks, but I hope you'll get the general idea from this skeleton.
my $filename = $ARGV[0];
print "Trying to parse: \"$filename\"\n\n";
open IN, "<$filename" or die $!;
binmode IN;
while( 1 ) { # this loop could be like infinite: You'll have to quit in reality if you reach the end of the 1st frame
read( IN, $buf, 4 ) or die $!;
if( $buf eq "Info" or $buf eq "Xing" ) {
seek( IN, -4, 1 );
seek( IN, 120, 1 ) or die $!;
read( IN, $buf, 4 );
if( $buf eq "LAME" ) {
seek( IN, -4, 1 );
printf "LAME Tag found at 0x%X\n", tell( IN );
seek( IN, 21, 1 ); # 0x15
$a = getc(IN);
$b = getc(IN);
$c = getc(IN);
printf "The 3 bytes are: %02X %02X %02X\n", ord $a, ord $b, ord $c;
$tmp24bits = (ord $a) * 256 * 256 + (ord $b) * 256 + (ord $c);
printf "Delay=%u, Padding=%u\n", int( $tmp24bits / 4096 ), $tmp24bits % 4096;
} else {
print "LAME Tag not found";
}
last;
}
seek( IN, -3, 1 ) or die $!;
}
close IN;
"Info" or "Xing" as ASCII charaters, yes.
Generally, you'll have to find the first byte of the MP3 frame, using binary 111 sync... but if you know you're handling the very 1st frame,
you can skip that part.
In your dump, you have "Info" and skip 120 bytes (0x78) from there, and you'll find "LAME".
Starting from that "LAME" go to offset 0x15-17, that is 24 08 0A in your sample. so 0x240 and 0x80A are what you want.
Basically You can simply "cut" this 0x24080A into 2 halves, "0x240" and "0x80A".
In many languages, that is bit-shift operation, perhaps in Perl too, but like I said I don't know Perl very well ^^;