短视频矩阵源码(NGINX,PHP7.4,MySQL5.7,redis)
$this->showAjaxResult($ret, '保存');
}
/*
* 保存场景
*/
public function saveSceneAction() {
$dv_id = $this->request->getIntParam('dv_id');
$scene = $this->request->getIntParam('scene');
if ($scene < 3 || $scene > 60) {
$this->displayJsonError('场景数,需介于3-60');
}
$video_model= new App_Model_Douyin_MysqlVideoStorage();
$video_item = $video_model->getRowByIdSid($dv_id, $this->sid);
if (empty($video_item)) {
$this->displayJsonError('参数错误');
}
$updata = [
'dv_video_use' => $scene,
];
$ret = $video_model->updateById($updata, $dv_id);
//更改场景组合数,则需要重新生成组合
if($video_item['dv_video_use'] != $scene){
//清空素材排列组合及缓存视频
$VideoMaterialPailie_model = new App_Model_Douyin_MysqlVideoMaterialPailieStorage();
$VideoMaterialPailie_model->clearPailie($dv_id);
//减少场景时清除视频素材
if ($scene < $video_item['dv_video_use']) {
//清除素材
$video_meta_model = new App_Model_Douyin_MysqlVideoMaterialStorage();
$vm_where = [
['name' => 'dvm_ds_id', 'oper' => '=', 'value' => $this->sid],
['name' => 'dvm_dv_id', 'oper' => '=', 'value' => $dv_id],
['name' => 'dvm_material_type', 'oper' => '=', 'value' => 1], //视频素材
['name' => 'dvm_scene', 'oper' => '>', 'value' => $scene],
];
$video_meta_list = $video_meta_model->getList($vm_where, 0, 0);
foreach ($video_meta_list as $item) {
$file_path = PLUM_DIR_ROOT.$item['dvm_material_videots'];
if (is_file($file_path)) {
unlink($file_path);
}
$video_meta_model->deleteById($item['dvm_id']);
}
}
}
$this->showAjaxResult($ret, '修改');
}
/*
* 素材类型输出
*/
private function output_materail_type($da_id, $type, $video_mode){
$material_model = new App_Model_Douyin_MysqlVideoMaterialStorage($this->sid);
$template_model = new App_Model_Douyin_MysqlVideoTempVideoStorage($this->sid);
$temp_video_count = $template_model->getTempVideoCountByItem($da_id);
$type_list = [
'video' => [
'type' => 1,
'title' => '视频素材('.($material_model->getMaterialCountByVideo($da_id, 1)).')',
'url' => "/dydqtshoppc/video/materialList?dv_id={$da_id}&type=1",
],
'image' => [
'type' => 3,
短视频矩阵源码的研发需要进一步完善技术架构和开发语言。一般来说,采用NGINX作为服务器,PHP7.4作为主要编程语言,MySQL5.7和redis作为数据库
1.NGINX是一个高性能的开源Web服务器软件,也可用作反向代理、负载均衡器和HTTP缓存。它可以处理高并发量和高流量的网站,且具有可靠性和稳定性。NGINX还支持动态模块化架构,可以通过添加不同的模块来增强其功能。易于配置和使用,是很多企业和网站开发时的首选。
2.MySQL5.7是一款开源的关系型数据库管理系统,具有高效、稳定、安全等特点。它支持多种数据类型、多线程处理、分布式事务、全文索引等功能。同时,MySQL5.7还采用了多种优化技术,如InnoDB引擎、线程池、查询优化器等,提高了系统的性能和稳定性。MySQL5.7适合用于各种规模的应用,可用于Web开发、数据仓库、企业级应用等领域,是一款非常优秀的数据库管理系统。
3.redis是一个高性能的键值对存储系统,常用于缓存、消息队列、排行榜等场景。它支持多种数据结构,如字符串、列表、哈希表、集合和有序集合,并提供了丰富的操作命令,例如:增删改查、过期设置、持久化、事务等。Redis采用内存+磁盘的方式进行数据存储,其内存加速和持久化方式可根据需求自由配置。Redis的高性能和高可用性让其广泛应用于全球许多大型网站和企业中。
短视频矩阵源码开发功能模型:
if (empty($dv_id)) {//新增
$indata = [
'dv_s_id' => $this->sid,
'dv_platform' => json_encode($video_cfg),
'dv_create_time'=> time(),
];
$indata = array_merge($updata, $indata);
$ret = $video_model->insertValue($indata);
} else {//编辑
$video_item = $video_model->getRowByIdSid($dv_id, $this->sid);
if (empty($video_item)) {
$this->displayJsonError('参数错误');
}
$curr_platform = json_decode($video_item['dv_platform'], 1);
$curr_platform = is_null($curr_platform) ? [] : $curr_platform;
$updata['dv_platform'] = json_encode(array_merge($curr_platform, $video_cfg));
$ret = $video_model->updateById($updata, $dv_id);
//切换模式或更改场景组合数,则需要重新生成组合
if($video_item['dv_video_mode'] != $video_mixed || $video_item['dv_video_use'] != $video_use){
//清空素材排列组合及缓存视频
$VideoMaterialPailie_model = new App_Model_Douyin_MysqlVideoMaterialPailieStorage();
$VideoMaterialPailie_model->clearPailie($dv_id);
//清除素材
$video_meta_model = new App_Model_Douyin_MysqlVideoMaterialStorage();
$vm_where = [
['name' => 'dvm_ds_id', 'oper' => '=', 'value' => $this->sid],
['name' => 'dvm_dv_id', 'oper' => '=', 'value' => $dv_id],
];
$video_meta_list = $video_meta_model->getList($vm_where, 0, 0);
foreach ($video_meta_list as $item) {
//新旧模式相同,并且视频对应场景不大于新的场景数
if ($item['dvm_video_mixed_mode'] == $video_mixed && $item['dvm_scene'] <= $video_use) {
continue;
//与新模式不同,则清除
}
//场景顺序组合,减少了场景数
/*
if ($item['dvm_scene'] > $video_use) {
}
*/
//智能混剪模式1,删除视频素材
if ($item['dvm_video_mixed_mode'] == 1 && $item['dvm_material_type'] == 1) {
$file_path = PLUM_DIR_ROOT.$item['dvm_material_content'];
if (is_file($file_path)) {
unlink($file_path);
}
}