From: Tom Reilly Date: 2008-01-20T01:43:59+09:00 Subject: Re: [OT] Re: Looking for code to determine length of audio files I wrote this to determine how much dictation there is to do in my office to see how backed up the typist is. It's a quick and dirty program but it works #--------------------------------------- # # Compute time of unfinished dictation # #-------------------------------------- # Version 1.1 1/18/07 require 'find' file_tb = Array.new Find.find(".\\trdict",".\\Dictations") do |f| if f =~ /DONE/ Find.prune elsif f =~ /wav/ fsize = File.stat(f).size time = fsize.to_f * 0.00157 / 1000.0 #minutes file_tb.push([f,fsize,time]) elsif f =~ /WMA/ fsize = File.stat(f).size time = f.size.to_f * 0.008123 / 1000.0 file_tb.push([f,fsize,time]) end end totSize = 0 totTime = 0 #file_tb.each {|x| p "#{x[0]} #{x[1]} #{x[2]}"} file_tb.each {|x| totSize += x[1]; totTime += x[2]} p "# Files=#{file_tb.size}, File Size=#{totSize/1000000} MB, Total Time=#{totTime} Min" sleep 10 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. >> >> I googled around to see if there might be some existing code, >> hopefully ruby code which can determine this, but I'm coming up dry. >> >> Any ideas? >> >> -- Rick DeNatale >> >> My blog on Ruby >> http://talklikeaduck.denhaven2.com/ >> > > > cfp:~/src/ruby > mp3info -p "%S seconds\n" /Users/ahoward/mp3/hot\ > chip\ -\ crap\ kraft\ dinner.mp3 > 394 seconds > > > a @ http://codeforpeople.com/ > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > >