IamAditya
IamAditya

Reputation: 31

mp3 to wav on linux via PHP

I want your advice on how to convert mp3 files to wav on linux via a PHP script.

I was successful with lame but only on windows, I putted lame.exe and lame.xxx.dll together and executed the PHP script posted here:

But so far so good, I'm not successful in doing the same thing on Linux.

Upvotes: 1

Views: 5065

Answers (2)

Nuwan Perera
Nuwan Perera

Reputation: 411

I am using mpg123 to convert *.mp3 files into *.wav.

// To install mpg123 {Ubuntu 12.04} sudo apt-get install mpg321

// My PHP Script (Sample)

<?php

# glob() :  to collect all files in a folder
# foreach() : to loop

foreach (glob("*.mp3") as $file)
{
    $act_name = explode ('.', $file);

    $command = "mpg123 -w {$act_name[0]}.wav $file";
    echo $command . "\n";
    exec($command)  
    echo "file converted {$file}\n";

    sleep(1);
}

Upvotes: 1

dogglebones
dogglebones

Reputation: 387

sorry, but afaik php is only gonna let you mess with id3 tags. you're gonna want to use an external tool to get this done.

use lame:

exec("lame –decode input.mp3 output.wav");

or use mpg123:

exec("mpg123 -w output.wav input.mp3");

Upvotes: 3

Related Questions