Ffmpeg-php
From DreamHost
(Redirected from Php-ffmpeg)
| This article or section may require a cleanup. We are hoping to create articles that meet certain standards. Please discuss this issue on the talk page. Editing help is available. |
| The instructions provided in this article or section are considered advanced. You are expected to be knowledgeable in the UNIX shell. |
Php-ffmpeg
php-ffmpeg is a component that can be used in a php script. Here are some details:
- php-ffmpeg is free
- php-ffmpeg installation is similar to installing a perl module
- php-ffmpeg is used for many youtube clones
- unlike other scripts, php-ffmpeg supports all video types
The php script
Full Code
<?php
// Set our source file
$srcFile = "/path/to/clock.avi";
$destFile = "/path/to/clock.flv";
$ffmpegPath = "/path/to/ffmpeg";
$flvtool2Path = "/path/to/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()
exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile);
function makeMultipleTwo ($value) {
if ($value % 2)
return $value - 1;
else
return $value;
}
?>