energine
[ class tree: energine ] [ index: energine ] [ all elements ]

Source for file VideoUploader.class.php

Documentation is available at VideoUploader.class.php

  1. <?php 
  2.  
  3. /**
  4.  * Класс VideoUploader.
  5.  *
  6.  * @package energine
  7.  * @subpackage core
  8.  * @author pavka
  9.  * @copyright Energine 2006
  10.  */
  11.  
  12.  
  13. /**
  14.  * 
  15.  * Загрузчик и конвертер видео файлов в формат flv
  16.  */
  17. final class VideoUploader extends FileUploader {
  18.     
  19.     public function __construct(Array $restrictions array()){
  20.         parent::__construct(
  21.            array_merge(
  22.                array('ext' => array('flv''avi''mpeg''mpg')),
  23.                $restrictions
  24.            )
  25.         );
  26.     }
  27.  
  28.     public function upload($dir){
  29.         if(
  30.            ($this->getExtension(!= 'flv'
  31.            && 
  32.            (file_exists($this->getConfigValue('video.ffmpeg')))
  33.         ){
  34.             $cmd $this->getConfigValue('video.ffmpeg').' -i '.
  35.               $this->file['tmp_name'].
  36.               ' -f flv -y  -ar 22050 -ab 32 -b 700000 -s cif '.
  37.               ($this->FileObjectName = $this->generateFilename($dir'flv'));
  38.             $returnStatus false
  39.             /*$result = */system($cmd$returnStatus);
  40.             if($returnStatus){
  41.                 throw new SystemException('ERR_BAD_FILE_FORMAT'SystemException::ERR_CRITICAL$this->file['name']);
  42.             }
  43.             
  44.             $cmd $this->getConfigValue('video.ffmpeg').' -i '.
  45.               $this->file['tmp_name'].
  46.               ' -vframes 1 -ss 00:00:05'.
  47.               ' -f image2 -s cif -an '.$this->FileObjectName.'.jpg';
  48.             system($cmd);
  49.             $result true;            
  50.         }
  51.         else{
  52.             $result parent::upload($dir);
  53.         }
  54.         
  55.         return $result;
  56.     }
  57. }
В создании документации нам помог: phpDocumentor