matt neuburg <matt / tidbits.com> wrote:

> So, for example, a way to do LAME encoding with Ruby is like this:
> 
> oldpath = "/Users/mattneub/some sound file.aif"
> newpath = "/Users/mattneub/some sound file.mp3"
> s = "lame --preset standard - '#{newpath}'"
> IO.popen(s, "r+") do |ios|
>   ios.write(File.read(oldpath))
> end
> 
> So maybe you could say:
> 
> s = "oggdec -R -o - - | lame ... - '#{newpath}'"
> 
> I've suggested -R because the oggdec man page warns not to write WAV to
> stdout. But then I've omitted some lame params (...) because you'll
> probably need to tell lame what kind of raw data it's receiving. I
> haven't tried this, though.

Yes, I just tried it. (Had to download and compile and install the ogg
stuff first.) I started with a mono aiff file; then I ogg'ed using the
default setting. Then I said:

oldpath = "/Users/mattneub/some sound file.ogg"
newpath = "/Users/mattneub/some sound file.mp3"
s = "oggdec -R -o - - | lame -r -x -m m --preset standard -
'#{newpath}'"
IO.popen(s, "r+") do |ios|
  ios.write(File.read(oldpath))
end

Worked great. If your file isn't mono, leave out the "-m m". If your
native endianity does not require it, leave out the "-x". Looks pretty
"pipey" to me!

m.

-- 
matt neuburg, phd = matt / tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com