$ffmpeg_path = current(explode(' ', izapAdminSettings_izap_videos('izapVideoCommand'))); $pdo_sqlite = extension_loaded('pdo_sqlite') ? true : false; if ($exec) { $php_command = exec(izapAdminSettings_izap_videos('izapPhpInterpreter') . ' --version', $output_PHP, $return_value); if ($return_value === 0) { $php = nl2br(implode('', $output_PHP)); } $ffmpeg_command = exec($ffmpeg_path . ' -version', $output_FFmpeg, $return_var); if ($return_var === 0) { $ffmpeg = nl2br(implode($output_FFmpeg)); $in_video = elgg_get_plugins_path() . 'izap_videos/server_test/test_video.avi'; $izap_videos = new IzapVideos(); $izap_videos->owner_guid = elgg_get_logged_in_user_guid(); $izap_videos->setFilename('izap_videos/server_test/test_video.avi'); $izap_videos->open('write'); $izap_videos->write(file_get_contents($in_video)); $in_video = $izap_videos->getFilenameOnFilestore(); if (!file_exists($in_video)) { $in_video = elgg_get_plugins_path() . 'izap_videos/server_test/test_video.avi'; exit; $izap_videos->open('write'); $izap_videos->write(file_get_contents($in_video)); $in_video = $izap_videos->getFilenameOnFilestore(); } $izap_videos->close(); if (file_exists($in_video)) { $in_video; $outputPath = substr($in_video, 0, -4); $out_video = $outputPath . '_c.flv'; $commands = array('Simple command' => $ffmpeg_path . ' -y -i [inputVideoPath] [outputVideoPath]'); }
/** * Create new video entity * * @return ElggEntity VIDEOS * * @version 5.0 */ public function createVideoEntity() { if (!filter_var($this->input, FILTER_VALIDATE_URL)) { $this->errors[] = 'Not valid url, currently supported for OFFSERVER videos only'; return FALSE; } // try saving the entity now $izap_videos = new IzapVideos(); $izap_videos->access_id = ACCESS_PUBLIC; $return = $izap_videos->input($this->input, 'url'); if (isset($return->status) && $return->status === FALSE) { $this->errors[] = $return->message; return FALSE; } if ($return->videosrc == '' || $return->filecontent == '') { $this->errors[] = elgg_echo('izap_videos:error'); return FALSE; } $izap_videos->title = $return->title; $izap_videos->description = $return->description; $izap_videos->tags = string_to_tag_array($return->videotags); $izap_videos->videosrc = $return->videosrc; $izap_videos->videotype = $return->type; $izap_videos->orignal_thumb = "izap_videos/" . $return->type . "/orignal_" . $return->filename; $izap_videos->imagesrc = "izap_videos/" . $return->type . "/" . $return->filename; $izap_videos->videotype_site = $return->domain; $izap_videos->converted = 'yes'; $izap_videos->setFilename($izap_videos->orignal_thumb); $izap_videos->open("write"); if ($izap_videos->write($return->filecontent)) { $thumb = get_resized_image_from_existing_file($izap_videos->getFilenameOnFilestore(), 120, 90, true); $izap_videos->setFilename($izap_videos->imagesrc); $izap_videos->open("write"); if (!$izap_videos->write($thumb)) { $this->errors[] = elgg_echo('izap_videos:error:saving_thumb'); return FALSE; } } else { $this->errors[] = elgg_echo('izap_videos:error:saving_thumb'); return FALSE; } // if every thing is good till here now we can save it. if (!$izap_videos->save()) { $this->errors[] = register_error(elgg_echo('izap_videos:error:save')); return FALSE; } return $izap_videos; }
/** * this fucntion actually converts the video * @param string $file file loacation * @param int $videoId video guid * @param int $ownerGuid video owner guid * @param int $accessId access id * @return boolean */ function izapConvertVideo_izap_videos($file, $videoId, $videoTitle, $videoUrl, $ownerGuid, $accessId = 2) { global $CONFIG; $return = FALSE; // works only if we have the input file if (file_exists($file)) { // now convert video // // Need to set flag for the file going in the conversion. $queue_object = new izapQueue(); $queue_object->change_conversion_flag($videoId); $video = new izapConvert($file); $videofile = $video->izap_video_convert(); // check if every this is ok if (!is_array($videofile)) { // if every thing is ok then get back values to save $file_values = $video->getValues(); $izap_videofile = 'izap_videos/uploaded/' . $file_values['filename']; $izap_origfile = 'izap_videos/uploaded/' . $file_values['origname']; $izap_videos = new IzapVideos($videoId); $izap_videos->setFilename($izap_videofile); $izap_videos->open("write"); $izap_videos->write($file_values['filecontent']); //check if you do not want to keep original file if (get_plugin_setting('izapKeepOriginal', GLOBAL_IZAP_VIDEOS_PLUGIN) == 'YES') { $izap_videos->setFilename($izap_origfile); $izap_videos->open("write"); $izap_videos->write($file_values['origcontent']); } $izap_videos->converted = 'yes'; $izap_videos->videofile = $izap_videofile; $izap_videos->orignalfile = $izap_origfile; notify_user($ownerGuid, $CONFIG->site_guid, elgg_echo('izap_videos:notifySub:videoConverted'), sprintf(elgg_echo('izap_videos:notifyMsg:videoConverted'), $izap_videos->getUrl())); return true; } else { $errorReason = $videofile['message']; } } else { $errorReason = elgg_echo('izap_videos:fileNotFound'); } $adminGuid = izapGetSiteAdmin_izap_videos(TRUE); // notify admin notify_user($adminGuid, $CONFIG->site_guid, elgg_echo('izap_videos:notifySub:videoNotConverted'), sprintf(elgg_echo('izap_videos:notifyAdminMsg:videoNotConverted'), $errorReason)); if (!empty($errorReason)) { $return = array('error' => TRUE, 'reason' => $errorReason); } return $return; }
if (empty($postedArray['videoEmbed'])) { register_error(elgg_echo('izap_videos:error:emptyEmbedCode')); forward($_SERVER['HTTP_REFERER']); } include_once dirname(__FILE__) . '/EMBED.php'; break; default: // register_error(elgg_echo('izap_videos:error:unknownFileType')); // forward($_SERVER['HTTP_REFERER']); break; } // if we have the optional image then replace all the previous values if ($_FILES['izap']['error']['videoImage'] == 0 && in_array(strtolower(end(explode('.', $_FILES['izap']['name']['videoImage']))), array('jpg', 'gif', 'jpeg', 'png'))) { $izap_videos->setFilename($izap_videos->orignal_thumb); $izap_videos->open("write"); $izap_videos->write(file_get_contents($_FILES['izap']['tmp_name']['videoImage'])); $thumb = get_resized_image_from_existing_file($izap_videos->getFilenameOnFilestore(), 120, 90, true); $izap_videos->setFilename($izap_videos->imagesrc); $izap_videos->open("write"); $izap_videos->write($thumb); } // filter tags if (is_array($izap_videos->tags)) { $filtered_tags = FALSE; foreach ($izap_videos->tags as $tag) { if ($tag != '') { $filtered_tags[] = $tag; } } if ($filtered_tags) { $izap_videos->tags = array_unique($filtered_tags);