PHP/Linux convert wav to mp3 using lame

<?php $wavfile=$_REQUEST['wav']; $wav=file_get_contents($wavfile); $descriptorspec = array( 0 => array( "pipe", "r" ), 1 => array( "pipe", "w" ), 2 => array( "file", "/dev/null", "w" ) ); $process = proc_open( "/usr/bin/lame - -", $descriptorspec, $pipes ); fwrite( $pipes[0], $wav ); fclose( $pipes[0] ); $mp3 = stream_get_contents( $pipes[1] ); fclose( $pipes[1] ); proc_close( $process ); header('Content-Type: audio/mpeg'); echo $mp3; ?>
Single php script to convert one wav file to mp3. This is based on Linux using lame utility. Permissions to www-data user must be set for executing lame and writing output file at destination path.

2 Responses

Receiving following warning, please tell me how to install lame library on wamp server

Warning: proc_open(/dev/null): failed to open stream:
Thanks, problem solved :)

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.