PicHome2.0
This commit is contained in:
@@ -1,46 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace dzz\ffmpeg\classes;
|
||||
|
||||
use \core as C;
|
||||
use \DB as DB;
|
||||
use \IO as IO;
|
||||
class convert{
|
||||
|
||||
public function run($data,$force=false)
|
||||
{
|
||||
if(strpos($data['realpath'],':') === false){
|
||||
$bz = 'dzz';
|
||||
}else{
|
||||
$patharr = explode(':', $data['realpath']);
|
||||
$bz = $patharr[0];
|
||||
$did = $patharr[1];
|
||||
|
||||
}
|
||||
if(!is_numeric($did) || $did < 2){
|
||||
$bz = 'dzz';
|
||||
}
|
||||
if (!$data['ext'] || $bz != 'dzz') {
|
||||
return '';
|
||||
}
|
||||
$videoexts = getglobal('config/pichomeffmpegconvertext') ? getglobal('config/pichomeffmpegconvertext'):'avi,rm,rmvb,mkv,mov,wmv,asf,mpg,mpe,mpeg,mp4,m4v,mpeg,f4v,vob,ogv,mts,m2ts,3gp,webm,flv,wav,mp3,ogg,midi,wma,vqf,ra,aac,flac,ape,amr,aiff,au,m4a';
|
||||
$videoarr = explode(',',$videoexts);
|
||||
$pexts= getglobal('config/pichomeplayermediaext') ? explode(',', getglobal('config/pichomeplayermediaext')):array('mp3','mp4','webm','ogv','ogg','wav','m3u8','hls','mpg','mpeg');
|
||||
if (in_array($data['ext'],$pexts) || !in_array($data['ext'],$videoarr)) {
|
||||
return '';
|
||||
} else {
|
||||
class convert
|
||||
{
|
||||
|
||||
$videodata= DB::fetch_first('select mediastatus,videoquality from %t where bz = %s',array('connect_storage',$bz));
|
||||
if(!$videodata['mediastatus']) return '';
|
||||
if ('audio' == getTypeByExt($data['ext'])) {
|
||||
$ext = 'mp3';
|
||||
} else {
|
||||
$ext = 'webm';
|
||||
}
|
||||
$setarr = ['rid' => $data['rid'], 'format' => $ext, 'dateline' => TIMESTAMP, 'videoquality' => $videodata['videoquality']];
|
||||
$ff = C::t('video_record')->insert($setarr);
|
||||
if($ff['id']) return false;
|
||||
//if ($force) dfsockopen(getglobal('localurl') . 'index.php?mod=ffmpeg&op=convert&id=' . $ff['id'], 0, '', '', false, '', 0.1);
|
||||
}
|
||||
}
|
||||
public function run($data, $force = false)
|
||||
{
|
||||
|
||||
//如果是普通目录
|
||||
$app = C::t('app_market')->fetch_by_identifier('ffmpeg', 'dzz');
|
||||
$appextra = unserialize($app['extra']);
|
||||
// if (!$appextra['status']) return true;
|
||||
$exts = $appextra['exts'] ? explode(',', $appextra['exts']) : array();
|
||||
//如果类型不符合则停止执行
|
||||
if ($exts && !in_array($data['ext'], $exts)) return true;
|
||||
$videoexts = $appextra ? getglobal('config/pichomeffmpegconvertext') : 'avi,rm,rmvb,mkv,mov,wmv,asf,mpg,mpe,mpeg,mp4,m4v,mpeg,f4v,vob,ogv,mts,m2ts,3gp,webm,flv,wav,mp3,ogg,midi,wma,vqf,ra,aac,flac,ape,amr,aiff,au,m4a';
|
||||
$videoarr = explode(',', $videoexts);
|
||||
$pexts = getglobal('config/pichomeplayermediaext') ? explode(',', getglobal('config/pichomeplayermediaext')) : array('mp3', 'mp4', 'webm', 'ogv', 'ogg', 'wav', 'm3u8', 'hls', 'mpg', 'mpeg');
|
||||
if (in_array($data['ext'], $pexts) || !in_array($data['ext'], $videoarr)) {
|
||||
return '';
|
||||
} else {
|
||||
|
||||
if ('audio' == getTypeByExt($data['ext'])) {
|
||||
$ext = 'mp3';
|
||||
} else {
|
||||
$ext = 'webm';
|
||||
}
|
||||
$setarr = ['rid' => $data['rid'], 'dateline' => TIMESTAMP, 'ctype' => 0,'format'=>$ext,'videoquality'=>0];
|
||||
$setarr['aid']= $data['aid'] ? $data['aid']:0;
|
||||
$ff = C::t('video_record')->insert_data($setarr);
|
||||
if ($ff['id']) return false;
|
||||
//if ($force) dfsockopen(getglobal('localurl') . 'index.php?mod=ffmpeg&op=convert&id=' . $ff['id'], 0, '', '', false, '', 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,38 +10,51 @@ class info
|
||||
|
||||
public function run($data)
|
||||
{
|
||||
if(strpos($data['realpath'],':') === false){
|
||||
$bz = 'dzz';
|
||||
}else{
|
||||
$patharr = explode(':', $data['realpath']);
|
||||
$bz = $patharr[0];
|
||||
$did = $patharr[1];
|
||||
$app = C::t('app_market')->fetch_by_identifier('ffmpeg', 'dzz');
|
||||
$extra = unserialize($app['extra']);
|
||||
|
||||
}
|
||||
if(!is_numeric($did) || $did < 2){
|
||||
$bz = 'dzz';
|
||||
}
|
||||
if(!$data['ext'] || $bz != 'dzz' || !in_array($data['ext'],explode(',',getglobal('config/pichomeffmpeggetvieoinfoext')))){
|
||||
|
||||
if (!$extra['status']) {
|
||||
return '';
|
||||
}
|
||||
$videostatus = DB::result_first('select mediastatus from %t where bz = %s',array('connect_storage',$bz));
|
||||
if(!$videostatus) return '';
|
||||
require_once DZZ_ROOT . './dzz/ffmpeg/class/class_fmpeg.php';
|
||||
try {
|
||||
if ($info = fmpeg::getInfo($data)) {
|
||||
|
||||
if (isset($info['duration'])) C::t('pichome_resources_attr')->update($data['rid'], array('duration' => $info['duration']));
|
||||
if (isset($info['width'])) C::t('pichome_resources')->update($data['rid'], array('width' => $info['width'], 'height' => $info['height']));
|
||||
C::t('pichome_resources_attr')->update($data['rid'],array('isget'=>1));
|
||||
return false;
|
||||
}else{
|
||||
$exts = $extra['exts_info'] ? explode(',', $extra['exts_info']) : array();
|
||||
|
||||
//如果类型不符合则停止执行
|
||||
if (!in_array($data['ext'], $exts)) return '';
|
||||
|
||||
//如果路径为数字视为pichome库
|
||||
$cachepath = ($data['aid']) ? intval($data['aid']):($data['rid'] ? $data['rid'] :md5($data['path']));
|
||||
if($infodata = C::t('ffmpegimage_cache')->fetch_by_path($cachepath)){
|
||||
$info = unserialize($infodata);
|
||||
if (isset($info['duration'])) C::t('pichome_resources_attr')->update($data['rid'], array('duration' => $info['duration']));
|
||||
if (isset($info['width'])) C::t('pichome_resources')->update($data['rid'], array('width' => $info['width'], 'height' => $info['height']));
|
||||
C::t('pichome_resources_attr')->update($data['rid'],array('isget'=>1));
|
||||
return false;
|
||||
}else{
|
||||
require_once DZZ_ROOT . './dzz/ffmpeg/class/class_fmpeg.php';
|
||||
try {
|
||||
if ($info = fmpeg::getInfo($data)) {
|
||||
$cachearr = [
|
||||
'info'=>serialize($info),
|
||||
'path'=>$cachepath,
|
||||
'dateline'=>TIMESTAMP
|
||||
];
|
||||
C::t('ffmpegimage_cache')->insert($cachearr);
|
||||
if (isset($info['duration'])) C::t('pichome_resources_attr')->update($data['rid'], array('duration' => $info['duration']));
|
||||
if (isset($info['width'])) C::t('pichome_resources')->update($data['rid'], array('width' => $info['width'], 'height' => $info['height']));
|
||||
C::t('pichome_resources_attr')->update($data['rid'],array('isget'=>1));
|
||||
return false;
|
||||
}else{
|
||||
C::t('pichome_resources_attr')->update($data['rid'],array('isget'=>-1));
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
runlog('ffmpeg', $e->getMessage() . 'rid:' . $data['rid']);
|
||||
C::t('pichome_resources_attr')->update($data['rid'],array('isget'=>-1));
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
runlog('ffmpeg', $e->getMessage() . 'rid:' . $data['rid']);
|
||||
C::t('pichome_resources_attr')->update($data['rid'],array('isget'=>-1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,50 +6,47 @@ use \core as C;
|
||||
use \fmpeg as fmpeg;
|
||||
use \IO as IO;
|
||||
use \DB as DB;
|
||||
|
||||
class thumb
|
||||
{
|
||||
|
||||
public function run(&$data)
|
||||
{
|
||||
if(strpos($data['realpath'],':') === false){
|
||||
$bz = 'dzz';
|
||||
}else{
|
||||
$patharr = explode(':', $data['realpath']);
|
||||
$bz = $patharr[0];
|
||||
$did = $patharr[1];
|
||||
|
||||
}
|
||||
if(!is_numeric($did) || $did < 2){
|
||||
$bz = 'dzz';
|
||||
}
|
||||
$exts = explode(',',getglobal('config/pichomeffmpeggetthumbext'));
|
||||
$app = C::t('app_market')->fetch_by_identifier('ffmpeg', 'dzz');
|
||||
$extra = unserialize($app['extra']);
|
||||
|
||||
if(!$data['ext'] || $bz != 'dzz' || !in_array($data['ext'],$exts)){
|
||||
|
||||
if (!$extra['status']) {
|
||||
return '';
|
||||
}
|
||||
$exts = $extra['exts_thumb'] ? explode(',', $extra['exts_thumb']) : array();
|
||||
|
||||
//如果类型不符合则停止执行
|
||||
if (!in_array($data['ext'], $exts)) return '';
|
||||
|
||||
$videostatus = DB::result_first('select mediastatus from %t where bz = %s',array('connect_storage',$bz));
|
||||
if(!$videostatus) return '';
|
||||
require_once DZZ_ROOT . './dzz/ffmpeg/class/class_fmpeg.php';
|
||||
$fm = new fmpeg();
|
||||
if ($data['Duration']) {
|
||||
$start = ceil($data['duration'] / 5);
|
||||
} else {
|
||||
$start = 1;
|
||||
$start = 0;
|
||||
}
|
||||
//执行获取缩略图
|
||||
if ($target = $fm->getThumb($data, $start)) {
|
||||
if ($imginfo = getimagesize($target)) {
|
||||
$fileuri = IO::getStream($target);
|
||||
if ($imginfo = getimagesize($fileuri)) {
|
||||
//将缩略图宽高视为文件宽高
|
||||
$resourcesarr = [
|
||||
'width' => $imginfo[0] ? $imginfo[0]:0,
|
||||
'height' =>$imginfo[1] ? $imginfo[1]:0
|
||||
'width' => $imginfo[0] ? $imginfo[0] : 0,
|
||||
'height' => $imginfo[1] ? $imginfo[1] : 0
|
||||
];
|
||||
C::t('pichome_resources')->update($data['rid'],$resourcesarr);
|
||||
C::t('pichome_resources')->update($data['rid'], array('hasthumb' => 1));
|
||||
C::t('pichome_resources')->update($data['rid'], $resourcesarr);
|
||||
return array($target);
|
||||
}else{
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user