"; if (!empty($_FILES[$file_item]['name'])) { //echo $_FILES[$file_item]['tmp_name']; if($_FILES[$file_item]['size']*1==0){ echo "File : ".$_FILES[$file_item]['name']." is either empty or exceeds the file size limit, please reduce the size of this document, check the file, or contact Greg to increase the limit"; return "%"; }else{ $file_name = str_replace(" ", "_" , $_FILES[$file_item]['name']); $file_name = str_replace("'", "_" ,$file_name); $file_name = str_replace("\\", "_" ,$file_name); $file_name = str_replace("#", "_" ,$file_name); $file_name = str_replace("&", "_" ,$file_name); $file_name = str_replace("\"", "_" ,$file_name); $file_name = str_replace("(", "_" ,$file_name); $file_name = str_replace(")", "_" ,$file_name); $file_name = str_replace("@", "_" ,$file_name); $file_name = str_replace("\$", "_" ,$file_name); $file_name = str_replace("*", "_" ,$file_name); $file_name = str_replace("~", "_" ,$file_name); $file_name = str_replace("`", "_" ,$file_name); $file_name = str_replace("+", "_" ,$file_name); $file_name = str_replace("=", "_" ,$file_name); $file_name = str_replace("|", "_" ,$file_name); $file_name= time_stamp() . "_" . $file_name; if (!file_exists($upload_dir . $file_name)) { $file_loc = copy($_FILES[$file_item]['tmp_name'], $upload_dir . $file_name); } else { $file_name = time_stamp() . "_" . $file_name; $file_loc = copy($_FILES[$file_item]['tmp_name'], $upload_dir . $file_name); } if ($file_loc != false) { $file_loc = $upload_dir . $file_name; return $file_loc; } else { echo "Could not find file : ".$_FILES[$file_item]['name']; return "%"; } } } else { echo "upload failed
"; return "%"; } } $flvtool2Path='/usr/bin/flvtool2'; $ffmpegPath='/usr/bin/ffmpeg'; $qualitySettings=array('low'=>'-ar 22050 -ab 32','med'=>'-ab 48k -ac 1 -ar 44100 -deinterlace -nr 500 -croptop 4 -cropbottom 4 -cropleft 8 -cropright 8 -aspect 4:3 -r 25 -b 270k -me_range 25 -i_qfactor 0.71 -g 500','high'=>'-ab 64k -ac 2 -ar 44100 -deinterlace -nr 500 -croptop 4 -cropbottom 4 -cropleft 8 -cropright 8 -aspect 4:3 -r 25 -b 650k -me_range 25 -i_qfactor 0.71 -g 500'); $reqFields="email|password|quality|size|format"; $reqFields=explode("|",$reqFields); $filesMessage=""; $formatSettings=array('flv'=>'-f flv -acodec mp3'); $badSubmit=false; //check for post if(!empty($_POST['password'])){ //check for pass and user //echo "checking pass
"; if(trim($_POST['password'])=='ricecrispytreat' && !empty($_POST['email'])){ //check submission //echo "password excepted
"; for($i=0;$i"; break; } } //ok we've done basic checking - now lets get to work if(!$badSubmit){ //first lets make sure we have a file if(!empty($_POST['serverPath']) || !empty($_FILES['fileUploaded'])){ if(!empty($_FILES['fileUploaded'])){ $processFile=upload_from_form('fileUploaded'); }else{ $processFile=$_POST['serverPath']; $processFile=realpath($processFile); if(!file_exists($processFile)){ $processFile="%"; } } }else{ $processFile='%'; } if($processFile=='%'){ echo " either you have entered a non valid path, or your uploaded file wasn't in the right format
"; } //end file checks if($processFile!='%'){ //now lets see if we have thumbnails to make if(isset($_POST['useThumbs'])){ //echo "thumbnailing
"; //defaults $maxThumbnails=5; $thumbnailsFrom=1; //if they were set if(!empty($_POST['thumbsMax'])){ $maxThumbnails=$_POST['thumbsMax']; $maxThumbnails*=1; } if(!empty($_POST['thumbStart'])){ $thumbnailsFrom=$_POST['thumbStart']; $thumbnailsFrom*=1; } //echo "making thumbnails"; //lets do the work //setup ffmpeg-php object, and needed vars $ffmpegObj = new ffmpeg_movie($processFile); $totalTime=$ffmpegObj->getDuration(); $frameRate=$ffmpegObj->getFrameRate(); $thumbIncrements=(($totalTime*$frameRate)-($thumbnailsFrom*$frameRate))/$maxThumbnails; $wide=$ffmpegObj->getFrameWidth(); $high=$ffmpegObj->getFrameHeight(); $startFrame=$thumbnailsFrom*$frameRate; //echo "frame rate: ".$frameRate; $filesMessage.="ThumbNails can be viewed at :

"; //echo "thumbs being processed now"; for($t=0;$t<$maxThumbnails;$t++){ //$image= @imagecreatetruecolor($wide,$high); $thumbFile=$processFile.".".$t.".png"; $currFrame=floor($startFrame+($thumbIncrements*$t)); //echo "
thumb of frame $currFrame: ".$thumbFile; $thumb=$ffmpegObj->getFrame($currFrame); if ($thumb) { $thumbImage = $thumb->toGDImage(); if ($thumbImage) { imagepng($thumbImage,$thumbFile); imagedestroy($thumbImage); } } //echo "
saved"; $thumbUrl=$url_dir."".basename($thumbFile); $filesMessage.="".$thumbUrl."
"; } $filesMessage.="

"; } //echo "outside thumbs"; $newFile=substr($processFile,0,strrpos($processFile,".")).".".$_POST['format']; $ffmpegCall=$ffmpegPath." -i ".$processFile." ".$qualitySettings[$_POST['quality']]." ".$formatSettings[$_POST['format']]." -s ".$_POST['size']." ".$newFile; $flvtool2Call=flvtool2Path." -U stdin ".$newFile.""; $encodeCall=$ffmpegCall." | ".$flvtool2Call; exec($encodeCall); $fileUrl=$url_dir."".basename($newFile); $filesMessage.="

You Can Now View / Download Your Video @".$fileUrl."

"; $user=$_POST['email']; mail($user,basename($newFile),$filesMessage); $foo=@unlink($processFile); //echo $fileMessage; } } } } ?> Untitled Document
     
 
video convert .01 alpha
 
this isn't pretty, but it gets the job done. consider this a POC. More options to come, and maybe an ajax or flash interface. Probaly Flash :)
 
Access and reporting

This will be used to notify you once conversion has completed.
 
video file---
or
     
thumbnails
- defaults to 5 if not set
 
video settings
     
Audio Settings