2021-12-09 21:00:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace dzz\ffmpeg\classes;
|
|
|
|
|
|
|
|
|
|
use \core as C;
|
|
|
|
|
use \fmpeg as fmpeg;
|
2022-06-25 14:48:20 +08:00
|
|
|
use \IO as IO;
|
|
|
|
|
use \DB as DB;
|
2024-01-31 01:00:33 +08:00
|
|
|
|
2021-12-09 21:00:09 +08:00
|
|
|
class thumb
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public function run(&$data)
|
|
|
|
|
{
|
2024-02-06 00:03:33 +08:00
|
|
|
global $_G;
|
2024-01-31 01:00:33 +08:00
|
|
|
$app = C::t('app_market')->fetch_by_identifier('ffmpeg', 'dzz');
|
|
|
|
|
$extra = unserialize($app['extra']);
|
2021-12-09 21:00:09 +08:00
|
|
|
|
2024-01-31 01:00:33 +08:00
|
|
|
|
|
|
|
|
if (!$extra['status']) {
|
2022-06-25 14:48:20 +08:00
|
|
|
return '';
|
|
|
|
|
}
|
2024-02-06 00:03:33 +08:00
|
|
|
$exts = explode(',',$_G['config']['pichomeffmpeggetthumbext']);//$extra['exts_thumb'] ? explode(',', $extra['exts_thumb']) : array();
|
2024-01-31 01:00:33 +08:00
|
|
|
|
|
|
|
|
//如果类型不符合则停止执行
|
|
|
|
|
if (!in_array($data['ext'], $exts)) return '';
|
2021-12-09 21:00:09 +08:00
|
|
|
|
|
|
|
|
require_once DZZ_ROOT . './dzz/ffmpeg/class/class_fmpeg.php';
|
|
|
|
|
$fm = new fmpeg();
|
|
|
|
|
if ($data['Duration']) {
|
|
|
|
|
$start = ceil($data['duration'] / 5);
|
|
|
|
|
} else {
|
2024-01-31 01:00:33 +08:00
|
|
|
$start = 0;
|
2021-12-09 21:00:09 +08:00
|
|
|
}
|
2024-01-31 01:00:33 +08:00
|
|
|
//执行获取缩略图
|
2021-12-09 21:00:09 +08:00
|
|
|
if ($target = $fm->getThumb($data, $start)) {
|
2022-06-25 14:48:20 +08:00
|
|
|
return array($target);
|
2024-01-31 01:00:33 +08:00
|
|
|
} else {
|
2022-06-25 14:48:20 +08:00
|
|
|
return '';
|
2021-12-09 21:00:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|