Ejemplo n.º 1
0
 /**
  * batch createFlavorAsset orgenize a convert job data 
  * 
  * @param flavorParamsOutputWrap $flavor
  * @param int $partnerId
  * @param int $entryId
  * @param string $description
  * @return flavorAsset
  */
 public static function createErrorFlavorAsset(flavorParamsOutputWrap $flavor, $partnerId, $entryId, $description)
 {
     $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavor->getFlavorParamsId());
     if ($flavorAsset) {
         $description = $flavorAsset->getDescription() . "\n" . $description;
         $flavorAsset->setDescription($description);
         $flavorAsset->incrementVersion();
     } else {
         // creates the flavor asset
         $flavorAsset = new flavorAsset();
         $flavorAsset->setPartnerId($partnerId);
         $flavorAsset->setEntryId($entryId);
         $flavorAsset->setDescription($description);
     }
     $flavorAsset->setTags($flavor->getTags());
     $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
     $flavorAsset->setFlavorParamsId($flavor->getFlavorParamsId());
     $flavorAsset->setFileExt($flavor->getFileExt());
     $flavorAsset->save();
     // save flavor params
     $flavor->setPartnerId($partnerId);
     $flavor->setEntryId($entryId);
     $flavor->setFlavorAssetId($flavorAsset->getId());
     $flavor->setFlavorAssetVersion($flavorAsset->getVersion());
     $flavor->save();
     return $flavorAsset;
 }
 public static function ConvertFlavorKdl2Cdl(KDLFlavor $target)
 {
     $flavor = new flavorParamsOutputWrap();
     $flavor->setFlavorParamsId($target->_id);
     $flavor->setName($target->_name);
     $flavor->setType($target->_type);
     $flavor->setTags($target->_tags);
     if ($target->_cdlObject) {
         $flavor->setReadyBehavior($target->_cdlObject->getReadyBehavior());
         $flavor->setSourceRemoteStorageProfileId($target->_cdlObject->getSourceRemoteStorageProfileId());
         $flavor->setRemoteStorageProfileIds($target->_cdlObject->getRemoteStorageProfileIds());
         $flavor->setMediaParserType($target->_cdlObject->getMediaParserType());
     }
     if ($target->IsRedundant()) {
         $flavor->_isRedundant = true;
     } else {
         $flavor->_isRedundant = false;
     }
     if ($target->IsNonComply()) {
         $flavor->_isNonComply = true;
     } else {
         $flavor->_isNonComply = false;
     }
     if ($target->_clipStart) {
         $flavor->setClipOffset($target->_clipStart);
     }
     if ($target->_clipDur) {
         $flavor->setClipDuration($target->_clipDur);
     }
     $flavor->_errors = $flavor->_errors + $target->_errors;
     $flavor->_warnings = $flavor->_warnings + $target->_warnings;
     if ($target->_container) {
         $flavor->setFormat($target->_container->GetIdOrFormat());
     }
     if ($target->_video) {
         //echo "\n target->_video - "; print_r($target->_video); echo "\n";
         $flavor->setVideoCodec($target->_video->GetIdOrFormat());
         $flavor->setVideoBitrate($target->_video->_bitRate);
         $flavor->setWidth($target->_video->_width);
         $flavor->setHeight($target->_video->_height);
         $flavor->setFrameRate($target->_video->_frameRate);
         $flavor->setGopSize($target->_video->_gop);
         if ($target->_video->_arProcessingMode) {
             $flavor->setAspectRatioProcessingMode($target->_video->_arProcessingMode);
         }
         if ($target->_video->_forceMult16) {
             $flavor->setForceFrameToMultiplication16($target->_video->_forceMult16);
         }
     }
     if ($target->_audio) {
         $flavor->setAudioCodec($target->_audio->GetIdOrFormat());
         $flavor->setAudioBitrate($target->_audio->_bitRate);
         $flavor->setAudioChannels($target->_audio->_channels);
         $flavor->setAudioSampleRate($target->_audio->_sampleRate);
     }
     if ($target->_pdf) {
         $flavor->putInCustomData('readonly', $target->_pdf->_readonly);
     }
     $cdlOprSets = KDLWrap::convertOperatorsKdl2Cdl($target->_transcoders);
     if ($target->_engineVersion == 1) {
         KalturaLog::log("\noperators==>\n" . print_r($cdlOprSets, true));
         $flavor->setOperators($cdlOprSets->getSerialized());
         $flavor->setEngineVersion(1);
     } else {
         $flavor->setEngineVersion(0);
         $convEnginesAssociated = null;
         $commandLines = array();
         foreach ($target->_transcoders as $key => $transObj) {
             $extra = $transObj->_extra;
             /* -------------------------
              * Translate KDL transcoders enums to CDL
              */
             $str = null;
             $cdlTrnsId = array_search($transObj->_id, self::$TranscodersCdl2Kdl);
             if ($cdlTrnsId !== false) {
                 $str = $cdlTrnsId;
                 $commandLines[$cdlTrnsId] = $transObj->_cmd;
             }
             // Add qt-faststart processing for mp4 targets (relevant to pre-opertors mode)
             if ($flavor->getFormat() == "mp4" && ($cdlTrnsId == conversionEngineType::FFMPEG || $cdlTrnsId == conversionEngineType::FFMPEG_AUX || $cdlTrnsId == conversionEngineType::MENCODER)) {
                 $fsAddonStr = kConvertJobData::CONVERSION_MILTI_COMMAND_LINE_SEPERATOR . kConvertJobData::CONVERSION_FAST_START_SIGN;
                 $commandLines[$cdlTrnsId] .= $fsAddonStr;
             }
             if ($convEnginesAssociated !== null) {
                 $convEnginesAssociated = $convEnginesAssociated . "," . $str;
             } else {
                 $convEnginesAssociated = $str;
             }
             //echo "transcoder-->".$key." flag:".$flag." str:".$trnsStr."<br>\n";
         }
         $flavor->setCommandLines($commandLines);
         $flavor->setConversionEngines($convEnginesAssociated);
     }
     $flavor->setFileExt($target->EvaluateFileExt());
     $flavor->_errors = $flavor->_errors + $target->_errors;
     //echo "target errs "; print_r($target->_errors);
     //echo "flavor errs "; print_r($flavor->_errors);
     $flavor->_warnings = $flavor->_warnings + $target->_warnings;
     //echo "target wrns "; print_r($target->_warnings);
     //echo "flavor wrns "; print_r($flavor->_warnings);
     //echo "flavor "; print_r($flavor);
     //KalturaLog::log(__METHOD__."\nflavorOutputParams==>\n".print_r($flavor,true));
     return $flavor;
 }