Re: passthru problems generating WAVs with mpg123

From: Date: Sat, 26 Oct 2002 17:11:39 +0000
Subject: Re: passthru problems generating WAVs with mpg123
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-121529@lists.php.net to get a copy of this message
I'm SURE you've got a good reason, but why are you wanting to generate a WAV on demand? The loss in file quality occurs going from WAV > MP3, so then later going back to WAV would only result in a bigger file size, with ZERO benefit in audio quality. Just asking :) Justin on 26/10/02 4:53 PM, soren@byu.edu (soren@byu.edu) wrote: > I've written a little script for VoiceXML applications to generate a WAV > from an MP3 on demand: > > #file wavwrapper.php > <? > header('Content-Type: audio/wav'); > $filename = $_GET['filename']; > > $mp3dir="/var/www/mp3s/"; > $playercmd="/usr/local/bin/mpg123 -m -w - -q -4 --8bit"; > passthru("$playercmd $mp3dir/$filename 2> /tmp/playererror"); > ?> > > > I request it as wavwrapper?filename=song.mp3, and the browser reads the > MIME type properly, prompts me to play or download the song. I download > it, and save it as a WAV file. However, Mozilla downloads about 1.5M of > data, saves it all to a file, and then displays the downloaded size as > 1k. And then when I try to play it back, it won't play; it's like an > empty file. Same thing happens if I try to play it directly. But if I > redirect the output of mpg123 from standard out (so it goes across the > web connection) to a file and then download the file, the file plays > just fine. I figure there's something to do with the way PHP dumps back > the binary data that just isn't working right, but I don't know what it > is. Anyone have any ideas?

« previous php.general (#121529) next »