コード例 #1
0
 public function GenerateCommandLine(KDLFlavor $predesign, KDLFlavor $target, $extra = null)
 {
     //		$cmdLineGenerator = $target->SetTranscoderCmdLineGenerator($predesign);
     $cmdLineGenerator = new KDLTranscoderCommand($predesign, $target);
     $params = new KDLOperationParams();
     $params->Set($this->_id, $extra);
     if (isset($predesign->_video)) {
         return $cmdLineGenerator->Generate($params, $predesign->_video->_bitRate);
     } else {
         return $cmdLineGenerator->Generate($params, 0);
     }
 }
 public static function GenerateSmoothStreamingPresetFile($flavors)
 {
     $rootFlavor = null;
     $rootStreams = null;
     foreach ($flavors as $flavor) {
         $ee3Id = KDLOperationParams::SearchInArray(KDLTranscoders::EE3, $flavor->_transcoders);
         if (is_null($ee3Id)) {
             continue;
         }
         $transcoderParams = $flavor->_transcoders[$ee3Id];
         KalturaLog::log("transcoder==>\n" . print_r($transcoderParams, true) . "\n<--");
         if (is_null($transcoderParams->_cmd)) {
             KalturaLog::log("ee3 cmd is null");
             continue;
         }
         $ee3 = new SimpleXMLElement($transcoderParams->_cmd);
         if (isset($ee3->MediaFile->OutputFormat->WindowsMediaOutputFormat->VideoProfile)) {
             $videoProfile = $ee3->MediaFile->OutputFormat->WindowsMediaOutputFormat->VideoProfile;
         } else {
             if (isset($ee3->MediaFile->OutputFormat->MP4OutputFormat->VideoProfile)) {
                 $videoProfile = $ee3->MediaFile->OutputFormat->MP4OutputFormat->VideoProfile;
             }
         }
         if (!isset($videoProfile)) {
             continue;
         }
         switch ($flavor->_video->_id) {
             case KDLVideoTarget::WVC1A:
                 $videoCodec = $videoProfile->AdvancedVC1VideoProfile;
                 break;
             case KDLVideoTarget::H264:
             case KDLVideoTarget::H264M:
             case KDLVideoTarget::H264H:
                 $videoCodec = $videoProfile->MainH264VideoProfile;
                 break;
             case KDLVideoTarget::H264B:
                 //					$videoCodec = $videoProfile->BaselineH264VideoProfile;
                 $videoCodec = $videoProfile->MainH264VideoProfile;
                 break;
             default:
                 continue;
         }
         if (!isset($videoCodec) || !isset($videoCodec['SmoothStreaming']) || $videoCodec['SmoothStreaming'] != 'true' && $videoCodec['SmoothStreaming'] != 'True') {
             continue;
         }
         $streams = $videoCodec->Streams;
         if (!(isset($streams) && isset($streams->StreamInfo))) {
             continue;
         }
         $flavorVideoBr = $flavor->_video->_bitRate;
         $br = $streams->StreamInfo->Bitrate;
         if (isset($br->ConstantBitrate)) {
             if ($br->ConstantBitrate['Bitrate'] != $flavorVideoBr) {
                 KalturaLog::log("-->xmlBR=" . $br->ConstantBitrate['Bitrate'] . ", flavorBR=" . $flavorVideoBr);
                 $br->ConstantBitrate['Bitrate'] = $flavorVideoBr;
             }
         } else {
             if (isset($br->VariableConstrainedBitrate)) {
                 if ($br->VariableConstrainedBitrate['AverageBitrate'] != $flavorVideoBr) {
                     KalturaLog::log("-->xmlBR=" . $br->VariableConstrainedBitrate['AverageBitrate'] . ", flavorBR=" . $flavorVideoBr);
                     $br->VariableConstrainedBitrate['AverageBitrate'] = $flavorVideoBr;
                     $br->VariableConstrainedBitrate['PeakBitrate'] = round($flavorVideoBr * 1.3);
                 }
             }
         }
         if ($rootFlavor == null) {
             $rootFlavor = $ee3;
             $rootStreams = $streams;
         } else {
             if ($streams && isset($streams->StreamInfo) && $rootStreams) {
                 KDLUtils::AddXMLElement($rootStreams, $streams->StreamInfo);
             }
         }
         $br = null;
     }
     if ($rootFlavor) {
         $rootFlavor->Job['DefaultMediaOutputFileName'] = KDLCmdlinePlaceholders::OutFileName . ".{DefaultExtension}";
         return $rootFlavor->asXML();
     } else {
         return null;
     }
 }
