From owner-freebsd-questions@FreeBSD.ORG Wed Sep 8 08:41:15 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3213416A4CF for ; Wed, 8 Sep 2004 08:41:15 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id CCEEE43D46 for ; Wed, 8 Sep 2004 08:41:14 +0000 (GMT) (envelope-from mileskeaton@gmail.com) Received: by mproxy.gmail.com with SMTP id 77so250240rnl for ; Wed, 08 Sep 2004 01:41:09 -0700 (PDT) Received: by 10.38.82.8 with SMTP id f8mr2588067rnb; Wed, 08 Sep 2004 01:41:09 -0700 (PDT) Received: by 10.38.79.58 with HTTP; Wed, 8 Sep 2004 01:41:09 -0700 (PDT) Message-ID: <59b2d39b04090801411c5af974@mail.gmail.com> Date: Wed, 8 Sep 2004 01:41:09 -0700 From: Miles Keaton To: brianfinniff@unixforge.org, questions@freebsd.org In-Reply-To: <200409072225.02425.brianfinniff@unixforge.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200409072225.02425.brianfinniff@unixforge.org> Subject: Re: MP3 Audio CD Burning X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Miles Keaton List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2004 08:41:15 -0000 On Tue, 7 Sep 2004 22:25:02 -0500, Brian Finniff wrote: > Is it possible to burn a CD from an .MP3 file? If so, how would I do that? You need to install sox: cd /usr/ports/audio/sox ; make install clean Then I wrote this little PHP script that seems to work well: # go through each file in directory $d = dir($directory); while($file = $d->read()) { # switch file extention (mp3, wav, flac) $ext = substr(strrchr($file, '.'), 1); $file = shellescape($file); switch($ext) { # lame + sox to decode mp3 case 'mp3': $cmd = 'lame --decode ' . $directory . $file . ' ' . $directory . $file . '.wav'; exec($cmd); $cmd = 'sox ' . $directory . $file . '.wav -t raw -s -w -c 2 ' . $directory . $file . '.raw'; exec($cmd); $cmd = 'rm ' . $directory . $file . '.wav'; exec($cmd); break; # flac + sox to decode flac case 'flac': $cmd = 'flac --decode ' . $directory . $file . ' -o ' . $directory . $file . '.wav'; exec($cmd); $cmd = 'sox ' . $directory . $file . '.wav -t raw -s -w -c 2 ' . $directory . $file . '.raw'; exec($cmd); $cmd = 'rm ' . $directory . $file . '.wav'; exec($cmd); break; # wav is ready to sox case 'wav': $cmd = 'sox ' . $directory . $file . ' -t raw -s -w -c 2 ' . $directory . $file . '.raw'; exec($cmd); break; } } $d->close(); # list them in order, to make burncd command-line $rawfiles = shell_exec('ls -l1 ' . $directory . '*.raw'); $filenames = explode("\n", trim($rawfiles)); # escape 'em all foreach($filenames as $key=>$value) { $filenames[$key] = shellescape($value); } print_r($filenames); # burn (and eject) $cmd = 'burncd -dne -f /dev/acd0c -s max audio ' . join(' ', $filenames); exec($cmd);