Beispiel #1
0
 public function GenerateCommandLine(KDLFlavor $design, KDLFlavor $target, $extra = null)
 {
     $action = "hint";
     $paramsMap = KDLUtils::parseParamStr2Map($extra);
     if (isset($paramsMap)) {
         if (array_key_exists('action', $paramsMap)) {
             $action = $paramsMap['action'];
         }
     }
     $cmdStr = null;
     switch ($action) {
         case self::ACTION_EMBED_SUBTITLES:
             $cmdStr = $this->generateEmbedSubtitlesCommandLine($design, $target, $paramsMap);
             break;
         case self::ACTION_HINT:
         default:
             $cmdStr = $this->generateHintCommandLine($design, $target, $paramsMap);
             break;
     }
     return $cmdStr;
 }
 public function GenerateCommandLine(KDLFlavor $design, KDLFlavor $target, $extra = null)
 {
     //segmenter 0_3eq4pxgw_0_j5b7ubqa_1.mpeg 2 zzz/segment zzz/playlist.m3u8 ./
     // out_dummyk:/opt/kaltura/tmp/convert/convert_0_6olnx72l_4a32a//out_dummy-1.ts
     /*
      * The segment duration can be evaluated from the 'segmentDuration' field in the operator->extra
      * or set to the gop value if such values are available.
      * Otherwise set to 10.
      */
     $segmentDur = 10;
     $paramsMap = KDLUtils::parseParamStr2Map($extra);
     if (isset($paramsMap) && array_key_exists('segmentDuration', $paramsMap)) {
         $auxDur = $paramsMap['segmentDuration'];
         if ($auxDur > 0) {
             $segmentDur = $auxDur;
         }
     }
     /*		else
     		if(isset($target->_video) 
     		&&(isset($target->_video->_gop) && $target->_video->_gop>0)
     		&&(isset($target->_video->_frameRate) && $target->_video->_frameRate>0)){
     			$auxDur = round($target->_video->_gop/$target->_video->_frameRate);
     			if($auxDur>0)
     				$segmentDur=$auxDur;
     		}
     */
     $cmdStr = " " . KDLCmdlinePlaceholders::InFileName;
     $cmdStr .= " {$segmentDur}";
     //		$cmdStr .= " ".KDLCmdlinePlaceholders::OutFileName."/segment"; // output MPEG-TS file prefix
     //		$cmdStr .= " ".KDLCmdlinePlaceholders::OutFileName."/playlist.m3u8"; // output m3u8 index file
     //		$cmdStr .= "zzzz"; // http prefix
     $cmdStr .= " " . KDLCmdlinePlaceholders::OutFileName . "//segment";
     // output MPEG-TS file prefix
     $cmdStr .= " " . KDLCmdlinePlaceholders::OutFileName . "//playlist.m3u8";
     // output m3u8 index file
     $cmdStr .= " ---";
     // http prefix
     return $cmdStr;
 }
 public static function simulateFlavor($fmt, $vcodec, $w = 0, $h, $br, $acodec = "", $ab = 96, $ar = 22050, $clipStart = 0, $clipDur = 0, $engines = "2,3,99,(6#2#7)")
 {
     $fl = new KDLFlavor();
     $fl->_audio = new KDLAudioData();
     $fl->_video = new KDLVideoData();
     $fl->_container = new KDLContainerData();
     $fl->_clipDur = $clipDur;
     $fl->_clipStart = $clipStart;
     //		$fl = $source;
     $fl->_container->_id = $fmt;
     $fl->_video->_id = $vcodec;
     $fl->_video->_bitRate = $br;
     $fl->_video->_width = $w;
     $fl->_video->_height = $h;
     $fl->_video->_gop = 0;
     //		$fl->_video->_frameRate = 0;
     //		$fl->_flags = KDLFlavor::ForceCommandLineFlagBit;
     $fl->_audio->_id = $acodec;
     //		$fl->_audio->_channels = 2;
     $fl->_audio->_sampleRate = $ar;
     $fl->_audio->_bitRate = $ab;
     //		$fl->_audio->_resolution=16;
     ///		$fl->_transcoders[] = new KDLOperationParams("cli_encode");
     $fl->_transcoders = KDLUtils::parseTranscoderList($engines, "", KDLWrap::$TranscodersCdl2Kdl);
     /*
     		$fl->_transcoders[] = new KDLOperationParams("encoding.com");
     		$fl->_transcoders[] = new KDLOperationParams("ffmpeg");
     		$fl->_transcoders[] = new KDLOperationParams("ffmpeg-aux");
     		$fl->_transcoders[] = new KDLOperationParams("mencoder");
     		//$fl->_transcoders["encoding.com"] = true; 
     		//$fl->_transcoders["cli_encode"] = true; 
     */
     KDLUtils::RecursiveScan($fl->_transcoders, "transcoderSetFuncTest", null, null);
     //KalturaLog::log(__METHOD__."==>\n".print_r($fl->_transcoders,true));
     return $fl;
 }
 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;
     }
 }
 public function ToString()
 {
     $rvStr = "flag({$this->_flags})";
     if ($this->_clipStart) {
         $rvStr .= ",clpStr({$this->_clipStart})";
     }
     if ($this->_clipDur) {
         $rvStr .= ",clpDur({$this->_clipDur})";
     }
     $rvStr .= "," . parent::ToString();
     if (count($this->_errors)) {
         $rvStr = $rvStr . ",ERRS(" . KDLUtils::arrayToString($this->_errors) . ")";
     }
     if (count($this->_warnings)) {
         $rvStr = $rvStr . ",WRNS(" . KDLUtils::arrayToString($this->_warnings) . ")";
     }
     if (count($this->_transcoders)) {
         $rvStr = $rvStr . ",TRNS(" . KDLUtils::arrayToString($this->_transcoders) . ")";
     }
     return $rvStr;
 }
