« php エラーレベル | メイン | PEAR (Pager) »
2007年09月21日
ffmpeg-php
http://phpspot.org/blog/archives/2007/03/phpffmpegffmpeg.html
よりメモ
define('FFMPEG_BINARY', '/usr/local/bin/ffmpeg');
define('FFMPEG_FLVTOOLS_BINARY', '/usr/bin/flvtool2');
require_once 'ffmpeg.php';
$files_to_process = array(
'xxxxx/ffmpeg/www/example/to-be-processed/MOV00007.3gp',
'xxxxx/ffmpeg/www/example/to-be-processed/Video000.3gp'
);
$video_output_dir = 'xxxxx/ffmpeg/www/example/processed/videos/';
$bitrate = 64;
$samprate = 44100;
$ffmpeg = new ffmpeg();
$ffmpeg->on_error_die = FALSE;
foreach($files_to_process as $file)
{
$filename = basename($file);
$filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
$ok = $ffmpeg->setInputFile($input_dir.$file);
if(!$ok)
{
echo $ffmpeg->getLastError()."
rn";
$ffmpeg->reset();
continue;
}
$ffmpeg->setVideoOutputDimensions(320, 240);
$ffmpeg->setFormatToFLV($samprate, $bitrate);
$ok = $ffmpeg->setOutput($video_output_dir, $filename_minus_ext.'.flv', TRUE);
if(!$ok)
{
echo $ffmpeg->getLastError()."
rn";
$ffmpeg->reset();
continue;
}
$result = $ffmpeg->execute(TRUE);
if(!$result)
{
echo $ffmpeg->getLastError()."
rn";
$ffmpeg->reset();
continue;
}
echo 'Video converted... '.array_shift($ffmpeg->getLastOutput()).'
'."rn";
$ffmpeg->reset();
}
?>
ffmpeg::setInputFile - 入力ファイルを設定
ffmpeg::setFormatToFLV - フォーマットをFLVに指定
ffmpeg::setOutput - 出力の設定
ffmpeg::execute - 変換の実行
投稿者 muuming : 2007年09月21日 19:01