public function GenerateCommandLine(KDLFlavor $predesign, KDLFlavor $target, $extra = null)
 {
     $cmdLineGenerator = $target->SetTranscoderCmdLineGenerator();
     if ($target->_video) {
         $cmdLineGenerator->_vidBr = $target->_video->_bitRate;
     }
     $params = new KDLOperationParams($this->_id, $extra);
     return $cmdLineGenerator->Generate($params, $predesign->_video->_bitRate);
 }
 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;
 }
Beispiel #3
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 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;
 }
Beispiel #5
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;
 }