Improve media retrieval performance
This commit is contained in:
@@ -180,9 +180,9 @@ class Media extends PhpObject {
|
|||||||
{
|
{
|
||||||
$sMediaPath = self::getMediaPath($sMediaName);
|
$sMediaPath = self::getMediaPath($sMediaName);
|
||||||
$sThumbPath = self::getMediaPath($sMediaName, 'thumbnail');
|
$sThumbPath = self::getMediaPath($sMediaName, 'thumbnail');
|
||||||
$sType = self::getMediaType($sMediaName);
|
|
||||||
|
|
||||||
if(!file_exists($sThumbPath)) {
|
if(!file_exists($sThumbPath)) {
|
||||||
|
$sType = self::getMediaType($sMediaName);
|
||||||
switch($sType) {
|
switch($sType) {
|
||||||
case 'image':
|
case 'image':
|
||||||
$asThumbInfo = ToolBox::createThumbnail($sMediaPath, self::THUMB_MAX_WIDTH, 0, $sThumbPath);
|
$asThumbInfo = ToolBox::createThumbnail($sMediaPath, self::THUMB_MAX_WIDTH, 0, $sThumbPath);
|
||||||
@@ -192,10 +192,10 @@ class Media extends PhpObject {
|
|||||||
$sTempPath = self::getMediaPath(uniqid('temp_').'.png');
|
$sTempPath = self::getMediaPath(uniqid('temp_').'.png');
|
||||||
$asResult = array();
|
$asResult = array();
|
||||||
$sParams = implode(' ', array(
|
$sParams = implode(' ', array(
|
||||||
'-i "'.$sMediaPath.'"', //input file
|
'-i "'.$sMediaPath.'"', //input file
|
||||||
'-ss 00:00:01.000', //Image taken after x seconds
|
'-ss 00:00:01.000', //Image taken after x seconds
|
||||||
'-vframes 1', //number of video frames to output
|
'-vframes 1', //number of video frames to output
|
||||||
'"'.$sTempPath.'"', //output file
|
'"'.$sTempPath.'"', //output file
|
||||||
));
|
));
|
||||||
exec('ffmpeg '.$sParams, $asResult);
|
exec('ffmpeg '.$sParams, $asResult);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ class Media extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static function getMediaPath($sMediaName, $sFileType='media') {
|
private static function getMediaPath($sMediaName, $sFileType='media') {
|
||||||
if($sFileType=='thumbnail') return self::THUMB_FOLDER.$sMediaName.(self::getMediaType($sMediaName)=='video'?'.png':'');
|
if($sFileType=='thumbnail') return self::THUMB_FOLDER.$sMediaName.(strtolower(substr($sMediaName, -3))=='mov'?'.png':'');
|
||||||
else return self::MEDIA_FOLDER.$sMediaName;
|
else return self::MEDIA_FOLDER.$sMediaName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user