Beispiel #1
0
 /**
  * converts the video
  *
  * @return <type>
  */
 public function convertVideo()
 {
     // experimental
     if (!izapSupportedVideos_izap_videos($this->input_object)) {
         return elgg_echo('izap_videos:error:code:106');
     }
     $convert_video = new izapConvert($this->input_object);
     if ($convert_video->photo()) {
         if ($convert_video->izap_video_convert()) {
             return $convert_video->getValuesForAPI();
         }
     }
     // if nothing is processes so far
     return FALSE;
 }
Beispiel #2
0
 /**
  * Used to process the video file
  * @param string $file upload file name
  * @return object
  */
 protected function processFile($file)
 {
     $returnValue = new stdClass();
     $returnValue->type = 'uploaded';
     $fileName = $_FILES[$file['mainArray']]['name'][$file['fileName']];
     $error = $_FILES[$file['mainArray']]['error'][$file['fileName']];
     $tmpName = $_FILES[$file['mainArray']]['tmp_name'][$file['fileName']];
     $type = $_FILES[$file['mainArray']]['type'][$file['fileName']];
     $size = $_FILES[$file['mainArray']]['size'][$file['fileName']];
     // if error
     if ($error > 0) {
         return 104;
     }
     // if file is of zero size
     if ($size == 0) {
         return 105;
     }
     // check supported video type
     if (!izapSupportedVideos_izap_videos($fileName)) {
         return 106;
     }
     // check supported video size
     if (!izapCheckFileSize_izap_videos($size)) {
         return 107;
     }
     // upload the tmp file
     $newFileName = izapGetFriendlyFileName_izap_videos($fileName);
     $this->setFilename('tmp/' . $newFileName);
     $this->open("write");
     $this->write(file_get_contents($tmpName));
     $returnValue->tmpFile = $this->getFilenameOnFilestore();
     // take snapshot of the video
     $image = new izapConvert($returnValue->tmpFile);
     if ($image->photo()) {
         $retValues = $image->getValues(true);
         if ($retValues['imagename'] != '' && $retValues['imagecontent'] != '') {
             $this->setFilename('izap_videos/uploaded/' . $retValues['imagename']);
             $this->open("write");
             if ($this->write($retValues['imagecontent'])) {
                 $orignal_file_path = $this->getFilenameOnFilestore();
                 $thumb = get_resized_image_from_existing_file($orignal_file_path, 120, 90);
                 $this->setFilename('izap_videos/uploaded/' . $retValues['imagename']);
                 $this->open("write");
                 $this->write($thumb);
                 $this->close();
                 $returnValue->thumb = 'izap_videos/uploaded/' . $retValues['imagename'];
                 // Defining new preview attribute of standard object
                 $returnValue->preview_400 = 'izap_videos/uploaded/preview_400';
                 $returnValue->preview_200 = 'izap_videos/uploaded/preview_200';
             }
         }
     }
     // check if it is flv, then dont send it to queue
     if (izap_get_file_extension($returnValue->tmpFile) == 'flv') {
         $file_name = 'izap_videos/uploaded/' . $newFileName;
         $this->setFilename($file_name);
         $this->open("write");
         $this->write(file_get_contents($returnValue->tmpFile));
         $this->converted = 'yes';
         $this->videofile = $file_name;
         $this->orignalfile = $file_name;
         $returnValue->is_flv = 'yes';
         // remove the tmp file
         @unlink($returnValue->tmpFile);
     }
     return $returnValue;
 }