-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
[To: mad-dev@lists.mars.org]
Is it possible for someone to elighten me on the relationship between ID3 v2 tags, Xing headers, and figuring out the lenght of VBR files?
Specifically, if I get my application to read ID3 tags, will I be able to find out the decoded length of an audio file without going through and counting all the frames?
- -- Russell O'Connor http://www.math.berkeley.edu/~roconnor/ ``[Law enforcement officials] suggested that the activists were stopped not because their names are on the list, but because their names resemble those of suspected criminals or terrorists.'' -- SFGate.com
Russell O'Connor wrote:
Specifically, if I get my application to read ID3 tags, will I be able to find out the decoded length of an audio file without going through and counting all the frames?
Unless I am incorrect, this is *not* the case. id3 tags don't contain this information as far as I know.
The way mpg321 calculates size is:
if (is_constant_bit_rate(file)) do_straight_multiplication(); else if (has_xing(file)) read_xing(); else count_all_frames();
The specifics are of course available in mpg321's source code; either in mad.c or mpg321.c iirc. Unfortunately my development machine is out of commission so I can't give you more detail than that, but you can browse CVS from http://sf.net/projects/mpg321.
HTH, Joe
On Tuesday, November 5, 2002, at 07:47 PM, Joe Drew wrote:
Russell O'Connor wrote:
Specifically, if I get my application to read ID3 tags, will I be able to find out the decoded length of an audio file without going through and counting all the frames?
Unless I am incorrect, this is *not* the case. id3 tags don't contain this information as far as I know.
The exception is if the tag contains a TLEN frame; this is supposed to contain the length of the audio file in milliseconds, represented as a numeric string. This frame is not very common, though.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
[To: mad-dev@lists.mars.org, chris.wohlgemuth@cityweb.de]
On Tue, 5 Nov 2002, Joe Drew wrote:
The way mpg321 calculates size is:
if (is_constant_bit_rate(file)) do_straight_multiplication(); else if (has_xing(file)) read_xing(); else count_all_frames();
I'm a little concerned about do_straight_multiplication(); If the file has extra headers randomly placed about it, you can be off by a small amount (or perhaps large amount).
For my application, I'd tempted to try finding the time in the following order:
1. check file's extended attribute (OS/2ism here) 2. check for xing header 3. check for TLEN in ID3 v2 tag. 4. count frames 5. assume CBR and just multiply 6. give up
(3 could fail and 4 succeed if you are accessing data over HTTP and have a Content-Length field).
Anyone have a reference to a Xing specification?
Presumably the Bytes field is the number of decode bytes.
The TOC seems useless for byte perfect seeking since the locations are only approximate.
Thanks for everyone's help.
- -- Russell O'Connor http://www.math.berkeley.edu/~roconnor/ ``[Law enforcement officials] suggested that the activists were stopped not because their names are on the list, but because their names resemble those of suspected criminals or terrorists.'' -- SFGate.com
Russell O'Connor wrote:
I'm a little concerned about do_straight_multiplication(); If the file has extra headers randomly placed about it, you can be off by a small amount (or perhaps large amount).
In my experience this isn't really an issue.
For my application, I'd tempted to try finding the time in the following order:
- check file's extended attribute (OS/2ism here)
- check for xing header
- check for TLEN in ID3 v2 tag.
- count frames
- assume CBR and just multiply
- give up
Don't underestimate the amount of time it takes to count the frames. This added around 5 seconds to the start of each song when I did it. Some minimal inaccuracy with frame numbers would probably be acceptable if it increased speed that much.