Last active
December 15, 2015 10:39
-
-
Save xeoncross/5246960 to your computer and use it in GitHub Desktop.
Record audio from flash to MP3 using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://code.google.com/p/wami-recorder/ | |
# Save the audio to a URL-accessible directory for playback. | |
parse_str($_SERVER['QUERY_STRING'], $params); | |
$name = isset($params['name']) ? $params['name'] : 'output.wav'; | |
$content = file_get_contents('php://input'); | |
$fh = fopen($name, 'w') or die("can't open file"); | |
fwrite($fh, $content); | |
fclose($fh); | |
unlink('output.mp3'); // FFMPEG won't overwrite existing files by default | |
// FFMPEG ignors our BITRATE if the Hz is wrong | |
//$commandOutput = shell_exec('ffmpeg -i output.wav output.mp3 -acodec libmp3lame -b 32k -ab 32k -b:a 32k'); | |
//$commandOutput = shell_exec('ffmpeg -i output.wav -acodec libmp3lame -b:a 8k -ac 1 -ar 11025 output.mp3'); | |
//$commandOutput = shell_exec('ffmpeg -i output.wav -acodec libmp3lame -b:a 8k -ac 1 -ar 8000 output.mp3'); | |
$commandOutput = shell_exec('ffmpeg -i output.wav -acodec libmp3lame -ab 24k -b:a 24k -ac 1 -ar 11025 output.mp3'); | |
file_put_contents('log.txt', $commandOutput); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment