Hi,
i'm building a icecast/shoutcast streamsouce in php. I can stream files now, but only in the original bitrate. So i can't stream 160kbit/s files with 128kbit. Therefore i want to use lame.. The following is the problem.
this:
/usr/local/bin/lame --mp3input -f -b 128 "mp3file.mp3" - 2>/dev/null
echo's the mp3data to the console. So i can use this command in system or exec or fpassthru to echo it to the icecast server. The problem is, lame re-encodes the whole song at max. speed(100% cpu, it takes not as much time as the song is) .. AND lame encodes it first and then the script continues.
I want to read the output from lame while lame is encoding, and only with.. let's say 4096 bytes per second.. so I can echo it with 4096 per second to icecast.
this is how they do it in perl:
my $lamestr = "$lame --mp3input -f -b $stream_bitrate \"$song\" -";
$lamestr .= ' 2>/dev/null';
$lamestr .= ' |'; #btw, what does this pipe do?
open(SONG, $lamestr);
while ( ($bytes = sysread(SONG, $buffer, 4096 )) > 0 ) {
(blabla code)
}
but I want it in php 🙂
I hope you can help me out, thanks,
~deuterium