Beispiel #1
0
 public function getAssetCode()
 {
     $asset = Asset::getById($this->id);
     $options = $this->getOptions();
     if ($asset && $options["thumbnail"]) {
         $thumbnail = $asset->getThumbnail($options["thumbnail"]);
         if ($thumbnail) {
             $image = $asset->getImageThumbnail(array("width" => $this->getWidth(), "height" => $this->getHeight()));
             if ($thumbnail["status"] == "finished") {
                 return $this->getFlowplayerCode($thumbnail["formats"], $image);
             } else {
                 if ($thumbnail["status"] == "inprogress") {
                     // disable the output-cache if enabled
                     $front = Zend_Controller_Front::getInstance();
                     $front->unregisterPlugin("Pimcore_Controller_Plugin_Cache");
                     $progress = Asset_Video_Thumbnail_Processor::getProgress($thumbnail["processId"]);
                     return $this->getProgressCode($progress, $image);
                 }
             }
         }
     }
     return $this->getFlowplayerCode((string) $asset);
 }
        }

    </style>

</head>

<body>

<table id="wrapper" width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="error" align="center" valign="center">
            <?php 
if ($this->thumbnail && $this->thumbnail["status"] == "inprogress") {
    ?>
                <?php 
    $progress = Asset_Video_Thumbnail_Processor::getProgress($this->thumbnail["processId"]);
    ?>

                <style type="text/css">
                    .pimcore_tag_video_progress {
                        position:relative;
                        background:#555 url(<?php 
    echo $this->asset->getImageThumbnail(array("width" => 640));
    ?>
) no-repeat center center;
                        font-family:Arial,Verdana,sans-serif;
                        color:#fff;
                        text-shadow: 0 0 3px #000, 0 0 5px #000, 0 0 1px #000;
                    }
                    .pimcore_tag_video_progress_status {
                        font-size:16px;
Beispiel #3
0
 public function getAssetCode()
 {
     $asset = Asset::getById($this->id);
     // compatibility mode when FFMPEG is not present
     if (!Pimcore_Video::isAvailable()) {
         // try to load the assigned asset into the flowplayer
         return $this->getFlowplayerCode(array("mp4" => (string) $asset));
     }
     $options = $this->getOptions();
     if ($asset instanceof Asset_Video && $options["thumbnail"]) {
         $thumbnail = $asset->getThumbnail($options["thumbnail"]);
         if ($thumbnail) {
             // try to get the dimensions out ouf the video thumbnail
             $imageThumbnailConf = array();
             $thumbnailConf = $asset->getThumbnailConfig($options["thumbnail"]);
             $transformations = $thumbnailConf->getItems();
             if (is_array($transformations) && count($transformations) > 0) {
                 foreach ($transformations as $transformation) {
                     if (!empty($transformation)) {
                         if (is_array($transformation["arguments"])) {
                             foreach ($transformation["arguments"] as $key => $value) {
                                 if ($key == "width" || $key == "height") {
                                     $imageThumbnailConf[$key] = $value;
                                 }
                             }
                         }
                     }
                 }
             }
             if (empty($imageThumbnailConf)) {
                 $imageThumbnailConf["width"] = 800;
             }
             $image = $asset->getImageThumbnail($imageThumbnailConf);
             if ($thumbnail["status"] == "finished") {
                 if ($options["html5"]) {
                     return $this->getHtml5Code($thumbnail["formats"], $image);
                 } else {
                     return $this->getFlowplayerCode($thumbnail["formats"], $image);
                 }
             } else {
                 if ($thumbnail["status"] == "inprogress") {
                     // disable the output-cache if enabled
                     $front = Zend_Controller_Front::getInstance();
                     $front->unregisterPlugin("Pimcore_Controller_Plugin_Cache");
                     $progress = Asset_Video_Thumbnail_Processor::getProgress($thumbnail["processId"]);
                     return $this->getProgressCode($progress, $image);
                 } else {
                     return $this->getErrorCode("The video conversion failed, please see the debug.log for more details.");
                 }
             }
         } else {
             return $this->getErrorCode("The given thumbnail doesn't exist");
         }
     } else {
         // try to load the assigned asset into the flowplayer (backward compatibility only for f4v, flv, and mp4 files)
         if ($asset instanceof Asset && preg_match("/\\.(f4v|flv|mp4)/", $asset->getFullPath())) {
             // try to generate thumbnail with ffmpeg if installed
             if (Pimcore_Video::isAvailable()) {
                 $image = $asset->getImageThumbnail(array("width" => array_key_exists("width", $options) ? $options["width"] : 800));
             }
             return $this->getFlowplayerCode(array("mp4" => (string) $asset), $image);
         }
         return $this->getErrorCode("Asset is not a video, or missing thumbnail configuration");
     }
 }
Beispiel #4
0
 /**
  * Returns a path to a given thumbnail or an thumbnail configuration
  *
  * @param mixed
  * @return string
  */
 public function getThumbnail($thumbnailName, $onlyFormats = array())
 {
     $thumbnail = $this->getThumbnailConfig($thumbnailName);
     if ($thumbnail) {
         try {
             Asset_Video_Thumbnail_Processor::process($this, $thumbnail, $onlyFormats);
             // check for existing videos
             $customSetting = $this->getCustomSetting("thumbnails");
             if (is_array($customSetting) && array_key_exists($thumbnail->getName(), $customSetting)) {
                 return $customSetting[$thumbnail->getName()];
             }
         } catch (Exception $e) {
             Logger::error("Couldn't create thumbnail of video " . $this->getFullPath());
             Logger::error($e);
         }
     }
     return null;
 }
<?php

/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @copyright  Copyright (c) 2009-2010 elements.at New Media Solutions GmbH (http://www.elements.at)
 * @license    http://www.pimcore.org/license     New BSD License
 */
include_once "startup.php";
Asset_Video_Thumbnail_Processor::execute($argv[1]);