コード例 #3
0
 static function mergeTranscoderObjArr(array $trPrmArr, $transParse, $extraParse = null, array $transDictionary = null)
 {
     foreach ($transParse as $key => $trId) {
         if ($trId == null) {
             continue;
         }
         if ($extraParse && array_key_exists($key, $extraParse)) {
             $trEx = $extraParse[$key];
         } else {
             $trEx = null;
         }
         if (is_array($trId)) {
             $auxArr = array();
             $trPrmArr[$key] = KDLUtils::mergeTranscoderObjArr($auxArr, $trId, $trEx, $transDictionary);
         } else {
             $trId = KDLUtils::trima($trId);
             if (!is_null($transDictionary) && array_key_exists($trId, $transDictionary)) {
                 $trId = $transDictionary[$trId];
             }
             $trPrm = new KDLOperationParams();
             $trPrm->Set($trId, $trEx);
             $trPrmArr[$key] = $trPrm;
         }
     }
     return $trPrmArr;
 }
コード例 #4
0
 public static function GenerateSmoothStreamingPresetFile($flavors)
 {
     /*
      * Filter in the flavors with EE operator
      */
     $flavorInColl = array();
     foreach ($flavors as $flavor) {
         $eeId = KDLOperationParams::SearchInArray(KDLTranscoders::EE3, $flavor->_transcoders);
         if (is_null($eeId)) {
             continue;
         }
         $transcoderParams = $flavor->_transcoders[$eeId];
         KalturaLog::log("transcoder==>\n" . print_r($transcoderParams, true) . "\n<--");
         if (is_null($transcoderParams->_cmd)) {
             KalturaLog::log("ee3 cmd is null");
             continue;
         }
         /*
          * The key if this array will be combination of bitrate,hight and counter, 
          * in order to solve possible duplication issues and easy the flavor sorting from low to high - 
          * - vBr*100000+height*10+counter
          * The counter meant to solve cases (forced) were two (or more) flavors have both the same vr and height 
          */
         $k = $flavor->_video->_bitRate * 100000 + $flavor->_video->_height * 10;
         while (array_key_exists(strval($k), $flavorInColl)) {
             $k++;
         }
         $flavorInColl[$k] = $flavor;
     }
     /*
      * Sort the flavors that participate in collection 
      */
     $rv = ksort($flavorInColl);
     /*
      * Buidl a combined SmoothSteaming preset XML
      */
     $prevK = null;
     foreach ($flavorInColl as $k => $flavor) {
         /*
          * Check for IsmvMinimalFlavorRatio compliance,
          * fix if required.
          */
         if (isset($prevK)) {
             $ratio = $flavor->_video->_bitRate / $flavorInColl[$prevK]->_video->_bitRate;
             if ($ratio < KDLConstants::IsmvMinimalFlavorRatio) {
                 $flavor->_video->_bitRate = round($flavorInColl[$prevK]->_video->_bitRate * KDLConstants::IsmvMinimalFlavorRatio);
                 $flavor->_video->_peakBitRate = round($flavor->_video->_bitRate * KDLConstants::IsmvPeakBitrateRatio * 1.1);
             }
         }
         $prevK = $k;
     }
     /*
      * Sort the flavors that participate in collection - from high to low, to match EE4 constraints
      */
     $rv = krsort($flavorInColl);
     /*
      * Update the preset XML's and build combined XML
      */
     $rootFlavorXml = null;
     $rootStreamsXml = null;
     foreach ($flavorInColl as $k => $flavor) {
         $eeId = KDLOperationParams::SearchInArray(KDLTranscoders::EE3, $flavor->_transcoders);
         $transcoderParams = $flavor->_transcoders[$eeId];
         $presetXml = new SimpleXMLElement($transcoderParams->_cmd);
         $streamsXml = self::updateToCollectionPreset($flavor, $presetXml);
         if ($rootFlavorXml == null) {
             $rootFlavorXml = $presetXml;
             $rootStreamsXml = $streamsXml;
         } else {
             if ($streamsXml && isset($streamsXml->StreamInfo) && $rootStreamsXml) {
                 KDLUtils::AddXMLElement($rootStreamsXml, $streamsXml->StreamInfo);
             }
         }
     }
     if ($rootFlavorXml) {
         $rootFlavorXml->Job['DefaultMediaOutputFileName'] = KDLCmdlinePlaceholders::OutFileName . ".{DefaultExtension}";
         return $rootFlavorXml->asXML();
     } else {
         return null;
     }
 }
