[mad-dev] About Xing VBR tag data
Rob Leslie
rob at mars.org
Tue Jan 13 22:23:07 PST 2009
On Jan 11, 2009, at 12:03 AM, leon deng wrote:
> I am new to MAD. I got confused about XING tag. Is XING also a mp3
> encoder? or XING is Tag in the mp3 format.
> If it is the later case, in the encoder side, we can put the size of
> the data in XING tag, and we can get the size of the file in XING
> tag in the decoder side. Because,
> we do not want to calculate the data size,and want to get the data
> size in XING tag.
>
> I also found XING is also a mp3 encoder on website.
>
> So could you tell me what the XING is ?
Xing was responsible for creating an encoder notable for its VBR tag,
which enables more accurate seeking within variable bitrate files.
Among other things, Xing's VBR tag contains information about the
total duration of an MP3 file, something that is not otherwise readily
available from the MPEG stream.
On Jan 13, 2009, at 11:18 AM, leon deng wrote:
> I want to find some mp3 headers, such as XING header,which can
> provide the duration information(total play time). I want to make
> use of it to achieve mp3 streaming support in libmad.
> So there are two questions.
> 1.I wrote a mp3 header reader, and it reads headers in the first 10
> frames. I only read first 4 bytes for each frame. where is XING
> duration field located, or could you provide some header
> documentation for XING header to me?
> 2. Could you please tell me some other headers which can provide
> duration information in it?
The Xing VBR tag, if present, is located within the ancillary data
portion of the first audio frame (unless the frame has CRC protection
enabled, in which case the tag is misplaced and overlaps the end of
the frame's audio data by two octets). You will find some code to
read the tag in the madplay distribution, within the files tag.c and
tag.h.
In general, MPEG audio streams only contain duration information about
each individual frame. If you know the total number of frames within
a file, you can calculate the total duration (assuming a constant
sample rate). Unfortunately, the total number of frames is difficult
to estimate in VBR files, and the only way to correctly calculate the
total duration -- absent a Xing tag or other source of metadata -- is
to scan every frame in the file.
--
Rob Leslie
rob at mars.org
More information about the mad-dev
mailing list