[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Reading mp3 files

Scott Rubin

2/15/2005 11:24:00 PM

I've been writing some simple music collection management scripts in ruby
lately, and it seems to be going well. I found ruby id3 with a google search,
it while not perfect it seems to meet my needs. However, I can't seem to find
any ruby library/class that will help me get information out of mp3/ogg/etc.
files that is not ID3. For example I would like to examine any mp3 file and
determine its bitrate and playtime. Is there a utility to give me this
functionality or am I going to have to write a wrapper for a C library?

Thanks,

Scott
3 Answers

Stefan Holst

2/16/2005 10:17:00 AM

0

Scott Rubin wrote:
> I've been writing some simple music collection management scripts in
> ruby lately, and it seems to be going well. I found ruby id3 with a
> google search, it while not perfect it seems to meet my needs. However,
> I can't seem to find any ruby library/class that will help me get
> information out of mp3/ogg/etc. files that is not ID3. For example I
> would like to examine any mp3 file and determine its bitrate and
> playtime. Is there a utility to give me this functionality or am I going
> to have to write a wrapper for a C library?

i've already written a wrapper which might suit your needs. it is
rather new and it's also the first time i mention it here.
it wraps xine (http://x...), a media player library you might
heard of and can be found here:

http://xiron.source...

only a cvs module (xiron-new) is available for now, it is not yet
released. you may also need the latest cvs of xine-lib since xiron may
trigger some bugs in lastest released version.

you can retrieve information about _any_ media file xine supports:

stefan@droopy data $ irb -r xiron
irb(main):001:0> s = Stream.new VideoPort.none, AudioPort.none
=> #<Stream:0x40715de4>
irb(main):002:0> s.open "ogg_vorbis.ogg"
=> true
irb(main):003:0> s.length
=> 10.011
irb(main):004:0> s.title
=> "Matrix XP Soundtrack"
irb(main):005:0> s.bitrate
=> 110734
irb(main):006:0> s.open "xvid.avi"
=> true
irb(main):007:0> s.length
=> 120.0
irb(main):008:0>

you can also play these files of course.

but there are also a few catches:
- xine has a relatively large memory footprint which might be too blown
for your needs
- the tag informations are only readible for now
- only tested on linux, might also work on other unix-derivates


RY
Stefan


Scott Rubin

2/16/2005 2:55:00 PM

0

Stefan,

Yeah, I know all about xine, I run gentoo :P But as you said, this is
definitely too much for what I need. However, it will very much come in handy
in the future for other projects. I'll keep an eye out for stable releases.
Any other options?

-Scott


Stefan Holst wrote:
> Scott Rubin wrote:
>
>> I've been writing some simple music collection management scripts in
>> ruby lately, and it seems to be going well. I found ruby id3 with a
>> google search, it while not perfect it seems to meet my needs.
>> However, I can't seem to find any ruby library/class that will help me
>> get information out of mp3/ogg/etc. files that is not ID3. For
>> example I would like to examine any mp3 file and determine its bitrate
>> and playtime. Is there a utility to give me this functionality or am I
>> going to have to write a wrapper for a C library?
>
>
> i've already written a wrapper which might suit your needs. it is
> rather new and it's also the first time i mention it here.
> it wraps xine (http://x...), a media player library you might
> heard of and can be found here:
>
> http://xiron.source...
>
> only a cvs module (xiron-new) is available for now, it is not yet
> released. you may also need the latest cvs of xine-lib since xiron may
> trigger some bugs in lastest released version.
>
> you can retrieve information about _any_ media file xine supports:
>
> stefan@droopy data $ irb -r xiron
> irb(main):001:0> s = Stream.new VideoPort.none, AudioPort.none
> => #<Stream:0x40715de4>
> irb(main):002:0> s.open "ogg_vorbis.ogg"
> => true
> irb(main):003:0> s.length
> => 10.011
> irb(main):004:0> s.title
> => "Matrix XP Soundtrack"
> irb(main):005:0> s.bitrate
> => 110734
> irb(main):006:0> s.open "xvid.avi"
> => true
> irb(main):007:0> s.length
> => 120.0
> irb(main):008:0>
>
> you can also play these files of course.
>
> but there are also a few catches:
> - xine has a relatively large memory footprint which might be too blown
> for your needs
> - the tag informations are only readible for now
> - only tested on linux, might also work on other unix-derivates
>
>
> RY
> Stefan
>
>

Scott Rubin

2/17/2005 3:03:00 AM

0

Totally awesome, that's perfect. Thanks!

Florian GroÃ? wrote:
> Scott Rubin wrote:
>
>> I've been writing some simple music collection management scripts in
>> ruby lately, and it seems to be going well. I found ruby id3 with a
>> google search, it while not perfect it seems to meet my needs.
>> However, I can't seem to find any ruby library/class that will help me
>> get information out of mp3/ogg/etc. files that is not ID3. For
>> example I would like to examine any mp3 file and determine its bitrate
>> and playtime. Is there a utility to give me this functionality or am I
>> going to have to write a wrapper for a C library?
>
>
> Here's a little bit of Ruby code a friend of me wrote -- it will not do
> everything you want and might even fail at some times, but it should at
> least get you started.