我们如何在php中将视频文件转换为.flv格式

时间:2010-05-27 05:39:08

标签: php

您好我必须在php中将视频文件转换为.flv格式。任何团体都有任何简单的脚本请给我。

3 个答案:

答案 0 :(得分:6)

exec()ffmpeg

的帮助下

答案 1 :(得分:3)

检查一下..这段代码应该可行

    <?php
class media_handler
{
function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
// root directory path, where FFMPEG folder exist in your application.
$rPath = $rootpath."\ffmpeg";
// which shows FFMPEG folder exist on the root.
// Set Media Size that is width and hieght
$size = $width."x".$height;
// remove origination extension from file adn add .flv extension, becuase we must give output file name to ffmpeg command.
$outfile =$filename;
$out=explode(".",$outfile);


// Media Size
//$size = Width & "x" & Height;

// remove origination extenstion from file and add .flv extension , becuase we must give output filename to ffmpeg command.

$outfile = $out[0].".flv";
// Use exec command to access command prompt to execute the following FFMPEG Command and convert video to flv format.

$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."/".$outfile;

//$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -b 500 -r 25 -s 320×240 -hq -deinterlace -ab 56 -ar 22050 -ac 1 ".$outputpath."/".$outfile." 2>&1";


$ret = shell_exec($ffmpegcmd1);

// return output file name for other operations
return $ffmpegcmd1;
}

}
?> 

答案 2 :(得分:-1)

include_once( “media_handler.php”);

$ _ objMda = new mandler(); // $ _ objMda as new mandler();

$ rootpath =“”; $ nputpath = $ rootpath。“/ Default”; $ outputpath = $ rootpath。 “/ FLV”; $ ThumbPath = $ rootpath。 “/大拇指”;

如果($ _ POST){ //将原始视频保存在默认文件夹中。

$ source = $ _FILES ['file1'] ['tmp_name']; $ name = $ _FILES ['file1'] ['name']; $ fileSize = $ _FILES ['file1'] ['size']; $ filetype = $ _FILES ['file1'] ['type']; $ dest ='';

copy($ source,$ inputpath。$ name);

//将其转换为FLV格式

$ outfile = $ _objMda-&gt; convert_media($ name,$ rootpath,$ inputpath,$ outputpath,320,240,32,22050);

我用过你的课,但没有结果先生。我可以在我的phpini上设置任何东西吗?