zhiyicx / thinksns-old-code Goto Github PK
View Code? Open in Web Editor NEWThinkSNS-4版本的老代码
License: MIT License
ThinkSNS-4版本的老代码
License: MIT License
在 VideoModel.class.php
的 video_transfer
方法中:
public function video_transfer()
{
$video_list = D('video_transfer')->where('status=0')->order('transfer_id Asc')->limit(3)->findAll();
// dump($video_list);exit;
if ($video_list) {
set_time_limit(0);
$video_config = model('Xdata')->get('admin_Content:video_config');
if (PATH_SEPARATOR == ':') { //Linux
$ffmpegpath = $video_config['ffmpeg_path'];
} else { //Windows
$ffmpegpath = SITE_PATH.$video_config['ffmpeg_path'];
}
foreach ($video_list as $k => $v) {
if (file_exists(SITE_PATH.$v['sourceSavePath'].'/'.$v['video_source_name'])) {
$sourceSavePath = SITE_PATH.$v['sourceSavePath'];
$savePath = SITE_PATH.$v['savePath'];
$command = $ffmpegpath.' -y -i '.$sourceSavePath.'/'.$v['video_source_name'].' -vcodec libx264 '.$savePath.'/'.$v['video_name'];
exec($command);
if (file_exists($savePath.'/'.$v['video_name'])) {
D('video_transfer')->where('transfer_id='.$v['transfer_id'])->setField('status', 1);
$feed_id = D('video_transfer')->where('transfer_id='.$v['transfer_id'])->getField('feed_id');
model('Feed')->cleanCache(array($feed_id));
}
} else {
continue;
}
}
}
}
如果删除原始视频为止会造成任务一直卡在这里,因为这个转换任务一直存在。如果转换失败,同理也会一直卡在这里。
video_transfer
增加 转换中状态,现在只有 status
标识 是否在转换,增加 transforming
查询是否已经在转换中。首先查询出所有超过一天 transforming
状态的转换记录,删除,然后查询出 非 transforming
状态 但是 status
为 0 的记录(可能三条),判断这条记录是否超过一天,超过删除,再判断原始文件是否存在,不存在删除,最后判断分片文件是否存在,存在则设置 status
为 1 和 transforming
设置为转换完成状态,如果分片不存在,则执行命令,开始转换视频,同时将该记录的 transforming
设置在正在转换状态,以免下次执行计划任务依旧查询出来。
建议重新编辑 转换视频 的计划任务,将任务时间设置为 null 或者 空,或者 000-00-00 00:00:00 达到任务不过期。现在出现的问题是,默认三个任务,有两个任务已经过期了,计划任务不会执行。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.