: [MPlayer-users] Piping live stream converting to ogg or mp3

Martin Simmons vyslnqaaxytp at spammotel.com
Thu Dec 28 22:48:14 CET 2006


>>>>> On Thu, 28 Dec 2006 10:48:38 +0000 (GMT), Original Brownster said:
> 
> Hi,
> Can anyone help me by looking at how I'm doing this below and say
> whether it's ok to do it this way or is there a better way?
> I'm writing a program in python with a gui frontend to help people
> download streams and convert them if required. Initially I'm working on
> realplayer streams but it should work with others like 'wma' 
> 
> I have worked out how to do this by:
> creating a named pipe 'foo'
> in a terminal running either lame or oggenc that reads from the pipe
> and writes the encoded file out '$ oggenc -q5 foo -o bar.ogg'
> in a separate terminal using mplayer: '$ stream-url.ra -ao
> pcm:file=foo'
> 
> This works fine and saves creating a massive wav file hence using the
> pipe, I didn't think I could do it with an inline pipe in one command
> but I'm happy to be proved wrong!

It can be done using /dev/fd.  In an interactive sh script, it looks like
this:

mplayer -ao pcm:file=/dev/fd/3 "$source" 3>&1 1>/dev/tty 2>&1 | lame - "$dest"

You can probably avoid the redirection cruft if pythan can set up the pipe
with the correct fds in the two child processes before they exec.

__Martin



More information about the MPlayer-users mailing list