[MPlayer-users] Patch to make the "-ao pcm" wav output supporting pipes.
Alain Daurat
daurat at tiscali.fr
Sun Jan 19 17:03:20 CET 2003
Dear users of MPlayer,
I join a patch against Mencoder 0.90rc2 which permits
to make pipes for the wav pcm output of mplayer.
With the 0.90rc2 it is impossible to do this.
For example the following commands:
--
rm audiodump.wav
mkfifo audiodump.wav
mplayer -ao pcm -waveheader -vo null test.avi < /dev/null &
lame audiodump.wav aa.mp3
--
always produces a aa.mp3 of length 0.
It is because that when the file is not finished to be written,
it has a temporary length of 0. It is more logical to
write an infinite length. (sox does this)
So I change 2 lines in libao2/ao_pcm.c to write infinite
instead of zero.
(PB: the infinite is in fact 2G which is only 3 hours for a
48khz/16bits/stereo sound, but it is an intrinseque limitation
of the WAV format ??)
I have also modified the script mencvcd, because thanks to
the previous modification, we don't need to use a file where there
is all the uncompressed audio data.
Alain
PATCH: (between the '##################')
#########################################
--- libao2/ao_pcm.c.ori Sat Nov 2 22:54:08 2002
+++ libao2/ao_pcm.c Sun Jan 19 15:51:48 2003
@@ -50,7 +50,8 @@
/* init with default values */
static struct WaveHeader wavhdr = {
le2me_32(WAV_ID_RIFF),
- le2me_32(0x00000000),
+ /* same conventions than in sox/wav.c/wavwritehdr() */
+ le2me_32(0x7ffff024),
le2me_32(WAV_ID_WAVE),
le2me_32(WAV_ID_FMT),
le2me_32(16),
@@ -61,7 +62,7 @@
le2me_16(4),
le2me_16(16),
le2me_32(WAV_ID_DATA),
- le2me_32(0x00000000)
+ le2me_32(0x7ffff000)
};
static FILE *fp = NULL;
--- TOOLS/mencvcd.ori Sat Nov 2 18:27:23 2002
+++ TOOLS/mencvcd Sun Jan 19 15:51:48 2003
@@ -166,6 +166,7 @@
rm -f $AUDIO
# create a named pipe for video stream
mkfifo -m 660 $VIDEO
+mkfifo -m 660 $AUDIO
# some inits
sub=""
@@ -331,35 +332,29 @@
mpeg2enc -v 0 -s $mpegnorm -S $CDMAXSIZE -g 6 -G 15 -r 16 \
$framerate $yuvin -4 2 -2 1 -o $NAME.mpv) &
- # wait for finishing the subprocesses
- wait
-
# do resampling with sox
if [ $sox -ne 0 ]; then
- echo "wait, do resampling with sox..."
- sox $AUDIO -v $volume -r $asr $NAME.wav resample -qs
- mv -f $NAME.wav $AUDIO
+ soundcmd="sox -t .wav - -v $volume -r $asr -t .wav - resample -qs"
+ else
+ soundcmd=cat
fi
if [ $toolame -ne 0 -a $mp3 -eq 0 ]; then
# do mp2 encoding with toolame
- echo "wait, encoding to mp2 audio with toolame..."
- toolame -b $abr $AUDIO
- mv -f `basename $AUDIO .wav`.mp2 $NAME.mpa
+ $soundcmd < $AUDIO | toolame -b $abr - $NAME.mpa &
elif [ $toolame -eq 0 -a $mp3 -eq 0 ]; then
# mp2enc/lame can't read audiodump.wav directly from named pipe,
# we have to read the whole file.
- echo "wait, encoding to mp2 audio with mp2enc..."
- mp2enc -b $abr -r $asr -o $NAME.mpa < $AUDIO
+ $soundcmd < $AUDIO | mp2enc -b $abr -r $asr -o $NAME.mpa &
elif [ $mp3 -ne 0 ]; then
- echo "wait, encoding to mp3 audio with lame..."
- lame -b $abr --resample $kasr - $NAME.mpa < $AUDIO
+ $soundcmd < $AUDIO | lame -b $abr --resample $kasr - $NAME.mpa &
fi
+
+
+ # wait for finishing the subprocesses
+ wait
fi
- # remove wav file, won't need anymore!
- rm -f $AUDIO
-
# multiplex streams
[ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1
rm -f ${NAME}*.mpg
@@ -367,6 +362,7 @@
# remove pipe, won't need anymore!
rm -f $VIDEO
+ rm -f $AUDIO
# should i create only the mpeg file?
[ $mpgonly -eq 1 ] && exit 0
#########################################################################
More information about the MPlayer-users
mailing list