本文整理汇总了PHP中kFileSyncUtils::getWamsAssetIdForKey方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::getWamsAssetIdForKey方法的具体用法?PHP kFileSyncUtils::getWamsAssetIdForKey怎么用?PHP kFileSyncUtils::getWamsAssetIdForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::getWamsAssetIdForKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attachFile
/**
* @param AttachmentAsset $attachmentAsset
* @param string $fullPath
* @param bool $copyOnly
*/
protected function attachFile(AttachmentAsset $attachmentAsset, $fullPath, $copyOnly = false)
{
$ext = pathinfo($fullPath, PATHINFO_EXTENSION);
$attachmentAsset->incrementVersion();
$attachmentAsset->setFileExt($ext);
$attachmentAsset->setSize(kFile::fileSize($fullPath));
$attachmentAsset->save();
$syncKey = $attachmentAsset->getSyncKey(AttachmentAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
try {
kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, $copyOnly);
} catch (Exception $e) {
if ($attachmentAsset->getStatus() == AttachmentAsset::ASSET_STATUS_QUEUED || $attachmentAsset->getStatus() == AttachmentAsset::ASSET_STATUS_NOT_APPLICABLE) {
$attachmentAsset->setDescription($e->getMessage());
$attachmentAsset->setStatus(AttachmentAsset::ASSET_STATUS_ERROR);
$attachmentAsset->save();
}
throw $e;
}
$finalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$wamsURL = kFileSyncUtils::getWamsURLForKey($syncKey);
if (empty($wamsURL)) {
list($width, $height, $type, $attr) = getimagesize($finalPath);
$fileSize = kFile::fileSize($finalPath);
} else {
list($width, $height, $type, $attr) = getimagesize($wamsURL);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
$fileSize = kWAMS::getInstance($syncKey->getPartnerId())->getFileSizeForAssetId($wamsAssetId, pathinfo($finalPath, PATHINFO_EXTENSION));
}
$attachmentAsset->setWidth($width);
$attachmentAsset->setHeight($height);
$attachmentAsset->setSize($fileSize);
$attachmentAsset->setStatus(AttachmentAsset::ASSET_STATUS_READY);
$attachmentAsset->save();
}
示例2: convert
/**
* Convert entry
*
* @param string $entryId Media entry id
* @param int $conversionProfileId
* @param KalturaConversionAttributeArray $dynamicConversionAttributes
* @return int job id
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND
* @throws KalturaErrors::FLAVOR_PARAMS_NOT_FOUND
*/
protected function convert($entryId, $conversionProfileId = null, KalturaConversionAttributeArray $dynamicConversionAttributes = null)
{
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$srcFlavorAsset) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
if (is_null($conversionProfileId) || $conversionProfileId <= 0) {
$conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
if (!$conversionProfile) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
}
$conversionProfileId = $conversionProfile->getId();
} else {
//The search is with the entry's partnerId. so if conversion profile wasn't found it means that the
//conversionId is not exist or the conversion profileId does'nt belong to this partner.
$conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId);
if (is_null($conversionProfile)) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
}
}
$srcSyncKey = $srcFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// if the file sync isn't local (wasn't synced yet) proxy request to other datacenter
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
if (!$fileSync) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
} else {
if (!$local) {
kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync));
}
}
// even if it null
$entry->setConversionQuality($conversionProfileId);
$entry->save();
if ($dynamicConversionAttributes) {
$flavors = assetParamsPeer::retrieveByProfile($conversionProfileId);
if (!count($flavors)) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_NOT_FOUND);
}
$srcFlavorParamsId = null;
$flavorParams = $entry->getDynamicFlavorAttributes();
foreach ($flavors as $flavor) {
if ($flavor->hasTag(flavorParams::TAG_SOURCE)) {
$srcFlavorParamsId = $flavor->getId();
}
$flavorParams[$flavor->getId()] = $flavor;
}
$dynamicAttributes = array();
foreach ($dynamicConversionAttributes as $dynamicConversionAttribute) {
if (is_null($dynamicConversionAttribute->flavorParamsId)) {
$dynamicConversionAttribute->flavorParamsId = $srcFlavorParamsId;
}
if (is_null($dynamicConversionAttribute->flavorParamsId)) {
continue;
}
$dynamicAttributes[$dynamicConversionAttribute->flavorParamsId][trim($dynamicConversionAttribute->name)] = trim($dynamicConversionAttribute->value);
}
if (count($dynamicAttributes)) {
$entry->setDynamicFlavorAttributes($dynamicAttributes);
$entry->save();
}
}
$srcFilePath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($srcSyncKey);
$job = kJobsManager::addConvertProfileJob(null, $entry, $srcFlavorAsset->getId(), $srcFilePath, $wamsAssetId);
if (!$job) {
return null;
}
return $job->getId();
}
示例3: bypassConversion
/**
* @param flavorAsset $originalFlavorAsset
* @param entry $entry
* @param BatchJob $convertProfileJob
* @return BatchJob
*/
public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob)
{
if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
if ($mediaInfo) {
$tagsArray = $originalFlavorAsset->getTagsArray();
$finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray);
$originalFlavorAsset->setTagsArray($finalTagsArray);
}
}
if (!$entry->getCreateThumb()) {
// mark the asset as ready
$originalFlavorAsset->setStatusLocalReady();
$originalFlavorAsset->save();
kFlowHelper::generateThumbnailsFromFlavor($entry->getId(), null, $originalFlavorAsset->getFlavorParamsId());
kBusinessPostConvertDL::handleConvertFinished(null, $originalFlavorAsset);
return null;
}
$offset = $entry->getThumbOffset();
// entry getThumbOffset now takes the partner DefThumbOffset into consideration
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
$srcFileSyncWamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($srcSyncKey);
$postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_BYPASS;
return kJobsManager::addPostConvertJob($convertProfileJob, $postConvertAssetType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset, null, $srcFileSyncWamsAssetId);
}
示例4: addConvertProfileJobAction
/**
* batch addConvertProfileJobAction creates a new convert profile job
*
* @action addConvertProfileJob
* @param string $entryId the id of the entry to be reconverted
* @return KalturaBatchJobResponse
*/
function addConvertProfileJobAction($entryId)
{
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
throw new KalturaAPIException(APIErrors::INVALID_ENTRY_ID, 'entry', $entryId);
}
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$flavorAsset) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($syncKey, true)) {
throw new KalturaAPIException(APIErrors::NO_FILES_RECEIVED);
}
$inputFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
$batchJob = kJobsManager::addConvertProfileJob(null, $entry, $flavorAsset->getId(), $inputFileSyncLocalPath, $wamsAssetId);
return $this->getStatusAction($batchJob->getId(), KalturaBatchJobType::CONVERT_PROFILE);
}
示例5: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
$entryId = $this->getRequestParameter("entry_id");
$flavorId = $this->getRequestParameter("flavor");
$fileName = $this->getRequestParameter("file_name");
$fileName = basename($fileName);
$ksStr = $this->getRequestParameter("ks");
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$entry = null;
if ($ksStr) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
kEntitlementUtils::initEntitlementEnforcement();
if (!$entry) {
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, accessControlContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload($entry, $ksStr);
$flavorAsset = null;
if ($flavorId) {
// get flavor asset
$flavorAsset = assetPeer::retrieveById($flavorId);
if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
// the request flavor should belong to the requested entry
if ($flavorAsset->getEntryId() != $entryId) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
} else {
$flavorAsset = assetPeer::retrieveBestPlayByEntryId($entry->getId());
}
// Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source
if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
}
if ($flavorAsset) {
$syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset);
} else {
$syncKey = $this->getBestSyncKeyForEntry($entry);
}
if (is_null($syncKey)) {
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$this->handleFileSyncRedirection($syncKey);
$filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
$wamsURL = kFileSyncUtils::getWamsURLForKey($syncKey);
list($fileBaseName, $fileExt) = $this->getFileName($entry, $flavorAsset);
if (!$fileName) {
$fileName = $fileBaseName;
}
if ($fileExt && !is_dir($filePath)) {
$fileName = $fileName . '.' . $fileExt;
}
//enable downloading file_name which inside the flavor asset directory
if (is_dir($filePath)) {
$filePath = $filePath . DIRECTORY_SEPARATOR . $fileName;
}
$this->dumpFile($filePath, $fileName, $wamsAssetId, $wamsURL);
die;
// no view
}
示例6: handlePostConvertFinished
/**
* @param BatchJob $dbBatchJob
* @param kPostConvertJobData $data
* @param BatchJob $twinJob
* @return BatchJob|BatchJob
*/
public static function handlePostConvertFinished(BatchJob $dbBatchJob, kPostConvertJobData $data, BatchJob $twinJob = null)
{
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
if ($data->getCreateThumb()) {
try {
self::createThumbnail($dbBatchJob, $data);
} catch (Exception $e) {
KalturaLog::err($e->getMessage());
// sometimes, because of disc IO load, it takes long time for the thumb to be moved.
// in such cases, the entry thumb version may be increased by other process.
// retry the job, it solves the issue.
kJobsManager::retryJob($dbBatchJob->getId(), $dbBatchJob->getJobType(), true);
$dbBatchJob->reload();
return $dbBatchJob;
}
}
$currentFlavorAsset = kBusinessPostConvertDL::handleFlavorReady($dbBatchJob, $data->getFlavorAssetId());
if ($data->getPostConvertAssetType() == BatchJob::POSTCONVERT_ASSET_TYPE_SOURCE) {
$convertProfileJob = $dbBatchJob->getRootJob();
if ($convertProfileJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
try {
kBusinessPreConvertDL::continueProfileConvert($dbBatchJob);
} catch (Exception $e) {
KalturaLog::err($e->getMessage());
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return $dbBatchJob;
}
} elseif ($currentFlavorAsset) {
KalturaLog::log("Root job [" . $convertProfileJob->getId() . "] is not profile conversion");
$syncKey = $currentFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::fileSync_exists($syncKey)) {
KalturaLog::debug("Start conversion");
$path = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
kJobsManager::addConvertProfileJob(null, $dbBatchJob->getEntry(), $currentFlavorAsset->getId(), $path, $wamsAssetId);
} else {
KalturaLog::debug("File sync not created yet");
}
$currentFlavorAsset = null;
}
}
if ($currentFlavorAsset) {
kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $currentFlavorAsset);
}
return $dbBatchJob;
}
示例7: objectChanged
public function objectChanged(BaseObject $object, array $modifiedColumns)
{
if ($object instanceof entry && in_array(entryPeer::STATUS, $modifiedColumns) && $object->getStatus() == entryStatus::READY && $object->getReplacedEntryId()) {
kFlowHelper::handleEntryReplacement($object);
return true;
}
if ($object instanceof UploadToken && in_array(UploadTokenPeer::STATUS, $modifiedColumns) && $object->getStatus() == UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
kFlowHelper::handleUploadFinished($object);
return true;
}
if ($object instanceof BatchJob && $object->getJobType() == BatchJobType::BULKUPLOAD && $object->getStatus() == BatchJob::BATCHJOB_STATUS_ABORTED && in_array(BatchJobPeer::STATUS, $modifiedColumns) && in_array($object->getColumnsOldValue(BatchJobPeer::STATUS), BatchJobPeer::getClosedStatusList())) {
$partner = $object->getPartner();
if ($partner->getEnableBulkUploadNotificationsEmails()) {
kFlowHelper::sendBulkUploadNotificationEmail($object, MailType::MAIL_TYPE_BULKUPLOAD_ABORTED, array($partner->getAdminName(), $object->getId(), kFlowHelper::createBulkUploadLogUrl($object)));
}
return true;
}
if ($object instanceof UserRole && in_array(UserRolePeer::PERMISSION_NAMES, $modifiedColumns)) {
$filter = new kuserFilter();
$filter->set('_eq_role_ids', $object->getId());
kJobsManager::addIndexJob($object->getPartnerId(), IndexObjectType::USER, $filter, false);
return true;
}
if (!$object instanceof flavorAsset || !in_array(assetPeer::STATUS, $modifiedColumns)) {
return true;
}
$entry = entryPeer::retrieveByPKNoFilter($object->getEntryId());
KalturaLog::debug("Asset id [" . $object->getId() . "] isOriginal [" . $object->getIsOriginal() . "] status [" . $object->getStatus() . "]");
if ($object->getIsOriginal()) {
return true;
}
if ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
$postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
$offset = $entry->getThumbOffset();
// entry getThumbOffset now takes the partner DefThumbOffset into consideration
$syncKey = $object->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey, false);
if (!$fileSync) {
return true;
}
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$srcFileSyncWamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
if ($srcFileSyncLocalPath || $srcFileSyncWamsAssetId) {
kJobsManager::addPostConvertJob(null, $postConvertAssetType, $srcFileSyncLocalPath, $object->getId(), null, $entry->getCreateThumb(), $offset, null, $srcFileSyncWamsAssetId);
}
} elseif ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
// If we get a ready flavor and the entry is in no content
if ($entry->getStatus() == entryStatus::NO_CONTENT) {
$entry->setStatus(entryStatus::PENDING);
// we change the entry to pending
$entry->save();
}
}
return true;
}
示例8: resizeEntryImage
public static function resizeEntryImage(entry $entry, $version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $orig_image_path = null, $density = 0, $stripProfiles = false, $thumbParams = null)
{
if (is_null($thumbParams) || !$thumbParams instanceof kThumbnailParameters) {
$thumbParams = new kThumbnailParameters();
}
$contentPath = myContentStorage::getFSContentRootPath();
$entry_status = $entry->getStatus();
$tempThumbName = $entry->getId() . "_{$width}_{$height}_{$type}_{$crop_provider}_{$bgcolor}_{$quality}_{$src_x}_{$src_y}_{$src_w}_{$src_h}_{$vid_sec}_{$vid_slice}_{$vid_slices}_{$entry_status}";
if ($orig_image_path) {
$tempThumbName .= '_oip_' . basename($orig_image_path);
}
if ($density) {
$tempThumbName .= "_dns_{$density}";
}
if ($stripProfiles) {
$tempThumbName .= "_stp_{$stripProfiles}";
}
$entryThumbFilename = $entry->getThumbnail() ? $entry->getThumbnail() : "0.jpg";
if ($entry->getStatus() != entryStatus::READY || @$entryThumbFilename[0] == '&') {
$tempThumbName .= "_NOCACHE_";
}
// we remove the & from the template thumb otherwise getGeneralEntityPath will drop $tempThumbName from the final path
$entryThumbFilename = str_replace("&", "", $entryThumbFilename);
$basePath = myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $tempThumbName, $entryThumbFilename, $version);
$tempThumbPath = $contentPath . $basePath;
if (file_exists($tempThumbPath) && @filesize($tempThumbPath)) {
header("X-Kaltura:cached-thumb-exists," . md5($tempThumbPath));
return $tempThumbPath;
}
if ($orig_image_path === null || !file_exists($orig_image_path)) {
$sub_type = $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE ? entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA : entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
$orig_image_key = $entry->getSyncKey($sub_type, $version);
$orig_image_path = kFileSyncUtils::getReadyLocalFilePathForKey($orig_image_key);
}
// remark added so ffmpeg will try to load the thumbnail from the original source
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE && !file_exists($orig_image_path)) {
throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC);
}
// check a request for animated thumbs without a concrete vid_slice
// in which case we'll create all the frames as one wide image
$multi = $vid_slice == -1 && $vid_slices != -1;
$count = $multi ? $vid_slices : 1;
$im = null;
if ($multi) {
$vid_slice = 0;
}
while ($count--) {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO && ($vid_sec != -1 || $vid_slices != -1) || !file_exists($orig_image_path)) {
if ($vid_sec != -1) {
$calc_vid_sec = min($vid_sec, floor($entry->getLengthInMsecs() / 1000));
} else {
if ($vid_slices != -1) {
$calc_vid_sec = floor($entry->getLengthInMsecs() / $vid_slices * min($vid_slice, $vid_slices) / 1000);
} else {
if ($entry->getStatus() != entryStatus::READY && $entry->getLengthInMsecs() == 0) {
$calc_vid_sec = $entry->getPartner() && $entry->getPartner()->getDefThumbOffset() ? $entry->getPartner()->getDefThumbOffset() : 3;
} else {
$calc_vid_sec = $entry->getBestThumbOffset();
}
}
}
$capturedThumbName = $entry->getId() . "_sec_{$calc_vid_sec}";
$capturedThumbPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $capturedThumbName, $entry->getThumbnail(), $version);
$orig_image_path = $capturedThumbPath . "temp_1.jpg";
// if we already captured the frame at that second, dont recapture, just use the existing file
if (!file_exists($orig_image_path)) {
// creating the thumbnail is a very heavy operation
// prevent calling it in parallel for the same thubmnail for 5 minutes
$cache = new myCache("thumb-processing", 5 * 60);
// 5 minutes
$processing = $cache->get($orig_image_path);
if ($processing) {
KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
}
$cache->put($orig_image_path, true);
$flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), flavorParams::TAG_THUMBSOURCE);
if (is_null($flavorAsset)) {
$flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($entry->getId());
if (is_null($flavorAsset) || !($flavorAsset->hasTag(flavorParams::TAG_MBR) || $flavorAsset->hasTag(flavorParams::TAG_WEB))) {
// try the best playable
$flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId());
}
if (is_null($flavorAsset)) {
// if no READY ORIGINAL entry is available, try to retrieve a non-READY ORIGINAL entry
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
}
}
if (is_null($flavorAsset)) {
// if no READY ORIGINAL entry is available, try to retrieve a non-READY ORIGINAL entry
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$entry_data_path = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
$entry_data_wams_asset_id = kFileSyncUtils::getWamsAssetIdForKey($flavorSyncKey);
if (!$entry_data_path) {
// since this is not really being processed on this server, and will probably cause redirect in thumbnailAction
// remove from cache so later requests will still get redirected and will not fail on PROCESSING_CAPTURE_THUMBNAIL
//.........这里部分代码省略.........