Beispiel #6
0
 public static function RecursiveScan(array $transObjArr, $func, $param1, $param2)
 {
     foreach ($transObjArr as $key => $trPrm) {
         if (is_array($trPrm)) {
             KDLUtils::RecursiveScan($trPrm, $func, $param1, $param2);
         } else {
             $func($trPrm, $param1, $param2);
         }
     }
 }
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     KalturaLog::debug("operator==>" . print_r($operator, 1));
     $encodingTemplateId = null;
     $encodingTemplateName = null;
     $cloneAndUpadate = false;
     $srcPrefixWindows = null;
     $srcPrefixLinux = null;
     $trgPrefixWindows = null;
     // ---------------------------------
     // Evaluate and set various Inlet Armada session params
     if (KBatchBase::$taskConfig->params->InletStorageRootWindows) {
         $srcPrefixWindows = KBatchBase::$taskConfig->params->InletStorageRootWindows;
     }
     if (KBatchBase::$taskConfig->params->InletStorageRootLinux) {
         $srcPrefixLinux = KBatchBase::$taskConfig->params->InletStorageRootLinux;
     }
     if (KBatchBase::$taskConfig->params->InletTmpStorageWindows) {
         $trgPrefixWindows = KBatchBase::$taskConfig->params->InletTmpStorageWindows;
     }
     $url = KBatchBase::$taskConfig->params->InletArmadaUrl;
     $login = KBatchBase::$taskConfig->params->InletArmadaLogin;
     $passw = KBatchBase::$taskConfig->params->InletArmadaPassword;
     if (KBatchBase::$taskConfig->params->InletArmadaPriority) {
         $priority = KBatchBase::$taskConfig->params->InletArmadaPriority;
     } else {
         $priority = 5;
     }
     // ----------------------------------
     $inlet = new InletAPIWrap($url);
     KalturaLog::debug(print_r($inlet, 1));
     $rvObj = new XmlRpcData();
     $rv = $inlet->userLogon($login, $passw, $rvObj);
     if (!$rv) {
         throw new KOperationEngineException("Inlet failure: login, rv(" . print_r($rvObj, true) . ")");
     }
     KalturaLog::debug("userLogon - " . print_r($rvObj, 1));
     $paramsMap = KDLUtils::parseParamStr2Map($operator->extra);
     foreach ($paramsMap as $key => $param) {
         switch ($key) {
             case 'encodingTemplate':
             case 'encodingTemplateId':
                 $encodingTemplateId = $param;
                 break;
             case 'encodingTemplateName':
                 $encodingTemplateId = $this->lookForJobTemplateId($inlet, $param);
                 $encodingTemplateName = $param;
                 break;
             case 'priority':
                 $priority = $param;
                 break;
             case 'cloneAndUpadate':
                 $cloneAndUpadate = $param;
                 break;
             default:
                 break;
         }
     }
     // Adjust linux file path to Inlet Armada Windows path
     if (isset($srcPrefixWindows) && isset($srcPrefixLinux)) {
         $srcPrefixLinux = $this->addLastSlashInFolderPath($srcPrefixLinux, "/");
         $srcPrefixWindows = $this->addLastSlashInFolderPath($srcPrefixWindows, "\\");
         $srcFileWindows = str_replace($srcPrefixLinux, $srcPrefixWindows, $inFilePath);
     } else {
         $srcFileWindows = $inFilePath;
     }
     if (isset($trgPrefixWindows)) {
         $trgPrefixLinux = $this->addLastSlashInFolderPath(KBatchBase::$taskConfig->params->localTempPath, "/");
         $trgPrefixWindows = $this->addLastSlashInFolderPath($trgPrefixWindows, "\\");
         $outFileWindows = str_replace($trgPrefixLinux, $trgPrefixWindows, $this->outFilePath);
     } else {
         $outFileWindows = $this->outFilePath;
     }
     $rv = $inlet->jobAdd($encodingTemplateId, $srcFileWindows, $outFileWindows, $priority, $srcFileWindows, array(), "", $rvObj);
     if (!$rv) {
         throw new KOperationEngineException("Inlet failure: add job, rv(" . print_r($rvObj, 1) . ")");
     }
     KalturaLog::debug("jobAdd - encodingTemplate({$encodingTemplateId}), inFile({$srcFileWindows}), outFile({$outFileWindows}),rv-" . print_r($rvObj, 1));
     $jobId = $rvObj->job_id;
     $attemptCnt = 0;
     while ($jobId) {
         sleep(60);
         $rv = $inlet->jobList(array($jobId), $rvObj);
         if (!$rv) {
             throw new KOperationEngineException("Inlet failure: job list, rv(" . print_r($rvObj, 1) . ")");
         }
         switch ($rvObj->job_list[0]->job_state) {
             case InletArmadaJobStatus::CompletedSuccess:
                 $jobId = null;
                 break;
             case InletArmadaJobStatus::CompletedUnknown:
             case InletArmadaJobStatus::CompletedFailure:
                 throw new KOperationEngineException("Inlet failure: job, rv(" . print_r($rvObj, 1) . ")");
                 break;
         }
         if ($attemptCnt % 10 == 0) {
             KalturaLog::debug("waiting for job completion - " . print_r($rvObj, 1));
         }
         $attemptCnt++;
     }
     //KalturaLog::debug("XXX taskConfig=>".print_r(KBatchBase::$taskConfig,1));
     KalturaLog::debug("Job completed successfully - " . print_r($rvObj, 1));
     if ($trgPrefixWindows) {
         $trgPrefixLinux = $this->addLastSlashInFolderPath(KBatchBase::$taskConfig->params->sharedTempPath, "/");
         $outFileLinux = str_replace($trgPrefixWindows, $trgPrefixLinux, $rvObj->job_list[0]->job_output_file);
         //KalturaLog::debug("XXX str_replace($trgPrefixWindows, ".$trgPrefixLinux.", ".$rvObj->job_list[0]->job_output_file.")==>$outFileLinux");
     } else {
         $outFileLinux = $rvObj->job_list[0]->job_output_file;
     }
     if ($outFileLinux != $this->outFilePath) {
         KalturaLog::debug("copy({$outFileLinux}, " . $this->outFilePath . ")");
         kFile::moveFile($outFileLinux, $this->outFilePath, true);
         //copy($outFileLinux, $this->outFilePath);
     }
     return true;
 }
 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 || $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();
     }
     //		$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();
     }
     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));
     return $kdlFlavor;
 }
