Convert video with PHP and FFMPEG

did not even find a similar search engine. It is necessary after downloading the file to the temporary folder to recode it FFMPEG after which it must write a successful conversion in the database.


Answer 1, Authority 100%

<?php
 //       
 $srcFile = "/path/to/clock.avi";
 $destFile = "/path/to/clock.flv";
 $ffmpegPath = "/path/to/ffmpeg";
 $flvtool2Path = "/path/to/flvtool2";
 //    ffmpeg
 $ffmpegObj = new ffmpeg_movie($srcFile);
 //    
 $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
 $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
 $srcFPS = $ffmpegObj->getFrameRate();
 $srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
 $srcAR = $ffmpegObj->getAudioSampleRate();
 //     ,  exec()
 exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile);
 //  
 function makeMultipleTwo ($value)
 {
 $sType = gettype($value/2);
 if($sType == "integer")
 {
 return $value;
 } else {
 return ($value-1);
 }
 }
 ?>

The first link in Google on request ffmpeg php convert video
Free translation. =)