From 3cab003a821b9d16a98ee98dc368c98716f3dcd3 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Wed, 6 Nov 2024 16:36:17 +0200 Subject: [PATCH 1/5] PLAT-24830: Support captions clipping when serving WebVTT --- alpha/apps/kaltura/lib/kContextDataHelper.php | 42 ++++++ alpha/apps/kaltura/lib/myEntryUtils.class.php | 2 +- .../entry/KalturaPlaybackContextOptions.php | 8 + api_v3/services/BaseEntryService.php | 2 + .../content/caption/base/CaptionPlugin.php | 17 ++- .../caption/base/lib/kWebVTTGenerator.php | 137 ++++++++++++------ .../base/services/CaptionAssetService.php | 12 +- 7 files changed, 168 insertions(+), 52 deletions(-) diff --git a/alpha/apps/kaltura/lib/kContextDataHelper.php b/alpha/apps/kaltura/lib/kContextDataHelper.php index b2605814d93..b869f15c4a3 100644 --- a/alpha/apps/kaltura/lib/kContextDataHelper.php +++ b/alpha/apps/kaltura/lib/kContextDataHelper.php @@ -74,6 +74,16 @@ class kContextDataHelper private $streamerType = null; private $mediaProtocol = null; + + /** + * @var int + */ + private $clipFrom; + + /** + * @var int + */ + private $clipTo; /** * @@ -152,6 +162,38 @@ public function setMediaProtocol($protocol) { $this->mediaProtocol = $protocol; } + /** + * @return int + */ + public function getClipFrom() + { + return $this->clipFrom; + } + + /** + * @param $clipFrom + */ + public function setClipFrom($clipFrom) + { + $this->clipFrom = $clipFrom; + } + + /** + * @return int + */ + public function getClipTo() + { + return $this->clipTo; + } + + /** + * @param $clipTo + */ + public function setClipTo($clipTo) + { + $this->clipTo = $clipTo; + } + public function buildContextDataResult($scope, $flavorTags, $streamerType, $mediaProtocol, $shouldHandleRuleCodes = false) { $this->streamerType = $streamerType; diff --git a/alpha/apps/kaltura/lib/myEntryUtils.class.php b/alpha/apps/kaltura/lib/myEntryUtils.class.php index 7435a262f1a..98c7bb7f39e 100644 --- a/alpha/apps/kaltura/lib/myEntryUtils.class.php +++ b/alpha/apps/kaltura/lib/myEntryUtils.class.php @@ -2015,7 +2015,7 @@ public static function isEntryReady($entryId) /* * Builds a manifest request for entry according to relevant flavors, delivery profile type and location of deliveryProfile(local/remote) */ - public static function buildManifestUrl($entry, $protocols, $format, $flavors, $profileId = "") + public static function buildManifestUrl($entry, $protocols, $format, $flavors, $profileId = "", $clipFrom = null, $clipTo = null) { $entryId = $entry->getId(); $partnerId = $entry->getPartnerId(); diff --git a/api_v3/lib/types/entry/KalturaPlaybackContextOptions.php b/api_v3/lib/types/entry/KalturaPlaybackContextOptions.php index 8ac10c25aa0..3eeb845c78c 100644 --- a/api_v3/lib/types/entry/KalturaPlaybackContextOptions.php +++ b/api_v3/lib/types/entry/KalturaPlaybackContextOptions.php @@ -6,5 +6,13 @@ */ class KalturaPlaybackContextOptions extends KalturaEntryContextDataParams { + /** + * @var int + */ + public $clipFrom; + /** + * @var int + */ + public $clipTo; } \ No newline at end of file diff --git a/api_v3/services/BaseEntryService.php b/api_v3/services/BaseEntryService.php index b9086d30c0d..b738ae9b2b6 100644 --- a/api_v3/services/BaseEntryService.php +++ b/api_v3/services/BaseEntryService.php @@ -1048,6 +1048,8 @@ function getPlaybackContextAction($entryId, KalturaPlaybackContextOptions $conte $contextDataHelper->setMediaProtocol($contextDataParams->mediaProtocol); $contextDataHelper->setStreamerType($contextDataParams->streamerType); + $contextDataHelper->setClipFrom($contextDataParams->clipFrom); + $contextDataHelper->setClipTo($contextDataParams->clipTo); $playbackContextDataHelper = new kPlaybackContextDataHelper(); $playbackContextDataHelper->setIsScheduledNow($isScheduledNow); diff --git a/plugins/content/caption/base/CaptionPlugin.php b/plugins/content/caption/base/CaptionPlugin.php index d55a99813a9..e07aca86e2a 100644 --- a/plugins/content/caption/base/CaptionPlugin.php +++ b/plugins/content/caption/base/CaptionPlugin.php @@ -665,16 +665,23 @@ public function contributeToPlaybackContextDataResult(entry $entry, kPlaybackCon continue; } - $url = null; - $webVttUrl = null; - try { - $url = $assetDb->getDownloadUrl(true, false, null, null, false); if ($url) { - $webVttUrl = myPartnerUtils::getCdnHost($assetDb->getPartnerId()) . self::SERVE_WEBVTT_URL_PREFIX . '/captionAssetId/' . $assetDb->getId() . '/segmentIndex/-1/version/' . $assetDb->getVersion() . '/captions.vtt'; + $clipFrom = $contextDataHelper->getClipFrom(); + $clipTo = $contextDataHelper->getClipTo(); + $webVttUrl = myPartnerUtils::getCdnHost($assetDb->getPartnerId()) . self::SERVE_WEBVTT_URL_PREFIX . '/captionAssetId/' . $assetDb->getId() . '/segmentIndex/-1/version/' . $assetDb->getVersion(); + if ($clipFrom) + { + $webVttUrl .= "/clipFrom/$clipFrom"; + } + if ($clipTo) + { + $webVttUrl .= "/clipTo/$clipTo"; + } + $webVttUrl .= '/captions.vtt'; $languageCode = languageCodeManager::getLanguageCode($assetDb->getLanguage(),$useThreeCodeLang); $playbackCaptions [] = new kCaptionPlaybackPluginData($assetDb->getLabel(), $assetDb->getContainerFormat(), $assetDb->getLanguage(), $assetDb->getDefault(), $webVttUrl, $url, $languageCode); } diff --git a/plugins/content/caption/base/lib/kWebVTTGenerator.php b/plugins/content/caption/base/lib/kWebVTTGenerator.php index d84d1b89129..ed8c85a1679 100644 --- a/plugins/content/caption/base/lib/kWebVTTGenerator.php +++ b/plugins/content/caption/base/lib/kWebVTTGenerator.php @@ -30,15 +30,25 @@ public static function formatWebVTTTimeStamp($timeStamp) * @param int $entryDuration * @return string */ - public static function buildWebVTTM3U8File($segmentDuration, $entryDuration) + public static function buildWebVTTM3U8File($segmentDuration, $entryDuration, $clipFrom, $clipTo) { - $result = "#EXTM3U\r\n"; - $result .= "#EXT-X-TARGETDURATION:{$segmentDuration}\r\n"; - $result .= "#EXT-X-VERSION:3\r\n"; - $result .= "#EXT-X-MEDIA-SEQUENCE:1\r\n"; - $result .= "#EXT-X-PLAYLIST-TYPE:VOD\r\n"; - $segmentCount = ceil($entryDuration / $segmentDuration); - $lastSegmentDuration = $entryDuration - ($segmentCount - 1) * $segmentDuration; + $result = self::getManifestHeaderForWebVTT($segmentDuration); + + $entryDurationMs = $entryDuration * 1000; + $linkParamsToConcat = ''; + if ($clipTo && $entryDurationMs > $clipTo) + { + $entryDurationMs = $clipTo; + $linkParamsToConcat .= "clipTo/$clipTo/"; + } + if ($clipFrom) + { + $entryDurationMs -= $clipFrom; + $linkParamsToConcat .= "clipFrom/$clipFrom/"; + } + + $segmentCount = ceil(($entryDurationMs / 1000) / $segmentDuration); + $lastSegmentDuration = ceil($entryDurationMs / 1000) - ($segmentCount - 1) * $segmentDuration; for ($curIndex = 1; $curIndex <= $segmentCount; $curIndex++) { if ($curIndex == $segmentCount) @@ -49,12 +59,24 @@ public static function buildWebVTTM3U8File($segmentDuration, $entryDuration) { $result .= "#EXTINF:{$segmentDuration}.0,\r\n"; } + + $result .= $linkParamsToConcat; $result .= "segmentIndex/{$curIndex}.vtt\r\n"; } $result .= "#EXT-X-ENDLIST\r\n"; return $result; } + protected static function getManifestHeaderForWebVTT($segmentDuration) + { + $result = "#EXTM3U\r\n"; + $result .= "#EXT-X-TARGETDURATION:{$segmentDuration}\r\n"; + $result .= "#EXT-X-VERSION:3\r\n"; + $result .= "#EXT-X-MEDIA-SEQUENCE:1\r\n"; + $result .= "#EXT-X-PLAYLIST-TYPE:VOD\r\n"; + return $result; + } + /** * @param array $parsedCaption * @param int $segmentIndex @@ -62,27 +84,24 @@ public static function buildWebVTTM3U8File($segmentDuration, $entryDuration) * @param int $localTimestamp * @return string */ - public static function buildWebVTTSegment(array $parsedCaption, $segmentIndex, $segmentDuration, $localTimestamp) + public static function buildWebVTTSegment(array $parsedCaption, $segmentIndex, $segmentDuration, $localTimestamp, $clipFrom, $clipTo) { - $segmentStartTime = ($segmentIndex - 1) * $segmentDuration * 1000; - $segmentEndTime = $segmentIndex * $segmentDuration * 1000; + $result = self::getSegmentHeaderForWebVTT($localTimestamp); - $result = "WEBVTT\n"; - if ($localTimestamp != 10000) - { - $result .= "X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:" . self::formatWebVTTTimeStamp($localTimestamp) . "\n"; - } - $result .= "\n"; + [$segmentStartTime, $segmentEndTime] = self::calculateSegmentTime($segmentIndex, $segmentDuration, $clipFrom, $clipTo); foreach ($parsedCaption as $curCaption) { - if ($segmentIndex != -1 && ($curCaption["startTime"] < $segmentStartTime || $curCaption["startTime"] >= $segmentEndTime) && - ($curCaption["endTime"] < $segmentStartTime || $curCaption["endTime"] >= $segmentEndTime) + if ($segmentStartTime > -1 && $segmentEndTime > -1 + && ($curCaption["startTime"] < $segmentStartTime || $curCaption["startTime"] >= $segmentEndTime) + && ($curCaption["endTime"] < $segmentStartTime || $curCaption["endTime"] >= $segmentEndTime) ) continue; - if ($curCaption["startTime"]>=$curCaption["endTime"]) + if ($curCaption["startTime"] >= $curCaption["endTime"]) + { continue; + } // calculate line-level styling $styling = array(); @@ -91,18 +110,18 @@ public static function buildWebVTTSegment(array $parsedCaption, $segmentIndex, $ { $style = $firstChunk['style']; - $aligmentMapping = array('left' => 'start', 'right' => 'end', 'center' => 'middle', 'full' => 'middle'); + $alignmentMapping = array('left' => 'start', 'right' => 'end', 'center' => 'middle', 'full' => 'middle'); if (isset($style['textAlign'])) { - if (isset($aligmentMapping[$style['textAlign']])) - $styling['align'] = $aligmentMapping[$style['textAlign']]; + if (isset($alignmentMapping[$style['textAlign']])) + $styling['align'] = $alignmentMapping[$style['textAlign']]; else $styling['align'] = $style['align']; } - $aligmentMapping = array('before' => '0%', 'center' => '50%', 'after' => '100%'); - if (isset($style['displayAlign']) && isset($aligmentMapping[$style['displayAlign']])) - $styling['line'] = $aligmentMapping[$style['displayAlign']]; + $alignmentMapping = array('before' => '0%', 'center' => '50%', 'after' => '100%'); + if (isset($style['displayAlign']) && isset($alignmentMapping[$style['displayAlign']])) + $styling['line'] = $alignmentMapping[$style['displayAlign']]; if (isset($style['origin'])) { @@ -159,26 +178,23 @@ public static function buildWebVTTSegment(array $parsedCaption, $segmentIndex, $ * @param int $localTimestamp * @return string */ - public static function getSegmentFromWebVTT($captionsContentManager, $webVTTcontent, $segmentIndex, $segmentDuration, $localTimestamp) + public static function getSegmentFromWebVTT($captionsContentManager, $webVTTcontent, $segmentIndex, $segmentDuration, $localTimestamp, $clipFrom, $clipTo) { - $parsedCaption = $captionsContentManager->parseWebVTT($webVTTcontent); - $headerInfo = $captionsContentManager->headerInfo; + $result = self::getSegmentHeaderForWebVTT($localTimestamp, $captionsContentManager->headerInfo); - $segmentStartTime = ($segmentIndex - 1) * $segmentDuration * 1000; - $segmentEndTime = $segmentIndex * $segmentDuration * 1000; - - $result = implode('', $headerInfo); - if ($localTimestamp != 10000) - { - $result .= "X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:" . self::formatWebVTTTimeStamp($localTimestamp) . "\n"; - } - $result .= "\n"; + [$segmentStartTime, $segmentEndTime] = self::calculateSegmentTime($segmentIndex, $segmentDuration, $clipFrom, $clipTo); + + $parsedCaption = $captionsContentManager->parseWebVTT($webVTTcontent); foreach ($parsedCaption as $curCaption) { - if ($segmentIndex != -1 && ($curCaption["startTime"] < $segmentStartTime || $curCaption["startTime"] >= $segmentEndTime) && - ($curCaption["endTime"] < $segmentStartTime || $curCaption["endTime"] >= $segmentEndTime)) - continue; + if ($segmentStartTime > -1 && $segmentEndTime > -1 + && ($curCaption["startTime"] < $segmentStartTime || $curCaption["startTime"] >= $segmentEndTime) + && ($curCaption["endTime"] < $segmentStartTime || $curCaption["endTime"] >= $segmentEndTime)) + { + continue; + } + // calculate the line content $content = ''; foreach ($curCaption['content'] as $curChunk) @@ -194,10 +210,49 @@ public static function getSegmentFromWebVTT($captionsContentManager, $webVTTcont self::formatWebVTTTimeStamp($curCaption["endTime"]) ."\n"; $result .= trim($content) . "\n\n"; } + $result .="\n\n\n"; + return $result; } + protected static function getSegmentHeaderForWebVTT($localTimestamp, $headerInfo = null) + { + $result = isset($headerInfo) ? implode('', $headerInfo) : "WEBVTT\n"; + if ($localTimestamp != 10000) + { + $result .= "X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:" . self::formatWebVTTTimeStamp($localTimestamp) . "\n"; + } + $result .= "\n"; + return $result; + } + + protected static function calculateSegmentTime($segmentIndex, $segmentDuration, $clipFrom, $clipTo) + { + $segmentStartTime = $clipFrom ?? 0; + + if ($segmentIndex == -1) + { + if (!isset($clipFrom) && !isset($clipTo)) + { + return array(-1, -1); + } + } + else + { + $segmentStartTime += ($segmentIndex - 1) * $segmentDuration * 1000; + } + + $segmentEndTime = $segmentStartTime + $segmentDuration * 1000; + + if (isset($clipTo) && $clipTo < $segmentEndTime) + { + $segmentEndTime = $clipTo; + } + + return array($segmentStartTime, $segmentEndTime); + } + /** * @param string $textLine * @return string diff --git a/plugins/content/caption/base/services/CaptionAssetService.php b/plugins/content/caption/base/services/CaptionAssetService.php index 3cedf0f18f4..5d7d430f34c 100644 --- a/plugins/content/caption/base/services/CaptionAssetService.php +++ b/plugins/content/caption/base/services/CaptionAssetService.php @@ -649,12 +649,14 @@ public function serveAsJsonAction($captionAssetId) * @param int $segmentDuration * @param int $segmentIndex * @param int $localTimestamp - * @return file + * @param int $clipFrom + * @param int $clipTo + * @return files * @ksOptional * * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND */ - public function serveWebVTTAction($captionAssetId, $segmentDuration = 30, $segmentIndex = null, $localTimestamp = 10000) + public function serveWebVTTAction($captionAssetId, $segmentDuration = 30, $segmentIndex = null, $localTimestamp = 10000, $clipFrom = null, $clipTo = null) { $captionAsset = $this->validateForDownload($captionAssetId); @@ -666,7 +668,7 @@ public function serveWebVTTAction($captionAssetId, $segmentDuration = 30, $segme throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ENTRY_ID_NOT_FOUND, $captionAsset->getEntryId()); entryPeer::setUseCriteriaFilter(true); - return new kRendererString(kWebVTTGenerator::buildWebVTTM3U8File($segmentDuration, (int)$entry->getDuration()), 'application/x-mpegurl'); + return new kRendererString(kWebVTTGenerator::buildWebVTTM3U8File($segmentDuration, (int)$entry->getDuration(), $clipFrom, $clipTo), 'application/x-mpegurl'); } $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $content = kFileSyncUtils::file_get_contents($syncKey, true, false, self::MAX_SERVE_WEBVTT_FILE_SIZE); @@ -687,13 +689,13 @@ public function serveWebVTTAction($captionAssetId, $segmentDuration = 30, $segme throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_INVALID_FORMAT, $captionAssetId); if ($captionAsset->getContainerFormat() == CaptionType::WEBVTT) - return new kRendererString(kWebVTTGenerator::getSegmentFromWebVTT($captionsContentManager, $content, $segmentIndex, $segmentDuration, $localTimestamp), 'text/vtt'); + return new kRendererString(kWebVTTGenerator::getSegmentFromWebVTT($captionsContentManager, $content, $segmentIndex, $segmentDuration, $localTimestamp, $clipFrom, $clipTo), 'text/vtt'); else { $parsedCaption = $captionsContentManager->parse($content); if (!$parsedCaption) throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_PARSING_FAILED, $captionAssetId); - return new kRendererString(kWebVTTGenerator::buildWebVTTSegment($parsedCaption, $segmentIndex, $segmentDuration, $localTimestamp), 'text/vtt'); + return new kRendererString(kWebVTTGenerator::buildWebVTTSegment($parsedCaption, $segmentIndex, $segmentDuration, $localTimestamp, $clipFrom, $clipTo), 'text/vtt'); } } From 96a9429a20759ccd8960451ba0437b21542f7e77 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Wed, 6 Nov 2024 16:37:40 +0200 Subject: [PATCH 2/5] PLAT-24830: Remove unused code --- alpha/apps/kaltura/lib/myEntryUtils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/myEntryUtils.class.php b/alpha/apps/kaltura/lib/myEntryUtils.class.php index 98c7bb7f39e..7435a262f1a 100644 --- a/alpha/apps/kaltura/lib/myEntryUtils.class.php +++ b/alpha/apps/kaltura/lib/myEntryUtils.class.php @@ -2015,7 +2015,7 @@ public static function isEntryReady($entryId) /* * Builds a manifest request for entry according to relevant flavors, delivery profile type and location of deliveryProfile(local/remote) */ - public static function buildManifestUrl($entry, $protocols, $format, $flavors, $profileId = "", $clipFrom = null, $clipTo = null) + public static function buildManifestUrl($entry, $protocols, $format, $flavors, $profileId = "") { $entryId = $entry->getId(); $partnerId = $entry->getPartnerId(); From c3c50db62f2fc4fedc5aa89c296ad6c002ad780c Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Thu, 7 Nov 2024 13:16:08 +0200 Subject: [PATCH 3/5] PLAT-24830: Added validation on clipping time --- api_v3/lib/KalturaErrors.php | 2 ++ api_v3/services/BaseEntryService.php | 7 +++++++ .../caption/base/lib/kWebVTTGenerator.php | 20 +++++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/api_v3/lib/KalturaErrors.php b/api_v3/lib/KalturaErrors.php index 963ee9a99d7..0e18e7d3299 100644 --- a/api_v3/lib/KalturaErrors.php +++ b/api_v3/lib/KalturaErrors.php @@ -712,6 +712,8 @@ class KalturaErrors extends APIErrors const FEATURE_RECYCLE_BIN_DISABLED = "FEATURE_RECYCLE_BIN_DISABLED;;Feature recycle bin is disabled for partner"; + const CLIPPING_PARAMS_INVALID = "CLIPPING_PARAMS_INVALID;;Clipping parameters are invalid"; + /* * FileAsset Service */ diff --git a/api_v3/services/BaseEntryService.php b/api_v3/services/BaseEntryService.php index b738ae9b2b6..bd4249b7082 100644 --- a/api_v3/services/BaseEntryService.php +++ b/api_v3/services/BaseEntryService.php @@ -1048,6 +1048,13 @@ function getPlaybackContextAction($entryId, KalturaPlaybackContextOptions $conte $contextDataHelper->setMediaProtocol($contextDataParams->mediaProtocol); $contextDataHelper->setStreamerType($contextDataParams->streamerType); + + KalturaLog::debug("getPlaybackContext - " . print_r($contextDataParams, true)); + if (isset($contextDataParams->clipFrom) && isset($contextDataParams->clipTo) + && $contextDataParams->clipFrom >= $contextDataParams->clipTo) + { + throw new KalturaAPIException(KalturaErrors::CLIPPING_PARAMS_INVALID); + } $contextDataHelper->setClipFrom($contextDataParams->clipFrom); $contextDataHelper->setClipTo($contextDataParams->clipTo); diff --git a/plugins/content/caption/base/lib/kWebVTTGenerator.php b/plugins/content/caption/base/lib/kWebVTTGenerator.php index ed8c85a1679..fbec4b3e99d 100644 --- a/plugins/content/caption/base/lib/kWebVTTGenerator.php +++ b/plugins/content/caption/base/lib/kWebVTTGenerator.php @@ -92,13 +92,12 @@ public static function buildWebVTTSegment(array $parsedCaption, $segmentIndex, $ foreach ($parsedCaption as $curCaption) { - if ($segmentStartTime > -1 && $segmentEndTime > -1 - && ($curCaption["startTime"] < $segmentStartTime || $curCaption["startTime"] >= $segmentEndTime) - && ($curCaption["endTime"] < $segmentStartTime || $curCaption["endTime"] >= $segmentEndTime) - ) + if (self::validateCaptionTimeFrame($curCaption, $segmentStartTime, $segmentEndTime)) + { continue; + } - if ($curCaption["startTime"] >= $curCaption["endTime"]) + if ($curCaption['startTime'] >= $curCaption['endTime']) { continue; } @@ -188,9 +187,7 @@ public static function getSegmentFromWebVTT($captionsContentManager, $webVTTcont foreach ($parsedCaption as $curCaption) { - if ($segmentStartTime > -1 && $segmentEndTime > -1 - && ($curCaption["startTime"] < $segmentStartTime || $curCaption["startTime"] >= $segmentEndTime) - && ($curCaption["endTime"] < $segmentStartTime || $curCaption["endTime"] >= $segmentEndTime)) + if (self::validateCaptionTimeFrame($curCaption, $segmentStartTime, $segmentEndTime)) { continue; } @@ -253,6 +250,13 @@ protected static function calculateSegmentTime($segmentIndex, $segmentDuration, return array($segmentStartTime, $segmentEndTime); } + protected static function validateCaptionTimeFrame($curCaption, $segmentStartTime, $segmentEndTime) + { + return $segmentStartTime > -1 && $segmentEndTime > -1 + && ($curCaption['startTime'] < $segmentStartTime || $curCaption['startTime'] >= $segmentEndTime) + && ($curCaption['endTime'] < $segmentStartTime || $curCaption['endTime'] >= $segmentEndTime); + } + /** * @param string $textLine * @return string From f2b1f76708a87e0e8e83840ebb07e60c35e980d2 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Thu, 7 Nov 2024 13:16:57 +0200 Subject: [PATCH 4/5] PLAT-24830: Removed a print --- api_v3/services/BaseEntryService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/api_v3/services/BaseEntryService.php b/api_v3/services/BaseEntryService.php index bd4249b7082..87573143381 100644 --- a/api_v3/services/BaseEntryService.php +++ b/api_v3/services/BaseEntryService.php @@ -1049,7 +1049,6 @@ function getPlaybackContextAction($entryId, KalturaPlaybackContextOptions $conte $contextDataHelper->setMediaProtocol($contextDataParams->mediaProtocol); $contextDataHelper->setStreamerType($contextDataParams->streamerType); - KalturaLog::debug("getPlaybackContext - " . print_r($contextDataParams, true)); if (isset($contextDataParams->clipFrom) && isset($contextDataParams->clipTo) && $contextDataParams->clipFrom >= $contextDataParams->clipTo) { From a813aeee7bd77ad0891e5d0ca6f31dc85872ac59 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Mon, 11 Nov 2024 11:28:05 +0200 Subject: [PATCH 5/5] PLAT-24830: No clipping args equals to zero --- plugins/content/caption/base/lib/kWebVTTGenerator.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/content/caption/base/lib/kWebVTTGenerator.php b/plugins/content/caption/base/lib/kWebVTTGenerator.php index fbec4b3e99d..cbe93498ca6 100644 --- a/plugins/content/caption/base/lib/kWebVTTGenerator.php +++ b/plugins/content/caption/base/lib/kWebVTTGenerator.php @@ -184,7 +184,6 @@ public static function getSegmentFromWebVTT($captionsContentManager, $webVTTcont [$segmentStartTime, $segmentEndTime] = self::calculateSegmentTime($segmentIndex, $segmentDuration, $clipFrom, $clipTo); $parsedCaption = $captionsContentManager->parseWebVTT($webVTTcontent); - foreach ($parsedCaption as $curCaption) { if (self::validateCaptionTimeFrame($curCaption, $segmentStartTime, $segmentEndTime)) @@ -226,11 +225,11 @@ protected static function getSegmentHeaderForWebVTT($localTimestamp, $headerInfo protected static function calculateSegmentTime($segmentIndex, $segmentDuration, $clipFrom, $clipTo) { - $segmentStartTime = $clipFrom ?? 0; + $segmentStartTime = $clipFrom ?: 0; if ($segmentIndex == -1) { - if (!isset($clipFrom) && !isset($clipTo)) + if (!$clipFrom && !$clipTo) { return array(-1, -1); } @@ -242,7 +241,7 @@ protected static function calculateSegmentTime($segmentIndex, $segmentDuration, $segmentEndTime = $segmentStartTime + $segmentDuration * 1000; - if (isset($clipTo) && $clipTo < $segmentEndTime) + if ($clipTo && $clipTo < $segmentEndTime) { $segmentEndTime = $clipTo; }