getting the MP3 duration

Shao Sean shaosean at unitz.ca
Mon Aug 4 20:27:04 EDT 2003


someone was looking at how to get the duration of an MP3
file.. here's a method that can be used..  the file used was
Jethro Tull's "Songs from the Woods" MP3 (the complete album
as one file).. it's a MPEG 1.0 layer 3 file.. if more
advanced file info is needed feel free to contact me
offlist..

-Sean

on mouseUp
  --- these constants come from my full album mp3 of Jethro
Tull's "Songs From The Woods"
  constant kFileSizeInBytes = "50034954"  -- as returned by
the 'detailed files'
  constant kFileBitRate = "160"           -- the bitrate
(displayed as 160kbit)
  
  local tTotalDurationInSeconds, tMM, tSS, tMMSS
  
  put ((kFileSizeInBytes * 8) / kFileBitRate / 1000) into
tTotalDurationInSeconds
  
  put trunc(tTotalDurationInSeconds / 60) into tMM
  put trunc(tTotalDurationInSeconds MOD 60) into tSS
  
  # WinAMP returns the total duration as: 2501 seconds
  #        returns the total time in MM:SS as: 41m 41s
end mouseUp



More information about the use-livecode mailing list