Beispiel #9
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;
 }
 public function UpdateTarget(KDLFlavor $target)
 {
     /*
      * Following code block is a 'dirty' short cut to overload the qt_tools 
      * target params to H264/AAC.
      * Other engines will not be effected.
      * The correct solution is to add additional param fields to engin's JSOn record 
      */
     $paramsMap = KDLUtils::parseParamStr2Map($this->_params);
     if (!isset($paramsMap)) {
         return;
     }
     foreach ($paramsMap as $key => $param) {
         if ($target->_video) {
             $mdObj = $target->_video;
             switch ($key) {
                 case 'video_codec':
                     $mdObj->_id = $param;
                     break;
                 case 'video_bitrate':
                     $mdObj->_bitRate = $param;
                     break;
                 case 'gop':
                     $mdObj->_gop = $param;
                     break;
                 case 'frame_rate':
                     $mdObj->_frameRate = $param;
                     break;
                 case 'width':
                     $mdObj->_width = $param;
                     break;
                 case 'height':
                     $mdObj->_height = $param;
                     break;
                 default:
                     break;
             }
         }
         if ($target->_audio) {
             $mdObj = $target->_audio;
             switch ($key) {
                 case 'audio_codec':
                     $mdObj->_id = $param;
                     break;
                 case 'audio_bitrate':
                     $mdObj->_bitRate = $param;
                     break;
                 case 'sample_rate':
                     $mdObj->_sampleRate = $param;
                     break;
                 case 'channels':
                     $mdObj->_channels = $param;
                     break;
                 default:
                     break;
             }
         }
         if ($target->_container) {
             $mdObj = $target->_container;
             switch ($key) {
                 case 'container_format':
                     $mdObj->_id = $param;
                     break;
                 default:
                     break;
             }
         }
     }
 }
 public function GenerateConfigData(KDLFlavor $design, KDLFlavor $target, $extra = null)
 {
     /*		
     $tryXML = "<StreamInfo
                     Size=\"512, 384\">
                     <Bitrate>
                       <ConstantBitrate
                         Bitrate=\"1045\"
                         IsTwoPass=\"False\"
                         BufferWindow=\"00:00:05\" />
                     </Bitrate>
                   </StreamInfo>
     ";
     		$xml = new SimpleXMLElement($tryXML);
     */
     if ($target->_container) {
         $cont = $target->_container;
         $dir = dirname(__FILE__);
         //$dir = '.';
         switch ($cont->_id) {
             case KDLContainerTarget::ISMV:
                 $xmlTemplate = $dir . '/ismPresetTemplate.xml';
                 break;
             case KDLContainerTarget::MP4:
             case KDLContainerTarget::WMV:
             case KDLContainerTarget::WMA:
             default:
                 $xmlTemplate = $dir . '/wmvPresetTemplate.xml';
                 break;
         }
         $xml = simplexml_load_file(realpath($xmlTemplate));
         switch ($cont->_id) {
             case KDLContainerTarget::MP4:
                 $xObj = simplexml_load_string($xml->MediaFile->OutputFormat->WindowsMediaOutputFormat->asXML());
                 $xml->MediaFile->OutputFormat->addChild("MP4OutputFormat");
                 KDLUtils::AddXMLElement($xml->MediaFile->OutputFormat->MP4OutputFormat, $xObj->AudioProfile);
                 KDLUtils::AddXMLElement($xml->MediaFile->OutputFormat->MP4OutputFormat, $xObj->VideoProfile);
                 unset($xml->MediaFile->OutputFormat->WindowsMediaOutputFormat);
                 $fileFormat = $xml->MediaFile->OutputFormat->MP4OutputFormat;
                 break;
             case KDLContainerTarget::ISMV:
             case KDLContainerTarget::WMV:
             case KDLContainerTarget::WMA:
             default:
                 $fileFormat = $xml->MediaFile->OutputFormat->WindowsMediaOutputFormat;
                 break;
         }
     }
     $xml->Job['OutputDirectory'] = KDLCmdlinePlaceholders::OutDir;
     if ($target->_video) {
         $vid = $target->_video;
         $vidProfile = null;
         switch ($vid->_id) {
             case KDLVideoTarget::WMV2:
             case KDLVideoTarget::WMV3:
             case KDLVideoTarget::WVC1A:
             default:
                 $vidProfile = $fileFormat->VideoProfile->AdvancedVC1VideoProfile;
                 unset($fileFormat->VideoProfile->MainH264VideoProfile);
                 break;
             case KDLVideoTarget::H264:
             case KDLVideoTarget::H264B:
             case KDLVideoTarget::H264M:
             case KDLVideoTarget::H264H:
                 $vidProfile = $fileFormat->VideoProfile->MainH264VideoProfile;
                 unset($fileFormat->VideoProfile->AdvancedVC1VideoProfile);
                 break;
         }
         $vFr = 30;
         if ($vid->_frameRate !== null && $vid->_frameRate > 0) {
             $vFr = $vid->_frameRate;
             $vidProfile['FrameRate'] = $vFr;
         }
         if ($vid->_gop !== null && $vid->_gop > 0) {
             $kFr = round($vid->_gop / $vFr);
             $mi = round($kFr / 60);
             $se = $kFr % 60;
             $vidProfile['KeyFrameDistance'] = sprintf("00:%02d:%02d", $mi, $se);
         }
         if ($vid->_bitRate) {
             if ($target->_isTwoPass && !($vid->_id == KDLVideoTarget::H264 || $vid->_id == KDLVideoTarget::H264B || $vid->_id == KDLVideoTarget::H264M || $vid->_id == KDLVideoTarget::H264H)) {
                 unset($vidProfile->Streams->StreamInfo->Bitrate->VariableConstrainedBitrate);
                 $vidProfile->Streams->StreamInfo->Bitrate->ConstantBitrate['Bitrate'] = $vid->_bitRate;
             } else {
                 unset($vidProfile->Streams->StreamInfo->Bitrate->ConstantBitrate);
                 $vid->_bitRate = max(100, $vid->_bitRate);
                 // The minimum video br for the SL is 100
                 $vidProfile->Streams->StreamInfo->Bitrate->VariableConstrainedBitrate['PeakBitrate'] = round($vid->_bitRate * 1.3);
                 $vidProfile->Streams->StreamInfo->Bitrate->VariableConstrainedBitrate['AverageBitrate'] = $vid->_bitRate;
             }
         }
         if ($vid->_width != null && $vid->_height != null) {
             $vidProfile->Streams->StreamInfo['Size'] = $vid->_width . ", " . $vid->_height;
         }
         //			$strmInfo = clone ($vidProfile->Streams->StreamInfo[0]);
         //			KDLUtils::AddXMLElement($vidProfile->Streams, $vidProfile->Streams->StreamInfo[0]);
     } else {
         unset($fileFormat->VideoProfile);
     }
     if ($target->_audio) {
         $aud = $target->_audio;
         $audProfile = null;
         switch ($aud->_id) {
             case KDLAudioTarget::WMA:
             default:
                 $audProfile = $fileFormat->AudioProfile->WmaAudioProfile;
                 unset($fileFormat->AudioProfile->AacAudioProfile);
                 break;
             case KDLAudioTarget::AAC:
                 $audProfile = $fileFormat->AudioProfile->AacAudioProfile;
                 unset($fileFormat->AudioProfile->WmaAudioProfile);
                 break;
         }
         /*
         	Since there are certain constraints on those values for the EE3 presets, 
         	those values are set in the templates only
         	
         			if($this->_audBr!==null && $this->_audBr>0){
         				$audProfile->Bitrate->ConstantBitrate['Bitrate'] = $this->_audBr;
         			}
         			if($this->_audSr!==null && $this->_audSr>0){
         				$audProfile['SamplesPerSecond'] = $this->_audSr;
         			}
         			if($this->_audCh!==null && $this->_audCh>0){
         				$audProfile['Channels'] = $this->_audCh;
         			}
         */
     } else {
         unset($fileFormat->AudioProfile->WmaAudioProfile);
         unset($fileFormat->AudioProfile->AacAudioProfile);
         unset($fileFormat->AudioProfile);
     }
     //$stream = clone $streams->StreamInfo;
     //		$streams[1] = $stream;
     //		print_r($xml);
     return $xml->asXML();
 }
 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;
     }
 }
