/**
  * Create video derivatives (either flv movie or thumbnail)
  *
  * @param integer  $usageId  usage type id
  * @return QubitDigitalObject derivative object
  */
 public function createVideoDerivative($usageId, $connection = null)
 {
     // Build new filename and path
     $originalFullPath = $this->getAbsolutePath();
     list($originalNameNoExtension) = explode('.', $this->getName());
     switch ($usageId) {
         case QubitTerm::REFERENCE_ID:
             $derivativeName = $originalNameNoExtension . '_' . $usageId . '.flv';
             $derivativeFullPath = sfConfig::get('sf_web_dir') . $this->getPath() . $derivativeName;
             self::convertVideoToFlash($originalFullPath, $derivativeFullPath);
             break;
         case QubitTerm::THUMBNAIL_ID:
         default:
             $extension = '.' . self::THUMB_EXTENSION;
             $derivativeName = $originalNameNoExtension . '_' . $usageId . $extension;
             $derivativeFullPath = sfConfig::get('sf_web_dir') . $this->getPath() . $derivativeName;
             $maxDimensions = self::getImageMaxDimensions($usageId);
             self::convertVideoToThumbnail($originalFullPath, $derivativeFullPath, $maxDimensions[0], $maxDimensions[1]);
     }
     if (file_exists($derivativeFullPath) && 0 < ($byteSize = filesize($derivativeFullPath))) {
         $derivative = new QubitDigitalObject();
         $derivative->setPath($this->getPath());
         $derivative->setName($derivativeName);
         $derivative->parentId = $this->id;
         $derivative->setByteSize($byteSize);
         $derivative->usageId = $usageId;
         $derivative->setMimeAndMediaType();
         $derivative->createDerivatives = false;
         $derivative->indexOnSave = false;
         $derivative->save($connection);
         return $derivative;
     }
 }