From: Matthew Berg Date: 2003-11-23T05:13:01+09:00 Subject: Re: Ruby classes for MP3 de-/encoding On Sat, 2003-11-22 at 14:15, Dennis Oelkers wrote: > On Sun, Nov 23, 2003 at 04:03:55AM +0900, Matthew Berg wrote: > > You can do metadata extraction with GStreamer as well, though the > > bundled bindings for libgstmediainfo can be slow in certain > > circumstances. I have the extraction code I've been working on up here > > though: > > > > http://www.gothpoodle.com/~galt/info.rb > > > > This should allow you to read id3 or ogg tags at minimum, and i think > > wav riff headers though I haven't tested it on that yet. > > Thanks for all your help, but it seems as if you misunderstood my question > a bit. I'm not looking for classes to extract metadata information, I want > to encode/decode MP3 data. I think you misunderstood my answer. The metadata stuff was meant to be a "you can do this as well" thing. GStreamer is a full multimedia framework, which *does* do encoding and decoding of mp3 data. For example, a program to play a music file would look something like this: (note, this is off the top of my head, I haven't tested it, but if you need example code there's some up on the Ruby-GNOME2 site and included with the distribution) require 'gst' Gst.init # element to read a file src = Gst::ElementFactory.make("filesrc") # element to decode autodetect and decode formats spider = Gst::ElementFactory.make("spider") # element to output to a media decide sink = Gst::ElementFactory.make("osssink") # create a pipeline pipeline = Gst::Pipeline.new # add the elements pipeline.add(src, spider, sink) # link them together src >> spider >> sink src.location = ARGV.first # reset the pipeline and set the state to playing pipeline.clear pipeline.play # keep processing the pipeline until it's finished while pipeline.iterate do end exit! That example will actually handle any supported media type (mp3, ogg, wav, au, flac, etc), but if you wanted to limit it to mp3 data you could just use the "mad" element instead of "spider". Want to output to a file instead? Use a "filesink" element. Want to reencode to ogg maybe? Put a "oggenc" element before the "filesink". In other words you can do most anything you want with audio and video files you'd ever want to do. :) Matt