Skip to content

Commit

Permalink
FOUN-290 - allow ffmpeg non-chunk convert to handle estimatedEffort t…
Browse files Browse the repository at this point in the history
…hreshold
  • Loading branch information
gotlieb committed Dec 8, 2021
1 parent 3013ff5 commit 3fd19d9
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion alpha/apps/kaltura/lib/batch2/kJobsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ public static function addFlavorConvertJob(array $srcSyncKeys, flavorParamsOutpu

$dbConvertFlavorJob->setObjectId($flavorAssetId);
$dbConvertFlavorJob->setObjectType(BatchJobObjectType::ASSET);

$convertData->setEstimatedEffort($convertData->calculateEstimatedEffort($dbConvertFlavorJob));
return kJobsManager::addJob($dbConvertFlavorJob, $convertData, BatchJobType::CONVERT, $dbCurrentConversionEngine);
}

Expand Down
19 changes: 19 additions & 0 deletions alpha/apps/kaltura/lib/batch2/model/kConvertJobData.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class kConvertJobData extends kConvartableJobData
* @var int
*/
private $userCpu;

/**
* @var int
*/
private $estimatedEffort;

/**
* @return the $destFileSyncLocalPath
Expand Down Expand Up @@ -387,4 +392,18 @@ public function getUserCpu() {
public function setUserCpu($userCpu) {
$this->userCpu = $userCpu;
}

/**
* @return the $estimatedEffort
*/
public function getEstimatedEffort() {
return $this->estimatedEffort;
}

/**
* @param int $estimatedEffort
*/
public function setEstimatedEffort($estimatedEffort) {
$this->estimatedEffort = $estimatedEffort;
}
}
12 changes: 9 additions & 3 deletions api_v3/lib/types/batch/KalturaConvertJobData.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class KalturaConvertJobData extends KalturaConvartableJobData
* @var int
*/
public $userCpu;

/**
* @var int
*/
public $estimatedEffort;

private static $map_between_objects = array
(
Expand All @@ -74,7 +79,8 @@ class KalturaConvertJobData extends KalturaConvartableJobData
"extraDestFileSyncs",
"engineMessage",
"destFileSyncSharedPath",
"userCpu"
"userCpu",
"estimatedEffort"
);

public function getMapBetweenObjects ( )
Expand All @@ -87,7 +93,7 @@ public function toObject($dbData = null, $props_to_skip = array())
{
if(is_null($dbData))
$dbData = new kConvertJobData();

return parent::toObject($dbData, $props_to_skip);
}

Expand All @@ -108,4 +114,4 @@ public function fromSubType($subType)
{
return kPluginableEnumsManager::coreToApi('conversionEngineType', $subType);
}
}
}
3 changes: 2 additions & 1 deletion batch/batches/Convert/Engines/KConversionEngine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ protected function getQuickStartCmdLine($add_log)
*
* @param string $cmd_line
* @param boolean $add_log
* @param integer $estimatedeffort
* @return string
*/
protected function getCmdLine ($cmd_line , $add_log )
protected function getCmdLine ($cmd_line , $add_log, $estimatedeffort = null )
{
// I have commented out the audio parameters so we don't decrease the quality - it stays as-is
$binName=$this->getCmd();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,10 @@ private function adjust_cmdline($cmdLine)
*
* @param string $cmd_line
* @param boolean $add_log
* @param integer $estimatedeffort
* @return string
*/
protected function getCmdLine ($cmd_line , $add_log )
protected function getCmdLine ($cmd_line , $add_log, $estimatedeffort = null )
{
// I have commented out the audio parameters so we don't decrease the quality - it stays as-is
$binName=$this->getCmd();
Expand Down
14 changes: 12 additions & 2 deletions batch/batches/Convert/Engines/KConversionEngineFfmpeg.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,13 +584,23 @@ public static function fetchCaptionFile($captionUrl, $captionFilePath)
*
* @param string $cmd_line
* @param boolean $add_log
* @param integer $estimatedEffort
* @return string
*/
protected function getCmdLine ($cmd_line , $add_log )
protected function getCmdLine ($cmd_line , $add_log, $estimatedEffort = null )
{
// I have commented out the audio parameters so we don't decrease the quality - it stays as-is
$binName = $this->getCmd();
$inputFilePath = kFile::buildDirectUrl($this->inFilePath);
if(isset(KBatchBase::$taskConfig->estimatedEffortThreshold) && $estimatedEffort && $estimatedEffort < KBatchBase::$taskConfig->estimatedEffortThreshold)
{
KalturaLog::debug("Setting pre-signed url for convert.");
$inputFilePath = kFile::realPath($this->inFilePath);
}
else
{
$inputFilePath = kFile::buildDirectUrl($this->inFilePath);
}

kBatchUtils::addReconnectParams("http", $inputFilePath,$binName);

$exec_cmd = "$binName " .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getCmd ()
return KBatchBase::$taskConfig->params->ffmpegAuxCmd;
}

protected function getCmdLine ($cmd_line , $add_log )
protected function getCmdLine ($cmd_line , $add_log, $estimatedeffort = null )
{
// I have commented out the audio parameters so we don't decrease the quality - it stays as-is
$binName = $this->getCmd();
Expand Down
3 changes: 1 addition & 2 deletions batch/batches/Convert/Engines/KJobConversionEngine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ protected function getExecutionCommandAndConversionString ( KalturaConvertJobDat
{
$tempPath = dirname($data->destFileSyncLocalPath);
$this->logFilePath = $data->logFileSyncLocalPath;

// assume there always will be this index
$conv_params = $data->flavorParamsOutput;

Expand Down Expand Up @@ -63,7 +62,7 @@ protected function getExecutionCommandAndConversionString ( KalturaConvertJobDat
}
else
{
$exec_cmd = $this->getCmdLine ( $cmd , true );
$exec_cmd = $this->getCmdLine ( $cmd , true, $data->estimatedEffort );
}
$conversion_engine_result = new KConversioEngineResult( $exec_cmd , $cmd );
$conversion_engine_result_list[] = $conversion_engine_result;
Expand Down

0 comments on commit 3fd19d9

Please sign in to comment.