[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: mpg123 playing to both file and speakers (stdout)



On Wed, May 15, 2002 at 04:40:01PM -0500, Lance Hoffmeyer wrote:
> Is there a way to have mpg123 play a file and record it to a file at once?
> 
> One can play mpg123 file.mpg or
>               mpg123 file.mpg --cdr file.cdr
> 
> but can I do both at once?

well, doing two functions to the same time ist not un*x like in the
sense of a process. every programm does one job at once. you can
hardcode the opposite, but it's not our way of doing things. daemons are
(well, not the only) execption.

but there's a big "but" if you come across I/O handling:

for e.g., if you have an output to /dev/stdout you can redirect the
output via traditional dup,dup2. this connects the file descriptors to
two or more ouput operations (in this theoretical example)

the program tee(1) is not actually an example of this, but does a
similar thing.

so, you can do the following stuff:

mpg123 file.mpg --cdr /dev/stdout | tee file.cdr | programm-to-handle-cdr </dev/stdin, if appropriate>

this does the following:

ouput file.mpg with cdr format to /dev/stdout. /dev/stdout is linked to
the stdout of the calling process.

now the magic. tee does write the input to file.cdr *and* also redirect
(duplex) the data to it's own stdout. see the manual page.

the next program does finally handle the original output and operate on
the data, while the tee in the middle save the data to a file.

conclusion: you can redirect output as you want, but seldom a un*x/linux
program does more than one thing at once. GUI programs have other
paradigms.


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: