public static function CDLGenerateTargetFlavorsCmdLinesOnly($fileSizeKb, $cdlFlavorList)
 {
     $kdlWrap = new KDLWrap();
     if ($fileSizeKb < KDLSanityLimits::MinFileSize) {
         $kdlWrap->_rv = false;
         $kdlWrap->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::SanityInvalidFileSize, $fileSizeKb);
         return $kdlWrap;
     }
     return $kdlWrap->generateTargetFlavors(null, $cdlFlavorList);
 }
示例#2
0
 public function CheckConstraints(KDLMediaDataSet $source, KDLFlavor $target, array &$errors = null, array &$warnings = null)
 {
     //No need for 'global' check, each engine can check for itself
     //		if(parent::CheckConstraints($source, $target, $errors, $warnings)==true)
     //			return true;
     if ($this->_id == KDLTranscoders::FFMPEG_AUX) {
         $transcoder = new KDLOperatorFfmpeg2_2($this->_id);
         if ($transcoder->CheckConstraints($source, $target, $errors, $warnings) == true) {
             return true;
         }
     }
     if ($this->_id == KDLTranscoders::FFMPEG) {
         $transcoder = new KDLOperatorFfmpeg2_7_2($this->_id);
         if ($transcoder->CheckConstraints($source, $target, $errors, $warnings) == true) {
             return true;
         }
     }
     if ($this->_id == KDLTranscoders::MENCODER) {
         $transcoder = new KDLOperatorMencoder($this->_id);
         if ($transcoder->CheckConstraints($source, $target, $errors, $warnings) == true) {
             return true;
         }
     }
     if ($this->_id == KDLTranscoders::ON2) {
         $transcoder = new KDLOperatorOn2($this->_id);
         if ($transcoder->CheckConstraints($source, $target, $errors, $warnings) == true) {
             return true;
         }
     }
     /*
      * Remove encoding.com for DAR<>PAR
      */
     if ($this->_id == KDLTranscoders::ENCODING_COM && $source->_video && $source->_video->_dar && abs($source->_video->GetPAR() - $source->_video->_dar) > 0.01) {
         $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderFormat, $this->_id, "non square pixels");
         return true;
     }
     /*
      * Prevent invalid copy attempts, that might erronously end up with 'false-positive' result
      */
     if (isset($target->_video) && $target->_video->_id == KDLVideoTarget::COPY || isset($target->_audio) && $target->_audio->_id == KDLAudioTarget::COPY) {
         if ($target->_container->_id == KDLContainerTarget::FLV) {
             $rvArr = $source->ToTags(array("web"));
             if (count($rvArr) == 0) {
                 $errStr = "Copy to Target format:FLV, Source:" . $source->ToString();
                 $target->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::InvalidRequest, $errStr);
                 return true;
             }
         }
     }
     return false;
 }
示例#3
0
 public function Validate()
 {
     if ($this->_video != "") {
         $this->_video->Validate($this->_errors, $this->_warnings);
     }
     if ($this->_audio != "") {
         $this->_audio->Validate($this->_errors, $this->_warnings);
     }
     if ($this->_container != "" && $this->_image == "") {
         $this->_container->Validate($this->_errors, $this->_warnings);
     }
     if ($this->_video == "" && $this->_audio == "" && $this->_image == "") {
         // "Invalid File - No media content";
         $this->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::NoValidMediaStream);
     }
     if (count($this->_errors) > 0) {
         return false;
     }
     return true;
 }
 public function ValidateProduct(KDLMediaDataSet $source, KDLFlavor $product)
 {
     KalturaLog::log(".TRG-->" . $this->ToString());
     $rv = $product->ValidateFlavor();
     if ($source) {
         $srcVid = $source->_video;
         $srcAud = $source->_audio;
         $srcCont = $source->_container;
     } else {
         $srcVid = null;
         $srcAud = null;
         $srcCont = null;
     }
     /*
      * Evaluate source duration, to be used to check the product duration validity 
      */
     $plannedDur = 0;
     if ($this->_clipDur && $this->_clipDur > 0) {
         $plannedDur = $this->_clipDur;
         $vDur = $plannedDur;
         $aDur = $plannedDur;
         $cDur = $plannedDur;
     } else {
         $vDur = isset($srcVid) ? $srcVid->_duration : 0;
         $aDur = isset($srcAud) ? $srcAud->_duration : 0;
         $cDur = isset($srcCont) ? $srcCont->_duration : 0;
         $plannedDur = max(max($aDur, $vDur), $cDur);
     }
     if ($this->_video !== null) {
         if ($product->_video === null) {
             $product->_errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::MissingMediaStream);
             $rv = false;
         } else {
             $prdVid = $product->_video;
             $trgVid = $this->_video;
             if ($plannedDur > 0) {
                 if ($prdVid->_duration < $plannedDur * KDLSanityLimits::MinDurationFactor || $prdVid->_duration > $plannedDur * KDLSanityLimits::MaxDurationFactor) {
                     $product->_errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::InvalidDuration, $prdVid->_duration / 1000, $plannedDur / 1000);
                     $rv = false;
                 } else {
                     if ($prdVid->_duration < $plannedDur * KDLConstants::ProductDurationFactor) {
                         $product->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ProductShortDuration, $prdVid->_duration, $plannedDur);
                     }
                 }
             }
             if (isset($srcVid) && $prdVid->_bitRate < $trgVid->_bitRate * KDLConstants::ProductBitrateFactor) {
                 $product->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ProductLowBitrate, $prdVid->_bitRate, $srcVid->_bitRate);
             }
         }
     }
     if ($this->_audio !== null) {
         if ($product->_audio === null) {
             $product->_errors[KDLConstants::AudioIndex][] = KDLErrors::ToString(KDLErrors::MissingMediaStream);
             $rv = false;
         } else {
             $prdAud = $product->_audio;
             $trgAud = $this->_audio;
             if ($plannedDur) {
                 if ($prdAud->_duration < $plannedDur * KDLSanityLimits::MinDurationFactor || $prdAud->_duration > $plannedDur * KDLSanityLimits::MaxDurationFactor) {
                     $product->_errors[KDLConstants::AudioIndex][] = KDLErrors::ToString(KDLErrors::InvalidDuration, $prdAud->_duration / 1000, $plannedDur / 1000);
                     $rv = false;
                 } else {
                     if ($prdAud->_duration < $plannedDur * KDLConstants::ProductDurationFactor) {
                         $product->_warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::ProductShortDuration, $prdAud->_duration, $plannedDur);
                     }
                 }
             }
             if (isset($srcAud) && $prdAud->_bitRate < $trgAud->_bitRate * KDLConstants::ProductBitrateFactor) {
                 $product->_warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::ProductLowBitrate, $prdAud->_bitRate, $srcAud->_bitRate);
             }
         }
     }
     if ($product->_video === null && $product->_audio === null) {
         // "Invalid File - No media content.";
         $product->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::NoValidMediaStream);
     }
     KalturaLog::log(".PRD-->" . $product->ToString());
     return $rv;
 }
示例#5
0
 public function ValidateProduct(KDLMediaDataSet $source, KDLFlavor $product)
 {
     KalturaLog::log(".SRC-->" . $source->ToString());
     KalturaLog::log(".TRG-->" . $this->ToString());
     KalturaLog::log(".PRD-->" . $product->ToString());
     $rv = $product->ValidateFlavor();
     if ($source) {
         $srcVid = $source->_video;
         $srcAud = $source->_audio;
         $srcCont = $source->_container;
     } else {
         $srcVid = null;
         $srcAud = null;
         $srcCont = null;
     }
     /*
      * ARF (webex) sources don't have proper mediaInfo - thus can not validate the product, skip it
      * 
      * - The second portion of the 'if condition' is a workaround to handle invalidly passed inter-src 
      * asset both as a source and as a product. 
      * It is 'strstr' rather than 'strcmp', because call to 'product->ValidateFlavor' might add warnings to the ToString
      */
     //		if(isset($srcCont) && $srcCont->GetIdOrFormat()=='arf') {
     if (isset($srcCont) && $srcCont->GetIdOrFormat() == 'arf' || strstr($product->ToString(), $source->ToString()) != false) {
         KalturaLog::log("ARF (webex) sources don't have proper mediaInfo - thus can not validate the product");
         return true;
     }
     /*
      * WVM (DRM Widevine) sources don't have proper mediaInfo - thus can not validate the product, skip it
      */
     if (isset($this->_container) && $this->_container->GetIdOrFormat() == 'wvm') {
         KalturaLog::log("WVM (DRM Widevine) sources don't have proper mediaInfo - thus can not validate the product");
         return true;
     }
     /*
      * Evaluate source duration, to be used to check the product duration validity 
      */
     $plannedDur = 0;
     if ($this->_clipDur && $this->_clipDur > 0) {
         $plannedDur = $this->_clipDur;
         $vDur = $plannedDur;
         $aDur = $plannedDur;
         $cDur = $plannedDur;
     } else {
         $vDur = isset($srcVid) ? $srcVid->_duration : 0;
         $aDur = isset($srcAud) ? $srcAud->_duration : 0;
         $cDur = isset($srcCont) ? $srcCont->_duration : 0;
         $plannedDur = max(max($aDur, $vDur), $cDur);
     }
     /*
      * Allow conversion and fixing of invalidly muxed WEB-CAM recordecd files - 
      * - FLV/Sorenson/Nellimossr
      * - very HUGE duration
      * - very LOW bitrate - about several bits-per-sec.
      * In such cases the 'duration validation' is un-applicable
      *
     if(isset($srcVid) && $srcVid->IsFormatOf(array("h.263","h263","sorenson spark","vp6")) 
     && isset($srcAud) && $srcAud->IsFormatOf(array('nellymoser')) && $cDur>0 && isset($srcCont->_fileSize)){
     	if($srcCont->_fileSize*8000/$cDur<KDLSanityLimits::MinBitrate) {
     		KalturaLog::log("Invalid WEB-CAM source file. Duration validation is un-applicable");
     		return true;
     	}
     }
     */
     if ($this->_video !== null) {
         if ($product->_video === null) {
             $product->_errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::MissingMediaStream);
             $rv = false;
         } else {
             $prdVid = $product->_video;
             $trgVid = $this->_video;
             /*
              *  On short durations, the 'granulariity' of a single frame dur might cause invalidation. 
              *  Don't check for <2sec
              */
             if ($plannedDur > 2000) {
                 if ($prdVid->_duration < $plannedDur * KDLSanityLimits::MinDurationFactor || $prdVid->_duration > $plannedDur * KDLSanityLimits::MaxDurationFactor) {
                     //This check was added to filter out files that have no duration set on their metadata and are of type ogg or ogv to avoid failure on product validation (SUP 546)
                     if ($aDur == 0 && in_array(strtolower($this->_container->GetIdOrFormat()), array("ogg", "ogv"))) {
                         //Do Nothing
                     } else {
                         $product->_errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::InvalidDuration, $prdVid->_duration / 1000, $plannedDur / 1000);
                         $rv = false;
                     }
                 } else {
                     if ($prdVid->_duration < $plannedDur * KDLConstants::ProductDurationFactor) {
                         $product->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ProductShortDuration, $prdVid->_duration, $plannedDur);
                     }
                 }
             }
             if (isset($srcVid) && $prdVid->_bitRate < $trgVid->_bitRate * KDLConstants::ProductBitrateFactor) {
                 $product->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ProductLowBitrate, $prdVid->_bitRate, $srcVid->_bitRate);
             }
         }
     }
     if ($this->_audio !== null) {
         if ($product->_audio === null) {
             $product->_errors[KDLConstants::AudioIndex][] = KDLErrors::ToString(KDLErrors::MissingMediaStream);
             $rv = false;
         } else {
             $prdAud = $product->_audio;
             $trgAud = $this->_audio;
             /*
              * On short durations, the 'granulariity' of a single frame dur might cause invalidation.
              * Don't check for <2sec
              */
             if ($plannedDur > 2000) {
                 if ($prdAud->_duration < $plannedDur * KDLSanityLimits::MinDurationFactor || $prdAud->_duration > $plannedDur * KDLSanityLimits::MaxDurationFactor) {
                     $product->_errors[KDLConstants::AudioIndex][] = KDLErrors::ToString(KDLErrors::InvalidDuration, $prdAud->_duration / 1000, $plannedDur / 1000);
                     $rv = false;
                 } else {
                     if ($prdAud->_duration < $plannedDur * KDLConstants::ProductDurationFactor) {
                         $product->_warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::ProductShortDuration, $prdAud->_duration, $plannedDur);
                     }
                 }
             }
             if (isset($srcAud) && $prdAud->_bitRate < $trgAud->_bitRate * KDLConstants::ProductBitrateFactor) {
                 $product->_warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::ProductLowBitrate, $prdAud->_bitRate, $srcAud->_bitRate);
             }
         }
     }
     if ($product->_video === null && $product->_audio === null) {
         // "Invalid File - No media content.";
         $product->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::NoValidMediaStream);
     }
     KalturaLog::log(".PRD-->" . $product->ToString());
     return $rv;
 }
 public function CheckConstraints(KDLMediaDataSet $source, KDLFlavor $target, array &$errors = null, array &$warnings = null)
 {
     if (KDLOperatorBase::CheckConstraints($source, $target, $errors, $warnings) == true) {
         return true;
     }
     if (!isset($target->_video)) {
         return false;
     }
     /*
      * HD codecs (prores & dnxhd) can be packaged only in MOV/MXF
      */
     $hdCodecsArr = array(KDLVideoTarget::APCO, KDLVideoTarget::APCS, KDLVideoTarget::APCN, KDLVideoTarget::APCH, KDLVideoTarget::DNXHD);
     if (isset($target->_container)) {
         if (!$target->_container->IsFormatOf(array(KDLContainerTarget::MOV, KDLContainerTarget::MXF)) && in_array($target->_video->_id, $hdCodecsArr)) {
             $target->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::PackageMovOnly, $target->_video->_id);
             return true;
         }
     }
     /*
      * DNXHD - check validity of frame-size/bitrate mix
      */
     /*
     Project Format	Resolution	Frame Size	Bits	FPS		<bitrate>
     1080i / 59.94	DNxHD 220	1920 x 1080	8		29.97	220M
     1080i / 59.94	DNxHD 145	1920 x 1080	8		29.97	145M
     1080i / 50		DNxHD 185	1920 x 1080	8		25		185M
     1080i / 50		DNxHD 120	1920 x 1080	8		25		120M
     1080p / 25		DNxHD 185	1920 x 1080	8		25		185M
     1080p / 25		DNxHD 120	1920 x 1080	8		25		120M
     1080p / 25		DNxHD 36	1920 x 1080	8		25		36M
     1080p / 24		DNxHD 175	1920 x 1080	8		24		175M
     1080p / 24		DNxHD 115	1920 x 1080	8		24		115M
     1080p / 24		DNxHD 36	1920 x 1080	8		24		36M
     1080p / 23.976	DNxHD 175	1920 x 1080	8		23.976	175M
     1080p / 23.976	DNxHD 115	1920 x 1080	8		23.976	115M
     1080p / 23.976	DNxHD 36	1920 x 1080	8		23.976	36M
     1080p / 29.7	DNxHD 45	1920 x 1080	8		29.97	45M
     
     720p  / 59.94	DNxHD 220	1280 x 720	8		59.94	220M
     720p  / 59.94	DNxHD 145	1280 x 720	8		59.94	145M
     720p  / 50		DNxHD 175	1280 x 720	8		50		175M
     720p  / 50		DNxHD 115	1280 x 720	8		50		115M
     720p  / 23.976	DNxHD 90	1280 x 720	8		23.976	90M
     720p  / 23.976	DNxHD 60	1280 x 720	8		23.976	60M
     */
     if ($target->_video->_id == KDLVideoTarget::DNXHD) {
         if (!isset($target->_video->_width) || $target->_video->_width == 0) {
             $width = 0;
         } else {
             $width = $target->_video->_width;
         }
         if (!isset($target->_video->_height) || $target->_video->_height == 0) {
             $height = 0;
         } else {
             $height = $target->_video->_height;
         }
         $dnxhd720BitratesArr = array(220000, 145000, 175000, 115000, 90000, 60000);
         $dnxhd1080BitratesArr = array(220000, 145000, 185000, 120000, 36000, 175000, 115000, 45000);
         if (in_array($target->_video->_bitRate, $dnxhd720BitratesArr) && ($width == 1280 && $height == 720 || $width == 1280 && $height == 0 || $width == 0 && $height == 720)) {
             KalturaLog::log("Supported DNXHD - br:" . $this->_video->_bitRate . ",w:{$width},h:{$height}");
         } else {
             if (in_array($target->_video->_bitRate, $dnxhd1080BitratesArr) && ($width == 1920 && $height == 1080 || $width == 1920 && $height == 0 || $width == 0 && $height == 1080)) {
                 KalturaLog::log("Supported DNXHD - br:" . $target->_video->_bitRate . ",w:{$width},h:{$height}");
             } else {
                 $str = "br:" . $target->_video->_bitRate . ",w:{$width},h:{$height}";
                 $target->_errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::DnxhdUnsupportedParams, $str);
                 return true;
             }
         }
     }
     return $this->checkBasicFFmpegConstraints($source, $target, $errors, $warnings);
 }
示例#7
0
 public static function decideProfileFlavorsConvert(BatchJob $parentJob, BatchJob $convertProfileJob, array $flavors, array $conversionProfileFlavorParams, $conversionProfileId, mediaInfo $mediaInfo = null)
 {
     $entryId = $convertProfileJob->getEntryId();
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($originalFlavorAsset)) {
         $errDescription = 'Original flavor asset not found';
         self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId());
         return false;
     }
     $errDescription = null;
     try {
         $finalFlavors = self::validateConversionProfile($convertProfileJob->getPartnerId(), $entryId, $mediaInfo, $flavors, $conversionProfileFlavorParams, $errDescription);
     } catch (Exception $e) {
         $code = $e->getCode();
         if ($code == KDLErrors::SanityInvalidFrameDim || $code == KDLErrors::NoValidMediaStream) {
             $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription);
             KalturaLog::err($e->getMessage());
             throw $e;
         }
     }
     KalturaLog::log(count($finalFlavors) . " flavors returned from the decision layer");
     if (is_null($finalFlavors)) {
         $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription);
         KalturaLog::log("No flavors created");
         //throw new Exception($errDescription); no need to throw alert if the root job failed
     }
     if (strlen($errDescription)) {
         $err = $convertProfileJob->getDescription() . $errDescription;
         $convertProfileJob->setDescription($err);
         $convertProfileJob->save();
         //Check if the error thrown is invalid file - no media content
         if (strpos($errDescription, KDLErrors::ToString(KDLErrors::NoValidMediaStream)) !== false) {
             throw new Exception(KDLErrors::ToString(KDLErrors::NoValidMediaStream), KDLErrors::NoValidMediaStream);
         }
     }
     $conversionsCreated = 0;
     $waitingAssets = 0;
     $entry = $convertProfileJob->getEntry();
     if (!$entry) {
         throw new APIException(APIErrors::INVALID_ENTRY, $convertProfileJob, $entryId);
     }
     $flavorsCollections = array();
     // create a convert job per each flavor
     foreach ($finalFlavors as $flavor) {
         $flavorAsset = kBatchManager::createFlavorAsset($flavor, $entry->getPartnerId(), $entry->getId());
         if (!$flavorAsset) {
             continue;
         }
         $collectionTag = $flavor->getCollectionTag();
         /*
          * CHANGE: collection porcessing only for ExpressionEncoder jobs
          * to allow FFmpeg/ISMV processing
          */
         KalturaLog::log("Check for collection case - engines(" . $flavor->getConversionEngines() . ")");
         if ($collectionTag && $flavor->getConversionEngines() == conversionEngineType::EXPRESSION_ENCODER3) {
             $flavorsCollections[$collectionTag][] = $flavor;
         } else {
             KalturaLog::log("Adding flavor conversion with flavor params output id [" . $flavor->getId() . "] and flavor params asset id [" . $flavorAsset->getId() . "]");
             $madiaInfoId = $mediaInfo ? $mediaInfo->getId() : null;
             $createdJob = self::decideFlavorConvert($flavorAsset, $flavor, $originalFlavorAsset, $conversionProfileId, $madiaInfoId, $parentJob);
             if ($createdJob) {
                 $conversionsCreated++;
             }
             if ($flavorAsset->getStatus() == flavorAsset::ASSET_STATUS_WAIT_FOR_CONVERT) {
                 $waitingAssets++;
             }
         }
     }
     foreach ($flavorsCollections as $tag => $flavors) {
         $createdJob = self::decideCollectionConvert($tag, $originalFlavorAsset, $entry, $parentJob, $flavors);
         if ($createdJob) {
             $conversionsCreated++;
         }
     }
     if (!$conversionsCreated && !$waitingAssets) {
         KalturaLog::log("No flavors created: {$errDescription}");
         $convertProfileJob = kJobsManager::failBatchJob($convertProfileJob, $errDescription);
         return false;
     }
     return true;
 }
示例#8
0
 public static function ConvertFlavorCdl2Kdl($cdlFlavor)
 {
     $kdlFlavor = new KDLFlavor();
     $kdlFlavor->_name = $cdlFlavor->getName();
     $kdlFlavor->_id = $cdlFlavor->getId();
     $kdlFlavor->_type = $cdlFlavor->getType();
     $kdlFlavor->_tags = $cdlFlavor->getTags();
     if ($cdlFlavor instanceof flavorParams) {
         $kdlFlavor->_clipStart = $cdlFlavor->getClipOffset();
         $kdlFlavor->_clipDur = $cdlFlavor->getClipDuration();
         /**/
         $multiStream = $cdlFlavor->getMultiStream();
         if (isset($multiStream)) {
             //Sample json string: {"detect":"auto","audio":{"mapping":[1,2]}}
             $fromJson = json_decode($multiStream);
             $kdlFlavor->_multiStream = isset($fromJson) ? $fromJson : null;
         }
         $kdlFlavor->_optimizationPolicy = $cdlFlavor->getOptimizationPolicy();
     } else {
         if ($cdlFlavor instanceof flavorParamsOutput) {
             $kdlFlavor->_clipStart = $cdlFlavor->getClipOffset();
             $kdlFlavor->_clipDur = $cdlFlavor->getClipDuration();
         }
     }
     $kdlFlavor->_cdlObject = $cdlFlavor;
     $kdlFlavor->_container = new KDLContainerData();
     $kdlFlavor->_container->_id = $cdlFlavor->getFormat();
     //		$kdlFlavor->_container->_duration=$api->getContainerDuration();
     //		$kdlFlavor->_container->_bitRate=$api->getContainerBitRate();
     //		$kdlFlavor->_container->_fileSize=$api->getFileSize();
     if ($kdlFlavor->_container->IsDataSet() == false) {
         $kdlFlavor->_container = null;
     }
     $kdlFlavor->_video = new KDLVideoData();
     $kdlFlavor->_video->_id = $cdlFlavor->getVideoCodec();
     //		$kdlFlavor->_video->_format = $api->getVideoFormat();
     //		$kdlFlavor->_video->_duration = $api->getVideoDuration();
     $kdlFlavor->_video->_bitRate = $cdlFlavor->getVideoBitRate();
     $kdlFlavor->_video->_width = $cdlFlavor->getWidth();
     $kdlFlavor->_video->_height = $cdlFlavor->getHeight();
     $kdlFlavor->_video->_frameRate = $cdlFlavor->getFrameRate();
     $kdlFlavor->_video->_gop = $cdlFlavor->getGopSize();
     $kdlFlavor->_isTwoPass = $cdlFlavor->getTwoPass();
     $kdlFlavor->_video->_arProcessingMode = $cdlFlavor->getAspectRatioProcessingMode();
     $kdlFlavor->_video->_forceMult16 = $cdlFlavor->getForceFrameToMultiplication16();
     if ($cdlFlavor instanceof flavorParams) {
         $kdlFlavor->_video->_cbr = $cdlFlavor->getVideoConstantBitrate();
         $kdlFlavor->_video->_bt = $cdlFlavor->getVideoBitrateTolerance();
         $kdlFlavor->_video->_isGopInSec = $cdlFlavor->getIsGopInSec();
         $kdlFlavor->_video->_isShrinkFramesizeToSource = !$cdlFlavor->getIsAvoidVideoShrinkFramesizeToSource();
         $kdlFlavor->_video->_isShrinkBitrateToSource = !$cdlFlavor->getIsAvoidVideoShrinkBitrateToSource();
         $kdlFlavor->_video->_isFrameRateForLowBrAppleHls = $cdlFlavor->getIsVideoFrameRateForLowBrAppleHls();
         $kdlFlavor->_video->_anamorphic = $cdlFlavor->getAnamorphicPixels();
         $kdlFlavor->_video->_maxFrameRate = $cdlFlavor->getMaxFrameRate();
         $kdlFlavor->_video->_isForcedKeyFrames = !$cdlFlavor->getIsAvoidForcedKeyFrames();
         $kdlFlavor->_video->_isCropIMX = $cdlFlavor->getIsCropIMX();
         $watermarkData = $cdlFlavor->getWatermarkData();
         if (isset($watermarkData)) {
             $fromJson = json_decode($watermarkData);
             $kdlFlavor->_video->_watermarkData = isset($fromJson) ? $fromJson : null;
         }
     }
     //		$flavor->_video->_dar = $api->getVideoDar();
     if ($kdlFlavor->_video->IsDataSet() == false) {
         $kdlFlavor->_video = null;
     }
     $kdlFlavor->_audio = new KDLAudioData();
     $kdlFlavor->_audio->_id = $cdlFlavor->getAudioCodec();
     //		$flavor->_audio->_format = $cdlFlavor->getAudioFormat();
     //		$flavor->_audio->_duration = $cdlFlavor->getAudioDuration();
     $kdlFlavor->_audio->_bitRate = $cdlFlavor->getAudioBitRate();
     $kdlFlavor->_audio->_channels = $cdlFlavor->getAudioChannels();
     $kdlFlavor->_audio->_sampleRate = $cdlFlavor->getAudioSampleRate();
     $kdlFlavor->_audio->_resolution = $cdlFlavor->getAudioResolution();
     if ($kdlFlavor->_audio->IsDataSet() == false) {
         $kdlFlavor->_audio = null;
     }
     $operators = $cdlFlavor->getOperators();
     $transObjArr = array();
     //KalturaLog::log(__METHOD__."\nCDL Flavor==>\n".print_r($cdlFlavor,true));
     if (!empty($operators) || $cdlFlavor->getEngineVersion() == 1) {
         $transObjArr = KDLWrap::convertOperatorsCdl2Kdl($operators);
         $kdlFlavor->_engineVersion = 1;
     } else {
         $kdlFlavor->_engineVersion = 0;
         $trnsStr = $cdlFlavor->getConversionEngines();
         $extraStr = $cdlFlavor->getConversionEnginesExtraParams();
         $transObjArr = KDLUtils::parseTranscoderList($trnsStr, $extraStr);
         if ($cdlFlavor instanceof flavorParamsOutputWrap || $cdlFlavor instanceof flavorParamsOutput) {
             $cmdLines = $cdlFlavor->getCommandLines();
             foreach ($transObjArr as $transObj) {
                 $transObj->_cmd = $cmdLines[$transObj->_id];
             }
         }
         KalturaLog::log("\ntranscoders==>\n" . print_r($transObjArr, true));
     }
     KDLUtils::RecursiveScan($transObjArr, "transcoderSetFuncWrap", self::$TranscodersCdl2Kdl, "");
     $kdlFlavor->_transcoders = $transObjArr;
     if ($cdlFlavor instanceof flavorParamsOutputWrap) {
         if ($cdlFlavor->_isRedundant) {
             $kdlFlavor->_flags = $kdlFlavor->_flags | KDLFlavor::RedundantFlagBit;
         }
         if ($cdlFlavor->_isNonComply) {
             $kdlFlavor->_flags = $kdlFlavor->_flags | KDLFlavor::BitrateNonComplyFlagBit;
         }
         $kdlFlavor->_errors = $kdlFlavor->_errors + $cdlFlavor->_errors;
         $kdlFlavor->_warnings = $kdlFlavor->_warnings + $cdlFlavor->_warnings;
     }
     if ($cdlFlavor instanceof SwfFlavorParams || $cdlFlavor instanceof SwfFlavorParamsOutput) {
         $kdlFlavor->_swf = new KDLSwfData();
         $kdlFlavor->_swf->_flashVersion = $cdlFlavor->getFlashVersion();
         $kdlFlavor->_swf->_zoom = $cdlFlavor->getZoom();
         $kdlFlavor->_swf->_zlib = $cdlFlavor->getZlib();
         $kdlFlavor->_swf->_jpegQuality = $cdlFlavor->getJpegQuality();
         $kdlFlavor->_swf->_sameWindow = $cdlFlavor->getSameWindow();
         $kdlFlavor->_swf->_insertStop = $cdlFlavor->getInsertStop();
         $kdlFlavor->_swf->_useShapes = $cdlFlavor->getUseShapes();
         $kdlFlavor->_swf->_storeFonts = $cdlFlavor->getStoreFonts();
         $kdlFlavor->_swf->_flatten = $cdlFlavor->getFlatten();
         $kdlFlavor->_swf->_poly2Bitmap = $cdlFlavor->getPoly2bitmap();
     }
     if ($cdlFlavor instanceof PdfFlavorParams || $cdlFlavor instanceof PdfFlavorParamsOutput) {
         $kdlFlavor->_pdf = new KDLPdfData();
         $kdlFlavor->_pdf->_resolution = $cdlFlavor->getResolution();
         $kdlFlavor->_pdf->_paperHeight = $cdlFlavor->getPaperHeight();
         $kdlFlavor->_pdf->_paperWidth = $cdlFlavor->getPaperWidth();
         $kdlFlavor->_pdf->_readonly = $cdlFlavor->getReadonly();
     }
     if ($cdlFlavor instanceof ImageFlavorParams || $cdlFlavor instanceof ImageFlavorParamsOutput) {
         $kdlFlavor->_image = new KDLImageData();
         $kdlFlavor->_image->_densityWidth = $cdlFlavor->getDensityWidth();
         $kdlFlavor->_image->_densityHeight = $cdlFlavor->getDensityHeight();
         $kdlFlavor->_image->_sizeWidth = $cdlFlavor->getSizeWidth();
         $kdlFlavor->_image->_sizeHeight = $cdlFlavor->getSizeHeight();
         $kdlFlavor->_image->_depth = $cdlFlavor->getDepth();
         $kdlFlavor->_image->_format = $cdlFlavor->getFormat();
     }
     //KalturaLog::log(__METHOD__."\nKDL Flavor==>\n".print_r($kdlFlavor,true));
     if (is_null($kdlFlavor->_container)) {
         KalturaLog::log("No Container Found On Flavor Convert Will Fail");
         $kdlFlavor->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::InvalidFlavorParamConfiguration);
     }
     return $kdlFlavor;
 }
