How does b2 know how long a track is?

77 views
Skip to first unread message

AndyC

unread,
Apr 30, 2020, 6:58:46 AM4/30/20
to Brennan Forum
Can anyone satisfy my curiosity please: 

When b2 starts to play a track, it immediately displays the track length in minutes & seconds and then proceeds to count it down. However almost all file formats it plays are compressed so the length of the track is not directly proportional to the file size in bytes and can't be used to predict the track length. 

So how does it know the time length? 
Is there something in the FLAC, MP3, AAC etc. file headers that stores this information? 
(I've had a look at a FLAC track with a Hex Editor and can't see anything obvious.)

Fatally Wanderer

unread,
Apr 30, 2020, 10:11:37 AM4/30/20
to Brennan Forum
Hi Andy, this is stored in, or can be derived from, information in the file headers. e.g for FLAC - https://xiph.org/flac/format.html

Tim

AndyC

unread,
May 2, 2020, 3:51:38 AM5/2/20
to Brennan Forum
Thanks Tim. The xiph.org website is very comprehensive in describing the way FLACs are assembled but doesn't actually contain any details about what the header includes.

However by a bit of detective work I've figured it out - the duration time is derived from the 23rd & 24th bytes of the header.

Thanks for the pointer. Andy
Reply all
Reply to author
Forward
0 new messages