<?php
ini_set("display_errors",1);
// Set our source file
$srcFile = "/web/htdocs/www.domain.com/home/test.avi";
$destFile = "/web/htdocs/www.domain.com/home/test.flv";
$ffmpegPath = "/usr/local/bin/ffmpeg";
$flvtool2Path = "/usr/bin/flvtool2";
// Create our FFMPEG-PHP class
$ffmpegObj = new ffmpeg_movie($srcFile);
// Save our needed variables
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate();
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();
// Call our convert using exec()
$command = $ffmpegPath ." -i " . $srcFile ." -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . "- | " . $flvtool2Path . " -U stdin " . $destFile;
exec($command,$out);
chmod($destFile,0755);
echo "<br><br><b>Comando</b>$command<br>";
// Make multiples function
function makeMultipleTwo ($value)
{
$sType = gettype($value/2);
if($sType == "integer")
{
return $value;
} else {
return ($value-1);
}
}
?>