[MPlayer-users] Re: rm -> pcm (then to mp3) and timing a stream
adland
adland123 at yahoo.com
Fri May 21 11:31:41 CEST 2004
> is there a way to do
> the encoding to mp3 at the same time?
could try
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: "$0" <input> <output>"
else
mkfifo MYFIFO
./mplayer -really-quiet -ao pcm -aofile MYFIFO -vo null -vc dummy "$1" &
lame -b 128 MYFIFO "$2"
rm MYFIFO
fi
> Next, I want to capture an hour out of an archive rm file.
>
> Now, luckily, it turns out the rstp address will take a ?start=h:m:s
> parameter to seek to a position, so I'm able too start where I like.
two ideas
1. try adding a stop parameter to rtsp stream argument as well.
ex
rtsp://stream?start=h:m:s&stop=h':m':s' to adjust length of file streamed.
2. modify above to count blocks being written to audio pipe
based on bitrate and blocksize used you could calculate a value
we set blocksize to 1 and count to
(bitrate*channels*bytes per sample*seconds) + 48 bytes for wave header
44100*2*2*3600)+48= 635040048 bytes into lame encoder for an hour
this is just a quick example be sure to edit the X value for some
integer calculated for length desired
CD audio is 44.1 Khz bitrate, 2 channels, 2 bytes per sample
also of course you may want/need different lame options
see unix manpages of commands for more help
#!/bin/bash
# encode some seconds of audio from infile into outfile as mp3.
# count should be set to (bitrate of input * channels * bytes per sample
# * # of seconds) + 48 header bytes
# when blocksize (bs) is set to one byte
# for dd you can also add skip=Y to skip first section of audio if desired
if [ $# -ne 2 ]; then
echo "Usage: "$0" <input> <output>"
else
mkfifo AOFIFO
./mplayer -really-quiet -ao pcm -aofile AOFIFO -vo null -vc dummy "$1" &
dd bs=1 if=AOFIFO count=X | lame --quiet -b 128 - "$2"
# stop mplayer in background and cleanup
killall -9 mplayer
rm AOFIFO
fi
good luck
More information about the MPlayer-users
mailing list