#!/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;