示例#9
0
 protected function sanityCheck(array &$errors, array &$warnings, $section = null)
 {
     if ($this->_width == 0) {
         $this->_width = 480;
         $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ZeroedFrameDim, $this->_width);
     }
     if ($this->_height == 0) {
         $this->_height = 320;
         $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ZeroedFrameDim, $this->_height);
     }
     if ($this->_width < KDLSanityLimits::MinDimension || $this->_width > KDLSanityLimits::MaxDimension || $this->_height < KDLSanityLimits::MinDimension || $this->_height > KDLSanityLimits::MaxDimension) {
         // "Invalid width (" . $this->_width . "px)";
         $errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::SanityInvalidFrameDim, $this->_width . "x" . $this->_height);
     }
     if ($this->_frameRate < KDLSanityLimits::MinFramerate || $this->_frameRate > KDLSanityLimits::MaxFramerate) {
         $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::SanityInvalidFarmerate, $this->_frameRate);
     }
     if ($this->_dar < KDLSanityLimits::MinDAR || $this->_dar > KDLSanityLimits::MaxDAR) {
         $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::SanityInvalidDAR, $this->_dar);
     }
 }
示例#10
0
 public function ValidateProduct(KDLMediaDataSet $source, KDLFlavor $product)
 {
     KalturaLog::log(".TRG-->" . $this->ToString());
     $rv = $product->ValidateFlavor();
     if ($this->_video !== null) {
         if ($product->_video === null) {
             $product->_errors[KDLConstants::VideoIndex][] = KDLErrors::ToString(KDLErrors::MissingMediaStream);
             $rv = false;
         } else {
             $prdVid = $product->_video;
             $trgVid = $this->_video;
             if ($source) {
                 $srcVid = $source->_video;
             } else {
                 $srcVid = null;
             }
             if ($srcVid) {
                 if ($this->_clipDur && $this->_clipDur > 0) {
                     $plannedDur = $this->_clipDur;
                 } else {
                     $plannedDur = $srcVid->_duration;
                 }
                 if ($prdVid->_duration < $plannedDur * KDLConstants::ProductDurationFactor) {
                     $product->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ProductShortDuration, $prdVid->_duration, $plannedDur);
                 }
             }
             if ($prdVid->_bitRate < $trgVid->_bitRate * KDLConstants::ProductBitrateFactor) {
                 $product->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::ProductLowBitrate, $prdVid->_bitRate, $srcVid->_bitRate);
             }
         }
     }
     if ($this->_audio !== null) {
         if ($product->_audio === null) {
             $product->_errors[KDLConstants::AudioIndex][] = KDLErrors::ToString(KDLErrors::MissingMediaStream);
             $rv = false;
         } else {
             $prdAud = $product->_audio;
             $trgAud = $this->_audio;
             if ($source) {
                 $srcAud = $source->_audio;
             } else {
                 $srcAud = null;
             }
             if ($srcAud && $prdAud->_duration < $srcAud->_duration * KDLConstants::ProductDurationFactor) {
                 $product->_warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::ProductShortDuration, $prdAud->_duration, $srcAud->_duration);
             }
             if ($prdAud->_bitRate < $trgAud->_bitRate * KDLConstants::ProductBitrateFactor) {
                 $product->_warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::ProductLowBitrate, $prdAud->_bitRate, $srcAud->_bitRate);
             }
         }
     }
     if ($product->_video === null && $product->_audio === null) {
         // "Invalid File - No media content.";
         $product->_errors[KDLConstants::ContainerIndex][] = KDLErrors::ToString(KDLErrors::NoValidMediaStream);
     }
     KalturaLog::log(".PRD-->" . $product->ToString());
     return $rv;
 }