protected function execute(InputInterface $input, OutputInterface $output) { // disable versioning Version::disable(); // get all thumbnails $dir = Asset\Video\Thumbnail\Config::getWorkingDir(); $thumbnails = array(); $files = scandir($dir); foreach ($files as $file) { if (strpos($file, ".xml")) { $thumbnails[] = str_replace(".xml", "", $file); } } $allowedThumbs = array(); if ($input->getOption("thumbnails")) { $allowedThumbs = explode(",", $input->getOption("thumbnails")); } // get only images $conditions = array("type = 'video'"); if ($input->getOption("parent")) { $parent = Asset::getById($input->getOption("parent")); if ($parent instanceof Asset\Folder) { $conditions[] = "path LIKE '" . $parent->getFullPath() . "/%'"; } else { $this->writeError($input->getOption("parent") . " is not a valid asset folder ID!"); exit; } } $list = new Asset\Listing(); $list->setCondition(implode(" AND ", $conditions)); $total = $list->getTotalCount(); $perLoop = 10; for ($i = 0; $i < ceil($total / $perLoop); $i++) { $list->setLimit($perLoop); $list->setOffset($i * $perLoop); $videos = $list->load(); foreach ($videos as $video) { foreach ($thumbnails as $thumbnail) { if (empty($allowedThumbs) && !$input->getOption("system") || in_array($thumbnail, $allowedThumbs)) { $this->output->writeln("generating thumbnail for video: " . $video->getFullpath() . " | " . $video->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage())); $video->getThumbnail($thumbnail); $this->waitTillFinished($video->getId(), $thumbnail); } } if ($input->getOption("system")) { $this->output->writeln("generating thumbnail for video: " . $video->getFullpath() . " | " . $video->getId() . " | Thumbnail: System Preview : " . formatBytes(memory_get_usage())); $thumbnail = Asset\Video\Thumbnail\Config::getPreviewConfig(); $video->getThumbnail($thumbnail); $this->waitTillFinished($video->getId(), $thumbnail); } } } }
// display help message if ($opts->getOption("help")) { echo $opts->getUsageMessage(); exit; } if ($opts->getOption("verbose")) { $writer = new \Zend_Log_Writer_Stream('php://output'); $logger = new \Zend_Log($writer); \Logger::addLogger($logger); // set all priorities \Logger::setVerbosePriorities(); } // disable versioning Version::disable(); // get all thumbnails $dir = Asset\Video\Thumbnail\Config::getWorkingDir(); $thumbnails = array(); $files = scandir($dir); foreach ($files as $file) { if (strpos($file, ".xml")) { $thumbnails[] = str_replace(".xml", "", $file); } } $allowedThumbs = array(); if ($opts->getOption("thumbnails")) { $allowedThumbs = explode(",", $opts->getOption("thumbnails")); } // get only images $conditions = array("type = 'video'"); if ($opts->getOption("parent")) { $parent = Asset::getById($opts->getOption("parent"));
public function videoThumbnailTreeAction() { $this->checkPermission("thumbnails"); $dir = Asset\Video\Thumbnail\Config::getWorkingDir(); $pipelines = array(); $files = scandir($dir); foreach ($files as $file) { if (strpos($file, ".xml")) { $name = str_replace(".xml", "", $file); $pipelines[] = array("id" => $name, "text" => $name); } } $this->_helper->json($pipelines); }