Define ("ROOT_DIR", dirname (_ FILE __)); Class EcodeFlv { Var $ fromFile; // uploaded file Var $ toFilePath; // save the file path Var $ toPicPath; // Save the image path Var $ mpeg; // path of the ffmpeg program file Var $ mencode; // the path of the mencode program file Var $ convert tofile; // convert the file command Var $ convert topic; // convert image command Var $ toFileName; // converted file name Var $ mpegComm; // The conversion command of ffmpeg.exe Var $ mencodeComm; // mencode.exe command Var $ mpegType; Var $ mencodeType; Var $ midi; // the path of mdi.exe Var $ unzip MIDI; // mdi.exe command // Initialization class 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 the file type Function checkType (){ If (function_exists (mime_content_type )){ Return false; } Else { // $ ContentType = mime_content_type ($ this-> fromFile ); $ Exe = "D: serverphpextrasmagic "; $ 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; } } } // Set the file, image size "> image 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-> export tofile = "$ this-> mpeg-I $ this-> fromFile-y-AB 56-ar 22050-B 500-r 15-s $ flvWith * $ flvHeight $ flvName "; } Elseif ($ this-> mencodeComm ){ $ This-> export tofile = "$ 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-> reply topic = "$ this-> mpeg-I $ toMdi-y-f image2-ss 8-t 0.003-s $ size $ picName "; $ This-> midi = "$ this-> midi $ toMdi/k "; Echo $ this-> reply topic; } // Start Conversion Function toEcode (){ Set_time_limit (0 ); Exec ($ this-> export tofile, $ flvStatus) Exec ($ this-> reply topic, $ picStatus ); Exec ($ this-> semi Midi, $ mStatus ); } } |