/** * @param string $in * * @version 5.0 */ public function izapConvert($in = '') { $this->invideo = $in; $extension_length = strlen(izap_get_file_extension($this->invideo)); $outputPath = substr($this->invideo, 0, '-' . ($extension_length + 1)); $this->outvideo = $outputPath . '_c.' . $this->format; $this->outimage = $outputPath . '_i.png'; }
public function izap_video_convert() { // check if the file is already flv $current_file_type = izap_get_file_extension($this->invideo); if ($current_file_type == 'flv') { $this->make_array_for_flv(); } else { $videoCommand = izapGetFfmpegVideoConvertCommand_izap_videos(); $videoCommand = str_replace('[inputVideoPath]', $this->invideo, $videoCommand); $videoCommand = str_replace('[outputVideoPath]', $this->outvideo, $videoCommand); exec($videoCommand, $arr, $ret); if (!$ret == 0) { $return = array(); $return['error'] = 1; $return['message'] = end($arr); $return['completeMessage'] = implode(' ', $arr); return $return; } } return end(explode('/', $this->outvideo)); }
<div> <h3> <?php echo elgg_echo('izap_videos:queueStatus') . $queueStatus . ' (' . izap_count_queue() . ')'; ?> </h3> <?php if (count($queuedVideos)) { ?> <table class="izap_table"> <tbody> <?php $i = 0; foreach ($queuedVideos as $queuedVideo) { $extension_length = strlen(izap_get_file_extension($queuedVideo['main_file'])); $outputPath = substr($queuedVideo['main_file'], 0, '-' . ($extension_length + 1)); $ORIGNAL_name = basename($queuedVideo['main_file']); $ORIGNAL_size = izapFormatBytes(filesize($queuedVideo['main_file'])); $FLV_name = basename($outputPath . '_c.flv'); if (file_exists($outputPath . '_c.flv')) { $FLV_size = izapFormatBytes(filesize($outputPath . '_c.flv')); } else { $FLV_size = '0 KB'; } ?> <tr class="<?php echo !$i && izapIsQueueRunning_izap_videos() ? 'queue_selected' : ''; ?> "> <td>
/** * 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; }
/** * Save Video * * @param array $data * * @return boolean * * @version 5.0 * * @todo saveVideo function should be more flaxible for unit tests */ public function saveVideo($data = array(), $new) { foreach ($data as $key => $value) { if ($value != '') { $this->{$key} = $value; } } if ($new && ($this->videoprocess == 'offserver' || $this->videoprocess == 'onserver' || $this->videoprocess == 'youtube')) { switch ($this->videoprocess) { case 'offserver': include_once dirname(dirname(__FILE__)) . '/actions/izap-videos/offserver.php'; $saved = $this; break; case 'youtube': include_once dirname(dirname(__FILE__)) . '/actions/izap-videos/youtube.php'; forward(REFERRER); break; case 'onserver': include_once dirname(dirname(__FILE__)) . '/actions/izap-videos/onserver.php'; //before start converting $this->converted = 'no'; if ($saved = $this->save()) { $get_guid = $this->getGUID(); $get_entity = get_entity($get_guid); if (file_exists($get_entity->videofile)) { $this->videosrc = elgg_get_site_url() . 'izap_videos_files/file/' . $get_entity->guid . '/' . elgg_get_friendly_title($get_entity->title) . '.flv'; if (izap_get_file_extension($get_entity->videofile) != 'flv') { izap_save_fileinfo_for_converting_izap_videos($get_entity->videofile, $get_entity, $get_entity->access_id, $this); } elseif (izap_get_file_extension($get_entity->videofile) == 'flv') { $this->converted = 'yes'; } //change access id to submit by user after converting video $this->access_id = $data['access_id']; $saved = $this; } } break; } } else { $saved = $this; } return $saved; }
/** * Read video file content * * @version 5.0 */ function izap_read_video_file() { $guid = (int) get_input('videoID'); $entity = get_entity($guid); if (!elgg_instanceof($entity, 'object', GLOBAL_IZAP_VIDEOS_SUBTYPE)) { exit; } if ($entity->videofile) { $get_video_name = end(explode('/', $entity->videofile)); $izapvideo_obj = new IzapVideo(); $set_video_name = $izapvideo_obj->getTmpPath($get_video_name); if (izap_get_file_extension($set_video_name) == 'flv') { $set_video_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $set_video_name) . '.flv'; } else { $set_video_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $set_video_name) . '_c.flv'; } $elggfile_obj = new ElggFile(); $elggfile_obj->owner_guid = $entity->owner_guid; $elggfile_obj->setFilename($set_video_name); if (file_exists($elggfile_obj->getFilenameOnFilestore())) { $contents = $elggfile_obj->grabFile(); } $content_type = 'video/x-flv'; header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+10 days")), true); header("Pragma: public", true); header("Cache-Control: public", true); header("Content-Length: " . strlen($contents)); header("Content-type: {$content_type}", true); echo $contents; exit; } }
$filtered_tags[] = $tag; } } if ($filtered_tags) { $izap_videos->tags = array_unique($filtered_tags); } } else { if ($izap_videos->tags == '' || !$izap_videos->tags) { unset($izap_videos->tags); } } if (!$izap_videos->save()) { register_error(elgg_echo('izap_videos:error:save')); forward($_SERVER['HTTP_REFERER']); exit; } // save the file info for converting it later in queue if ($postedArray['videoType'] == 'ONSERVER' && $postedArray['guid'] == 0) { $izap_videos->videosrc = $CONFIG->wwwroot . 'pg/izap_videos_files/file/' . $izap_videos->guid . '/' . friendly_title($izap_videos->title) . '.flv'; if (izap_get_file_extension($tmpUploadedFile) != 'flv') { // will only send to queue if it is not flv izapSaveFileInfoForConverting_izap_videos($tmpUploadedFile, $izap_videos, $postedArray['access_id']); } } if ($postedArray['guid'] == 0) { add_to_river('river/object/izap_videos/create', 'create', $izap_videos->owner_guid, $izap_videos->guid); } system_message(elgg_echo('izap_videos:success:save')); unset($_SESSION['izapVideos']); forward($izap_videos->getUrl()); exit;