From: jonty Date: 2008-01-25T04:09:46+09:00 Subject: Re: [OT] Re: Looking for code to determine length of audio files I have just yesterday tried a script using mp3info, which worked a treat identifying some music files and giving their length even though their was no tag data. Hope this helps. require 'mp3info' Dir.chdir("C:/Mymusic) musicdir=Dir.glob("*.mp3") musicdir.sort out="" musicdir.each do |f| Mp3Info.open(f) do |mp3| l=mp3.length mins=l.divmod(60) if mins[0]==0 ln=mins[1].round.to_s+" secs" else ln=mins[0].to_s+ " minutes, "+mins[1].round.to_s+" seconds" end fl=mp3.filename out+= fl + " length: "+ln+"\n\n" end end f= File.open("musicinfo.txt","w") f.write(out) f.close Rick DeNatale wrote: > On 1/18/08, ara.t.howard wrote: > >> On Jan 18, 2008, at 6:47 PM, Rick DeNatale wrote: >> >> >>> I'm working on a project which has the requirement to automatically >>> determine the runtime of audio files in several formats, right now mp3 >>> and aac. >>> > > >> cfp:~/src/ruby > mp3info -p "%S seconds\n" /Users/ahoward/mp3/hot\ >> chip\ -\ crap\ kraft\ dinner.mp3 >> 394 seconds >> > > Where does this mp3info come from? I installed mp3info from > http://ruby-mp3info.rubyforge.org/ following Carlo's lead, but it > doesn't seem to have a command line component. > > But looking at an example of the podcast I need to handle, in both mp3 > and aac format, neither seems to have any duration related tags. > > So I guess I need to figure out if there's any way to compute the duration. > > Any ideas anyone? > >