色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

用php將任何格式視頻轉為flv的代碼

復制代碼 代碼如下:
<?
define("ROOT_DIR",dirname(__FILE__));
class EcodeFlv {
var $fromFile; //上傳來的文件
var $toFilePath; //保存文件路徑
var $toPicPath; //保存圖片路徑
var $mpeg; //ffmpeg.exe文件的路徑
var $mencode; //mencode.exe文件的路徑
var $cmdToFile; //轉換文件命令
var $cmdToPic; //轉換圖片命令
var $toFileName; //轉換后的文件名
var $mpegComm; //ffmpeg.exe的轉換命令
var $mencodeComm; //mencode.exe的命令
var $mpegType;
var $mencodeType;
var $midi; //mdi.exe的路徑
var $cmdMidi; //mdi.exe的命令
//初始化類
function EcodeFlv($fromFile,$toFilePath,$toPicPath,$mpeg,$mencode,$midi) {
$this->mpegComm = false;
$this->mencodeComm = false;
$this->fromFile = $fromFile;
$this->toFilePath = $toFilePath;
$this->toPicPath = ROOT_DIR."/".$toPicPath;
$this->mpeg = ROOT_DIR.$mpeg;
$this->mencode = ROOT_DIR.$mencode;
$this->midi = ROOT_DIR.$midi;
$this->mpegType=array (
"audio/x-mpeg"=>".mp3",
"video/mpeg"=>".mpeg",
"video/3gpp"=>".3gp",
"video/x-ms-asf"=>".asf",
"video/x-msvideo"=>".avi"
);
$this->mencodeType = array(
"application/vnd.rn-realmedia"=>".rm",
"audio/x-pn-realaudio"=>".rmvb",
"audio/x-ms-wmv"=>".wmv",
);
}

//檢查文件類型

function checkType() {
if(function_exists(mime_content_type)){
return false;
}else{
//$contentType = mime_content_type($this->fromFile);
$exe = "D:/server/php/extras/magic";
$handel = new finfo(FILEINFO_MIME, $exe);
$contentType = $handel->file($this->fromFile);
}
foreach($this->mpegType as $index=>$key){
if($contentType == $index){
$name = md5(date("Ymd").tiime());
$this->toFileName = $name;
$this->$mpegComm = true;
return true;
}
}
foreach($this->mencodeType as $index=>$key){
if($contentType == $index){
$name = md5(date("Ymd").time());
$this->toFileName = $name;
$this->mencodeComm = true;
return true;
}else{
return false;
}
}
}

//設置文件,圖片大小
function setSize($flvSize,$picSize) {
$flvWidth = $flvSize[0];
$flvHeight = $flvSize[1];
$picWidth = $picSize[0];
$picHeight = $picSize[1];
$picName = $this->toPicPath.$this->toFileName.".jpg";
$flvName = $this->toFilePath.$this->toFileName.".flv";
$toMdi = ROOT_DIR."/".$flvName;
$size = $picWidth."x".$picHeight;
if($this->mpegComm){
$this->cmdToFile= "$this->mpeg -i $this->fromFile -y -ab 56 -ar 22050 -b 500 -r 15 -s $flvWith*$flvHeight $flvName";
}
elseif($this->mencodeComm){
$this->cmdToFile = "$this->mencode $this->fromFile -vf scale=$flvWidth:$flvHeight -ffourcc FLV1 -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=70:acodec=mp3:abitrate=56:dia=-1 -ofps 25 -srate 22050 -oac mp3lame -o $flvName";
}
$this->cmdToPic = "$this->mpeg -i $toMdi -y -f image2 -ss 8 -t 0.003 -s $size $picName";
$this->cmdMidi = "$this->midi $toMdi /k";
echo $this->cmdToPic;
}

//開始轉換
function toEcode() {
set_time_limit(0);
exec($this->cmdToFile,$flvStatus)
exec($this->cmdToPic,$picStatus);
exec($this->cmdMidi,$mStatus);
}

}
?>

php技術用php將任何格式視頻轉為flv的代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 洱源县| 富平县| 张家界市| 方正县| 琼结县| 吴川市| 安泽县| 明光市| 定远县| 梁山县| 苍溪县| 郸城县| 靖西县| 旺苍县| 轮台县| 冀州市| 台东市| 舞阳县| 喀什市| 三门县| 连山| 河曲县| 汽车| 灵寿县| 平顶山市| 密云县| 晋中市| 汽车| 从江县| 西盟| 崇仁县| 迁安市| 上思县| 蒙城县| 石城县| 仙居县| 阿坝县| 琼结县| 岑溪市| 绿春县| 临洮县|