Beispiel #13
0
 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;
     }
 }
Beispiel #14
0
 private function loadBaseSet(&$baseData, $key, $val)
 {
     switch ($key) {
         case "codec id":
             $baseData->_id = $val;
             break;
         case "format":
             $baseData->_format = $val;
             break;
         case "duration":
             $baseData->_duration = KDLUtils::convertDuration2msec($val);
             break;
         case "bit rate":
             $baseData->_bitRate = KDLUtils::convertValue2kbits(KDLUtils::trima($val));
             break;
         default:
             //echo "<br>". "key=". $key . " val=" . $val . "<br>";
             $baseData->_params[$key] = $val;
             break;
     }
 }
function testOperatorJSON()
{
    if (1) {
        require_once '../kOperator.php';
        require_once '../kOperatorSets.php';
        //	$transObjArr=KDLUtils::parseTranscoderList("(1),(2#99#5),98,4,1","(--FE_SOMETING 0)|(-b 30#-a 23 -c ee# vcodec;c:7)|--FE_AAA 1234||101");
        //print_r($transObjArr);
        //print_r($transObjArr);
        $json2 = '[[{"id":2}]]';
        $json3 = '[[{\\"id\\":2,\\"extra\\":null,\\"command\\":\\"-i __inFileName__ -vcodec flv -b 251k -s 320x240 -r 14.96 -g 60 -acodec libmp3lame -ab 64k -ar 44100 -ac 2 -f flv -y __outFileName__\\"},{\\"id\\":98,\\"extra\\":null,\\"command\\":\\"-i __inFileName__ -vcodec flv -b 251k -s 320x240 -r 14.96 -g 60 -acodec libmp3lame -ab 64k -ar 44100 -ac 2 -f flv -y __outFileName__\\"}]]';
        $json4 = '[[{"id":2,"extra":null,"command":"-i __inFileName__ -vcodec flv -b 251k -s 320x240 -r 14.96 -g 60 -acodec libmp3lame -ab 64k -ar 44100 -ac 2 -f flv -y __outFileName__"},{"id":98,"extra":null,"command":"-i __inFileName__ -vcodec flv -b 251k -s 320x240 -r 14.96 -g 60 -acodec libmp3lame -ab 64k -ar 44100 -ac 2 -f flv -y __outFileName__"}]]';
        $json = '
[
	[
		{
			"id":6,
			"extra":"A extra params 1 ",
			"command":"A command line data 1",
			"azaz":12345
		}
	],
	[
		{
			"id":1,
			"extra":"A extra params 1 ",
			"command":"A command line data 1"
		},
		{
			"id":2,
			"extra":"A extra params 2",
			"command":"A command line data 2"
		}
	],
	[
		{
			"id":1,
			"extra":"B extra params 1 ",
			"command":"B command line data 1"
		},
		{
			"id":2,
			"extra":"B extra params 2",
			"command":"B command line data 2"
		}
	]
]';
        $oprSets = new kOperatorSets();
        $oprSets->setSerialized(stripslashes($json));
        print_r($oprSets);
        echo "<br>\n\n";
        echo "333333333333333333";
        return;
        $transObjArr = KDLWrap::convertOperatorsCdl2Kdl($json);
        KDLUtils::RecursiveScan($transObjArr, "transcoderSetFuncTest", KDLConstants::$TranscodersCdl2Kdl, "");
        echo "<br>\n\n";
        print_r($transObjArr);
        $cdlOprSets = new kOperatorSets();
        //		$cdlOprSets = KDLWrap::convertOperatorsKdl2Cdl($transObjArr);
        //		print_r($cdlOprSets);
        //return;
        foreach ($transObjArr as $transObj) {
            $auxArr = array();
            if (is_array($transObj)) {
                foreach ($transObj as $tr) {
                    $opr = new kOperator();
                    $key = array_search($tr->_id, KDLWrap::$TranscodersCdl2Kdl);
                    if ($key === false) {
                        $opr->id = $tr->_id;
                    } else {
                        $opr->id = $key;
                    }
                    $opr->extra = $tr->_extra;
                    $opr->command = $tr->_cmd;
                    $auxArr[] = $opr;
                }
            } else {
                $opr = new kOperator();
                $key = array_search($transObj->_id, KDLWrap::$TranscodersCdl2Kdl);
                if ($key === false) {
                    $opr->id = $transObj->_id;
                } else {
                    $opr->id = $key;
                }
                $opr->extra = $transObj->_extra;
                $opr->command = $transObj->_cmd;
                $auxArr[] = $opr;
            }
            $cdlOprSets->addSet($auxArr);
        }
        print_r($cdlOprSets);
        return;
    }
}