/** * batch addMediaInfo adds a media info and updates the flavor asset * * @param mediaInfo $mediaInfoDb * @return mediaInfo */ public static function addMediaInfo(mediaInfo $mediaInfoDb) { $mediaInfoDb->save(); KalturaLog::log("Added media info [" . $mediaInfoDb->getId() . "] for flavor asset [" . $mediaInfoDb->getFlavorAssetId() . "]"); if (!$mediaInfoDb->getFlavorAssetId()) { return $mediaInfoDb; } $flavorAsset = assetPeer::retrieveById($mediaInfoDb->getFlavorAssetId()); if (!$flavorAsset) { return $mediaInfoDb; } if ($flavorAsset->getIsOriginal()) { KalturaLog::log("Media info is for the original flavor asset"); $tags = null; $profile = myPartnerUtils::getConversionProfile2ForEntry($flavorAsset->getEntryId()); if ($profile) { $tags = $profile->getInputTagsMap(); } KalturaLog::log("Flavor asset tags from profile [{$tags}]"); if (!is_null($tags)) { $tagsArray = explode(',', $tags); // support for old migrated profiles if ($profile->getCreationMode() == conversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_AUTOMATIC_BYPASS_FLV) { if (!KDLWrap::CDLIsFLV($mediaInfoDb)) { $key = array_search(flavorParams::TAG_MBR, $tagsArray); if ($key !== false) { unset($tagsArray[$key]); } } } $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfoDb, $tagsArray); $finalTags = join(',', array_unique($finalTagsArray)); KalturaLog::log("Flavor asset tags from KDL [{$finalTags}]"); //KalturaLog::log("Flavor asset tags [".print_r($flavorAsset->setTags(),1)."]"); $flavorAsset->addTags($finalTagsArray); } } else { KalturaLog::log("Media info is for the destination flavor asset"); $tags = null; $flavorParams = assetParamsPeer::retrieveByPK($flavorAsset->getFlavorParamsId()); if ($flavorParams) { $tags = $flavorParams->getTags(); } KalturaLog::log("Flavor asset tags from flavor params [{$tags}]"); if (!is_null($tags)) { $tagsArray = explode(',', $tags); $assetTagsArray = $flavorAsset->getTagsArray(); foreach ($assetTagsArray as $tag) { $tagsArray[] = $tag; } $maxMbrBitrate = 8000; if (kConf::hasParam('max_mbr_flavor_bitrate')) { $maxMbrBitrate = kConf::get('max_mbr_flavor_bitrate'); } if ($mediaInfoDb->getContainerBitRate() >= $maxMbrBitrate) { $tagsArray = array_unique($tagsArray); $key = array_search(flavorParams::TAG_MBR, $tagsArray); if ($key !== false) { unset($tagsArray[$key]); } } $finalTagsArray = $tagsArray; // bypass, KDLWrap::CDLMediaInfo2Tags doesn't support destination flavors and mobile tags // $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfoDb, $tagsArray); $finalTags = join(',', array_unique($finalTagsArray)); KalturaLog::log("Flavor asset tags from KDL [{$finalTags}]"); $flavorAsset->setTags($finalTags); } } KalturaLog::log("KDLWrap::ConvertMediainfoCdl2FlavorAsset(" . $mediaInfoDb->getId() . ", " . $flavorAsset->getId() . ");"); KDLWrap::ConvertMediainfoCdl2FlavorAsset($mediaInfoDb, $flavorAsset); $flavorAsset->save(); // if(!$flavorAsset->hasTag(flavorParams::TAG_MBR)) // return $mediaInfoDb; $entry = entryPeer::retrieveByPK($flavorAsset->getEntryId()); if (!$entry) { return $mediaInfoDb; } $contentDuration = $mediaInfoDb->getContainerDuration(); if (!$contentDuration) { $contentDuration = $mediaInfoDb->getVideoDuration(); if (!$contentDuration) { $contentDuration = $mediaInfoDb->getAudioDuration(); } } if ($contentDuration && $entry->getCalculateDuration()) { $entry->setLengthInMsecs($contentDuration); } if ($mediaInfoDb->getVideoWidth() && $mediaInfoDb->getVideoHeight()) { $entry->setDimensionsIfBigger($mediaInfoDb->getVideoWidth(), $mediaInfoDb->getVideoHeight()); } $entry->save(); return $mediaInfoDb; }
/** * batch addMediaInfo adds a media info and updates the flavor asset * * @param mediaInfo $mediaInfoDb * @return mediaInfo */ public static function addMediaInfo(mediaInfo $mediaInfoDb) { $mediaInfoDb->save(); KalturaLog::log("Added media info [" . $mediaInfoDb->getId() . "] for flavor asset [" . $mediaInfoDb->getFlavorAssetId() . "]"); if (!$mediaInfoDb->getFlavorAssetId()) { return $mediaInfoDb; } $flavorAsset = flavorAssetPeer::retrieveById($mediaInfoDb->getFlavorAssetId()); if (!$flavorAsset) { return $mediaInfoDb; } if ($flavorAsset->getIsOriginal()) { KalturaLog::log("Media info is for the original flavor asset"); $tags = null; $profile = myPartnerUtils::getConversionProfile2ForEntry($flavorAsset->getEntryId()); if ($profile) { $tags = $profile->getInputTagsMap(); } KalturaLog::log("Flavor asset tags from profile [{$tags}]"); if (!is_null($tags)) { $tagsArray = explode(',', $tags); // support for old migrated profiles if ($profile->getCreationMode() == conversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_AUTOMATIC_BYPASS_FLV) { if (!KDLWrap::CDLIsFLV($mediaInfoDb)) { $key = array_search(flavorParams::TAG_MBR, $tagsArray); unset($tagsArray[$key]); } } $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfoDb, $tagsArray); $finalTags = join(',', $finalTagsArray); KalturaLog::log("Flavor asset tags from KDL [{$finalTags}]"); $flavorAsset->setTags($finalTags); } } KalturaLog::log("KDLWrap::ConvertMediainfoCdl2FlavorAsset(" . $mediaInfoDb->getId() . ", " . $flavorAsset->getId() . ");"); KDLWrap::ConvertMediainfoCdl2FlavorAsset($mediaInfoDb, $flavorAsset); $flavorAsset->save(); // if(!$flavorAsset->hasTag(flavorParams::TAG_MBR)) // return $mediaInfoDb; $entry = entryPeer::retrieveByPK($flavorAsset->getEntryId()); if (!$entry) { return $mediaInfoDb; } $contentDuration = $mediaInfoDb->getContainerDuration(); if (!$contentDuration) { $contentDuration = $mediaInfoDb->getVideoDuration(); if (!$contentDuration) { $contentDuration = $mediaInfoDb->getAudioDuration(); } } $entry->setLengthInMsecs($contentDuration); if ($mediaInfoDb->getVideoWidth() && $mediaInfoDb->getVideoHeight()) { $entry->setDimensions($mediaInfoDb->getVideoWidth(), $mediaInfoDb->getVideoHeight()); } $entry->save(); return $mediaInfoDb; }