public function checkBlackList($blackList, $mediaSet, array &$errors = null, array &$warnings = null) { if (!is_null($blackList)) { foreach ($blackList as $keyPart => $subBlackList) { $sourcePart = null; switch ($keyPart) { case KDLConstants::ContainerIndex: $sourcePart = $mediaSet->_container; break; case KDLConstants::VideoIndex: $sourcePart = $mediaSet->_video; break; case KDLConstants::AudioIndex: $sourcePart = $mediaSet->_audio; break; default: continue; } if ($sourcePart && is_array($subBlackList) && (in_array($sourcePart->_id, $subBlackList) || in_array($sourcePart->_format, $subBlackList))) { $warnings[$keyPart][] = KDLWarnings::ToString(KDLWarnings::TranscoderFormat, $this->_id, $sourcePart->_id . "/" . $sourcePart->_format); return $sourcePart; } } } return null; }
public function Generate(KDLMediaDataSet $mediaSet, KDLProfile $profile, array &$targetList) { if ($mediaSet != null && $mediaSet->IsDataSet()) { $rv = $this->Initialize($mediaSet); if ($rv == false) { /* * fix #9599 - handles rm files that fails to extract media info, but still playable by real player - * simulate video and audio elements, although no source mediainfo is provided */ if ($this->_srcDataSet->_container && $this->_srcDataSet->_container->IsFormatOf(array("realmedia"))) { $rmSrc = $this->_srcDataSet; $rmSrc->_errors = array(); $rmSrc->_video = new KDLVideoData(); $rmSrc->_video->_id = $rmSrc->_video->_format = "realvideo"; $rmSrc->_audio = new KDLAudioData(); $rmSrc->_audio->_id = $rmSrc->_audio->_format = "realaudio"; $rmSrc->_warnings[KDLConstants::ContainerIndex][] = KDLWarnings::ToString(KDLWarnings::RealMediaMissingContent); KalturaLog::log("An invalid source RealMedia file thatfails to provide valid mediaInfodata. Set up a flavor with 'default' params."); } else { return false; } } } if ($profile == null) { return true; } $this->GenerateTargetFlavors($profile, $targetList); if (count($this->_srcDataSet->_errors) > 0) { return false; } return true; }
public function Initialize() { if ($this->_video) { $this->_video->CheckAndFixFormat(); /* * If video.BR is undefined ==> evaluate from file size & duration */ $br = 0; if ($this->_video->_bitRate == "" && $this->_container && $this->_container->_duration > 0) { $br = round($this->_container->_fileSize * 8 * 1024 / $this->_container->_duration); if ($this->_audio->_bitRate !== "") { $br = $br - $this->_audio->_bitRate; } if ($br > 0) { $this->_video->_bitRate = $br; } else { $this->_video->_bitRate = 100; $this->_warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::SetDefaultBitrate, $this->_video->_bitRate); } } } if ($this->_audio) { $this->_audio->CheckAndFixFormat(); } if ($this->_container) { $this->_container->CheckAndFixFormat(); if ($this->_container->_bitRate == "" && $this->_container->_duration > 0) { $this->_container->_bitRate = round($this->_container->_fileSize * 8 * 1024 / $this->_container->_duration); } } if ($this->Validate() != true) { return false; } return true; }
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; }
public function CheckConstraints(KDLMediaDataSet $source, KDLFlavor $target, array &$errors = null, array &$warnings = null) { // if(array_key_exists($this->_id, KDLConstants::$TranscodersSourceBlackList)) { // $this->_sourceBlacklist = KDLConstants::$TranscodersSourceBlackList[$this->_id]; // } // if(array_key_exists($this->_id, KDLConstants::$TranscodersTargetBlackList)) { // $this->_targetBlacklist = KDLConstants::$TranscodersTargetBlackList[$this->_id]; // } if (parent::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; } /* * Remove mencoder, encoding.com and cli_encode * for audio only flavors */ if (($this->_id == KDLTranscoders::MENCODER || $this->_id == KDLTranscoders::ENCODING_COM || $this->_id == KDLTranscoders::ON2) && $target->_video == null) { $warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderLimitation, $this->_id); return true; } /* * Remove encoding.com and ffmpegs * for rotated videos */ if (($this->_id == KDLTranscoders::ENCODING_COM || $this->_id == KDLTranscoders::FFMPEG || $this->_id == KDLTranscoders::FFMPEG_AUX) && $target->_video && $target->_video->_rotation) { $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderLimitation, $this->_id); return true; } /* * Non Mac transcoders should not mess up with QT/WMV/WMA * */ $qt_wmv_list = array("wmv1", "wmv2", "wmv3", "wvc1", "wmva", "wma1", "wma2", "wmapro"); if (($this->_id == KDLTranscoders::FFMPEG || $this->_id == KDLTranscoders::FFMPEG_AUX) && $source->_container && ($source->_container->_id == "qt" || $source->_container->_format == "qt") && ($source->_video && (in_array($source->_video->_format, $qt_wmv_list) || in_array($source->_video->_id, $qt_wmv_list)) || $source->_audio && (in_array($source->_audio->_format, $qt_wmv_list) || in_array($source->_audio->_id, $qt_wmv_list)))) { $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderFormat, $this->_id, "qt/wmv/wma"); return true; } return false; }
public function CheckConstraints(KDLMediaDataSet $source, KDLFlavor $target, array &$errors = null, array &$warnings = null) { if (parent::CheckConstraints($source, $target, $errors, $warnings) == true) { return true; } if ($this->_id == KDLTranscoders::FFMPEG_AUX) { $transcoder = new KDLOperatorFfmpeg($this->_id); if ($transcoder->CheckConstraints($source, $target, $errors, $warnings) == true) { return true; } } if ($this->_id == KDLTranscoders::FFMPEG) { $transcoder = new KDLOperatorFfmpeg0_10($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; } return false; }
private function validateTranscoders(KDLMediaDataSet $source, &$transcoders, $inSet = false) { KalturaLog::log("==>\n"); $cnt = count($transcoders); $i = 0; foreach ($transcoders as $key => $trPrm) { if (is_array($trPrm)) { $cnt = count($trPrm); $this->validateTranscoders($source, $trPrm, true); if ($cnt > count($trPrm)) { unset($transcoders[$key]); $this->_warnings[KDLConstants::ContainerIndex][] = KDLWarnings::ToString(KDLWarnings::RemovingMultilineTranscoding); } } else { if (is_null($transcoders[$key]->_engine)) { $this->_warnings[KDLConstants::ContainerIndex][] = KDLWarnings::ToString(KDLWarnings::MissingTranscoderEngine, $transcoders[$key]->_id); unset($transcoders[$key]); } else { if ($inSet) { KalturaLog::log(": inSet,cnt:{$cnt},i:{$i}"); if ($i > 0) { $transcoders[$key]->_engine->set_sourceBlacklist(null); } if ($i < $cnt - 1) { $transcoders[$key]->_engine->set_targetBlackList(null); } } $rv = $transcoders[$key]->_engine->CheckConstraints($source, $this, $this->_errors, $this->_warnings); if ($rv == true) { unset($transcoders[$key]); } } } $i++; } if (count($transcoders)) { return true; } return false; }
protected function checkBasicFFmpegConstraints(KDLMediaDataSet $source, KDLFlavor $target, array &$errors = null, array &$warnings = null) { /* * Non Mac transcoders should not mess up with QT/WMV/WMA * */ $qt_wmv_list = array("wmv1", "wmv2", "wmv3", "wvc1", "wmva", "wma1", "wma2", "wmapro"); if ($source->_container && ($source->_container->_id == "qt" || $source->_container->_format == "qt") && ($source->_video && (in_array($source->_video->_format, $qt_wmv_list) || in_array($source->_video->_id, $qt_wmv_list)) || $source->_audio && (in_array($source->_audio->_format, $qt_wmv_list) || in_array($source->_audio->_id, $qt_wmv_list)))) { $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderFormat, $this->_id, "qt/wmv/wma"); return true; } return false; }
public function CheckConstraints(KDLMediaDataSet $source, KDLFlavor $target, array &$errors = null, array &$warnings = null) { if (parent::CheckConstraints($source, $target, $errors, $warnings) == true) { return true; } /* * Remove mencoder, encoding.com and cli_encode * for audio only flavors */ if ($target->_video == null) { $warnings[KDLConstants::AudioIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderLimitation, $this->_id); return true; } /* * Remove On2 * for 270 rotated videos */ if ($target->_video && $target->_video->_rotation == 270) { $warnings[KDLConstants::VideoIndex][] = KDLWarnings::ToString(KDLWarnings::TranscoderLimitation, $this->_id); return true; } return false; }
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); } }