Copy Code code as follows:
?
Define ("Root_dir", DirName (__file__));
Class Ecodeflv {
var $fromFile; The papers that came on
var $toFilePath; Save File path
var $toPicPath; Save Picture Path
var $mpeg; Path to Ffmpeg.exe file
var $mencode; Path to Mencode.exe file
var $cmdToFile; Convert File command
var $cmdToPic; Convert Picture command
var $toFileName; The converted FileName
var $mpegComm; Ffmpeg.exe's Conversion command
var $mencodeComm; Mencode.exe's orders.
var $mpegType;
var $mencodeType;
var $midi; Path to Mdi.exe
var $cmdMidi; Mdi.exe's orders.
Initializing classes
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",
);
}
Check file type
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;
}
}
}
Settings file, picture size
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 $flvNam E ";
}
ElseIf ($this->mencodecomm) {
$this->cmdtofile = "$this->mencode $this->fromfile-vf scale= $flvWidth: $flvHeight-FFOURCC flv1-of LA Vc-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;
}
Start conversion
function Toecode () {
Set_time_limit (0);
EXEC ($this->cmdtofile, $flvStatus)
EXEC ($this->cmdtopic, $picStatus);
EXEC ($this->cmdmidi, $mStatus);
}
}
?>