[MPlayer-users] Problem with multiple mplayer in the same pipe

Gilberto Abram gilberto.abram at gmail.com
Tue Feb 12 07:02:52 CET 2008


Hey,

I'm writing a little program that does some simple audio processing,
and I wanted to use mplayer to convert audio files in a standard
format that I use, and then save or listen to the output.
The way I had in mind was by doing something like this:

mplayer -af resample=48000:0:2,channels=1,format=s16ne -ao
pcm:nowaveheader:file=/dev/stdout:fast $INPUT_FILE | ./a.out | mplayer
-demuxer rawaudio -rawaudio channels=1:rate=48000:samplesize=2 -

however, I can only hear noise, even if I save the output to a file,
even if I set a cache much bigger than the size of the wave file.
Using an intermediate file works perfectly though:

#!/bin/bash

tmpfile=$(mktemp)
mplayer -af resample=48000:0:2,channels=1,format=s16ne -ao
pcm:nowaveheader:file=/dev/stdout:fast $INPUT_FILE > $tmpfile
cat $tmpfile | ./a.out | mplayer -demuxer rawaudio -rawaudio
channels=1:rate=48000:samplesize=2 - #ao
pcm:waveheader:file=/dev/stdout:fast -
rm -f $tmpfile

The script is doing the job for me, but if any of you knows the reason
for the behavior above I curious to know why and how to fix it. If you
want to try you can just substitute cat for ./a.out and it has the
same behavior. I am using mplayer 1.0pre8-4.1.1 on Gentoo 2.6.22.
Thank you

GB



More information about the MPlayer-users mailing list