Jul. 18th, 2006

elfs: (Default)
Tonight, my local NPR affiliate is playing Selected Shorts, and Leonard Nimoy will be doing the reading. I want to listen to it, but Selected Shorts isn't available in a free archive and I don't want to be up at that hour. The problem was simple: how do I capture the audio in a podable format?

My solution works for Linux geeks.

Well, Mplayer will play many audio streaming formats, including many MS and Quicktime formats, but it dumps to a file. Also, I want it in MP3 format, and Lame will handle that, but how do I get the file from Mplayer to Lame without a humungous wave file in the middle? Well, Linux has named pipes, so I created one of those, and then Mplayer dumps to it, and Lame picks the stream out of it. I put both of those processes in the background in the right order, then wait for the correct interval and kill the Mplayer process. Lame detects the pipe closure and cleans up the MP3 output appropriately.

Obviously, for this to work, you need Mplayer, Lame, and I strongly recommend Delay, a replacement for the traditional sleep command with a lot of nifty features. If you don't have it, you can edit the file and substitute sleep for Delay.

Posting code to LJ is notoriously difficult, but let's see if I can't get it to behave now. If you use this code, you are responsible for its use, no warranties, released under the GNU Public License, all that. You are also responsible for discovering your local NPR affiliate's data stream (which can usually be uncovered by downloading one of the 'listen now' links and examining the source code), and for using it responsibly.

The code. )

Profile

elfs: (Default)
Elf Sternberg

May 2025

S M T W T F S
    123
45678910
111213141516 17
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 10th, 2025 05:21 pm
Powered by Dreamwidth Studios