[vorbis-dev] Solved! piping vorbize's stdout/stderr

Peter Surda psurda at byte.at
Mon Aug 7 11:06:27 PDT 2000



On Tue, Aug 01, 2000 at 06:12:53AM +0200, Peter Surda wrote:
> The exact format isn't important, but it should
> - provide enough important information
> - be parsable (or parseable?) with a simple regexp
> - have a "\n" at the end of a line.
The holiday seemed to be a success, `cause after the resting I discovered a
new method to decode the output without any patches. It looks like this (works
analogously for ogg123 -v and mpg123 -v):

--------cut and simplified--------
$txt = "";
$rh = gensym();
$wh = gensym();
$pid = open3 ($wh, $rh, "", 'nice', '-n', '10', 'vorbize',
        'something.wav', '-v', '-w', 'something.ogg');
binmode $wh; select ($wh); $|=1;
binmode $rh; select ($rh); $|=1;
select (STDOUT);
while (sysread ($rh, $tmp, 80) != 0) {
        $txt .= $tmp;
        while ($txt =~ s/.*[^\d](\d+\.\d\%)//) {
                $perc = $1;
        }
}
waitpid ($pid, 0);
close $rh;
close $wh;
unlink "something.wav";
--------cut and simplified--------

There is place for optimizations, but the main point is that it works this
way. The open3 stuff was actually borrowed from cajun but the sysread was my
idea.

So now my jukebox can display progress of mpg123, ogg123, cdparanoia and
vorbize :-).

Bye,

Peter Surda (Shurdeek) <surda at bigfoot.com>, ICQ 10236103, +4369910964300


--
     The three Rs of Microsoft support: Retry, Reboot, Reinstall.

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/




More information about the Vorbis-dev mailing list