コード例 #5
0
ファイル: KDLProcessor.php プロジェクト: richhl/kalturaCE
 public static function ProceessFlavorsForCollection($flavorList)
 {
     $rootFlavor = null;
     $rootStreams = null;
     foreach ($flavorList as $flavor) {
         $ee3Id = KDLOperationParams::SearchInArray(KDLTranscoders::EE3, $flavor->_transcoders);
         if (!is_null($ee3Id)) {
             //				if(array_key_exists(KDLTranscoders::EE3, $flavor->_transcoders)) {
             $tr = $flavor->_transcoders[$ee3Id];
             //KalturaLog::log(__METHOD__."transcoders==>\n".print_r($trnsStr,true));
             KalturaLog::log(__METHOD__ . "\n" . "transcoder==>\n" . print_r($tr, true) . "\n<--");
             if (is_null($tr->_cmd)) {
                 KalturaLog::log(__METHOD__ . " - ee3 cmd is null");
             }
             //					KalturaLog::log(__METHOD__."-->\n".$flavor->_transcoders[$ee3Id]->_id."\n<--");
             //					KalturaLog::log(__METHOD__."-->\n".$flavor->_transcoders[$ee3Id]->_cmd."\n<--");
             $ee3 = new SimpleXMLElement($flavor->_transcoders[$ee3Id]->_cmd);
             $ee3Streams = null;
             if (!is_null($ee3->MediaFile->OutputFormat->WindowsMediaOutputFormat->VideoProfile)) {
                 $ee3Streams = $ee3->MediaFile->OutputFormat->WindowsMediaOutputFormat->VideoProfile->AdvancedVC1VideoProfile->Streams;
                 if ($ee3Streams->StreamInfo->Bitrate->VariableConstrainedBitrate['AverageBitrate'] != $flavor->_video->_bitRate) {
                     KalturaLog::log(__METHOD__ . "-->xmlBR=" . $ee3Streams->StreamInfo->Bitrate->VariableConstrainedBitrate['AverageBitrate'] . ", flavorBR=" . $flavor->_video->_bitRate);
                     $ee3Streams->StreamInfo->Bitrate->VariableConstrainedBitrate['AverageBitrate'] = $flavor->_video->_bitRate;
                     $ee3Streams->StreamInfo->Bitrate->VariableConstrainedBitrate['PeakBitrate'] = round($flavor->_video->_bitRate * 1.3);
                 }
             }
             if ($rootFlavor == null) {
                 $rootFlavor = $ee3;
                 $rootStreams = $ee3Streams;
             } else {
                 $dest = $rootStreams;
                 if ($ee3Streams) {
                     $src = $ee3Streams->StreamInfo[0];
                     if ($dest && $src) {
                         KDLUtils::AddXMLElement($dest, $src);
                     }
                 }
             }
         }
     }
     if ($rootFlavor) {
         return $rootFlavor->asXML();
     } else {
         return null;
     }
 }
コード例 #6
0
ファイル: KDLProcessor.php プロジェクト: DBezemer/server
 private function setProfileWithIntermediateSource($contId, $vidId, $vidBr, $vidHeight, $audId, $audBr, $audSr, $engVer, $engine)
 {
     $interSrcFlavor = new KDLFlavor();
     $interSrcFlavor->_name = "Automatic Intermediate Source";
     $interSrcFlavor->_id = 0;
     $interSrcFlavor->_container = new KDLContainerData();
     $interSrcFlavor->_container->_id = $contId;
     $vid = new KDLVideoData();
     $vid->_id = $vidId;
     $vid->_bitRate = $vidBr;
     $vid->_height = $vidHeight;
     $interSrcFlavor->_video = $vid;
     $aud = new KDLAudioData();
     $aud->_id = $audId;
     $aud->_bitRate = $audBr;
     $aud->_sampleRate = $audSr;
     $interSrcFlavor->_audio = $aud;
     $interSrcFlavor->_engineVersion = $engVer;
     $opr = new KDLOperationParams();
     $opr->Set($engine);
     if ($interSrcFlavor->_engineVersion == 1) {
         $opr->_engine = KalturaPluginManager::loadObject('KDLOperatorBase', $opr->_id);
     } else {
         $opr->_engine = new KDLOperatorWrapper($opr->_id);
     }
     if ($opr->_engine == null) {
         return null;
     }
     $interSrcFlavor->_transcoders[] = $opr;
     $interSrcProfile = new KDLProfile();
     $interSrcProfile->_flavors[] = $interSrcFlavor;
     return $interSrcProfile;
 }