Take a look at the metadata gem. It harnesses several libraries to provide
meta-information from a wide variety of formats. Not sure if runtime length
is stored in the file's metadata but it may serve your needs.
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
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
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?
···
On 1/18/08, ara.t.howard <ara.t.howard@gmail.com> 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.
Except that it doesn't handle the file types I need.
···
On 1/19/08, Tom Reilly <w3gat@nwlagardener.org> wrote:
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
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.
--
share your knowledge. it's a way to achieve immortality.
h.h. the 14th dalai lama
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 <ara.t.howard@gmail.com> 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.
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.
We'd found another program called sox as an alternative, but at least
on OSX, it's rather slow, it's really an audio file transcoder and it
seems to be doing quite a bit of work to discover the playing time,
several seconds for a 30 minute MP3.
···
On 1/24/08, ara.t.howard <ara.t.howard@gmail.com> wrote:
On Jan 24, 2008, at 9:55 AM, Rick DeNatale wrote:
> 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.