|
发表于 2004-3-28 20:52:20
|
显示全部楼层
I had thought about this before after visiting an artists web site and being dismayed that the free offerings were all streaming media. It made me wonder, what if I somehow make /dev/dsp a file or something. I tried and, of course, failed. Months later, my wife planned a course lesson around a radio show she had found which was offered in this format. She was quite upset to find after arriving in class that the network was down and she couldn't get the track... I did some research and found a solution.
If you have alsa drivers (or kernel > 2.6), alsa-oss, and alsa-utils installed, then you can capture streaming media directly. NOTE: I tried this under kde-3.1 and it did not work (even after disabling artsd), but under kde-3.2+, it works fine.
Edit the .asoundrc file in your home directory to look like this:
Code:
pcm.copy {
type plug
slave {
pcm hw
}
route_policy copy
}
Now, in one terminal, try playing some audio:
Code:
play /usr/kde/3.2/share/sounds/KDE_Startup.wav
In another terminal, use this command:
Code:
arecord -f cd -t wav -D copy > capture.wav
This tells the alsa record utility to use cd quality sound in wav format using your defined 'copy' pcm device and put the output in capture.wav.
You will have to hand time this or write some script to synchronize these commands, but to simply test, the terminals work fine.
OK, now for the good stuff.
Code:
realplay file.smil
In one terminal and
Code:
arecord -f cd -t wav -d copy | lame - file.mp3
in another and you have just captured your streaming media and encoded it on the fly
You may get more mileage using the aoss LD_PRELOAD wrapper for the playing application, but I found this was not neccessary for the aforementioned app, as it seems to play directly to the native sound device.
NOTE: You may also get things to work by simply using:
Code:
arecord -f cd -t wav -d hw
My sound card is es1371, BTW.
Have fun |
|