calculate lenght of an audio file

Multimedia related Tips and tricks you would like to share.

Re: calculate lenght of an audio file

Postby kokoko3k on Tue Feb 09, 2010 2:08 pm

Hi luca, i'm afraid i can't help you much, as Xt7player itself uses mplayer get info about media files.
I Guess you've got to read the file header, which is different on different audio file types.
Also, different mp3 files can have different headers too (see xing header for an example reference).

If you manage to write a library which doesn't uses mplayer i would be happy to take a look, mplayer sometimes fails in reporting currect values on mp3 files (mostly vbr ones).

Good gambas coding!
User avatar
Site Admin
Posts: 309
Joined: Wed Nov 05, 2008 12:29 pm

Re: calculate lenght of an audio file

Postby Kasey42 on Sat Jan 14, 2012 12:57 pm

A sound file is encoded by length. Most mp3 files use up 128 or 256 kilobits of memory to store a singe second of data (audio). That number is in the file description, which you could easily obtain using a proper API to your operating system. Also, you'll need the total filesize, which is also obtainable. Now, the last step? Divide the filesize by the bit rate, and you have the length of the song.
Posts: 1
Joined: Sat Jan 14, 2012 12:10 pm

Return to Howtos, Tips&Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron Logo