国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

如何用php將任何格式視頻轉為flv

2024-05-04 21:52:35
字體:
來源:轉載
供稿:網友
<?
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);
  }
 
 }
?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 靖江市| 丹江口市| 铜陵市| 进贤县| 常德市| 安远县| 太仓市| 青海省| 莆田市| 长汀县| 彩票| 历史| 炉霍县| 石门县| 元氏县| 读书| 县级市| 深圳市| 周宁县| 北流市| 新安县| 新疆| 安阳县| 洪江市| 从江县| 西乌| 定南县| 紫金县| 扎囊县| 米易县| 新竹县| 泸州市| 溧阳市| 柏乡县| 普安县| 若羌县| 永靖县| 乳山市| 平南县| 孟津县| 高密市|