Hi, I've tried for a few hours, and I am at a roadblock. What I am trying to do, is pipe raw pcm sound from /dev/dsp to oggenc, and save it to a scalar. In the code below, I can create an ogg file, or dump the binary data to stdout. But I can't seem to capture the stdout from oggenc. I tried IO::Tee and a few other things, but I can't seem to capture the data I see flying by on the screen.

Does anyone know if this type of capture is possible?

#!/usr/bin/perl use warnings; use strict; use Audio::DSP; $|++; my ($buf, $chan, $fmt, $rate) = (4096, 1, 16, 22050); my $dsp = new Audio::DSP(buffer => $buf, channels => $chan, format => $fmt, rate => $rate); $dsp->init() || die $dsp->errstr(); #this method dosn't work #close STDOUT; #my $ogg_out = ''; #open STDOUT, '>', \$ogg_out, or die "Couldn't redirect STDOUT to $ogg +_out: $!"; #this will dump the encoded ogg to STDOUT my $pid = open(OGGIN, "| oggenc -Q -r -R 22050 --resample 8000 -C 1 -q + 2 - ") or warn "No oggenc $!\n"; #this will dump it to a file #my $pid = open(OGGIN, "| oggenc -Q -r -R 22050 --resample #8000 -C 1 +-q 2 - | cat > $0.ogg ") # or warn "No oggenc $!\n"; while (my $buffer = $dsp->dread(4096) ) { syswrite( OGGIN, $buffer, length($buffer) ); } # of course, cntrl-c out of the while loop never lets this print # but I include it to show what I'm after #print $ogg_out;

I'm not really a human, but I play one on earth. flash japh

In reply to capturing stdout from a piped open by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.