|
@@ -13,6 +13,7 @@ s.resp.parse_template_info = function(info,template_info)
|
|
|
local video_crop_time = info.video_crop_time
|
|
|
local ratio = info.ratio
|
|
|
local user_id = info.user_id
|
|
|
+ local video_stype = info.video_stype
|
|
|
-- skynet.error("(info.template_info",info.template_info)
|
|
|
-- if template_info.piantou_video_data.is_random then --说明选择的是随机
|
|
|
-- local folder_list = template_info.piantou_video_data.random_folder_list
|
|
@@ -50,10 +51,12 @@ s.resp.parse_template_info = function(info,template_info)
|
|
|
-- end
|
|
|
-- end
|
|
|
|
|
|
- if template_info.piantou_video_data.select_video_file~=nil then
|
|
|
- local data = template_info.piantou_video_data.select_video_file
|
|
|
- table.insert(head_video,1,{video_id =data.info.id,path =data.info.path,duration=data.info.duration,info=data })
|
|
|
- -- table.insert(head_video,1,data)
|
|
|
+ if video_stype ==1 then
|
|
|
+ if template_info.piantou_video_data.select_video_file~=nil then
|
|
|
+ local data = template_info.piantou_video_data.select_video_file
|
|
|
+ table.insert(head_video,1,{video_id =data.info.id,path =data.info.path,duration=data.info.duration,info=data })
|
|
|
+ -- table.insert(head_video,1,data)
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
if #head_video <= 0 then
|
|
@@ -62,68 +65,69 @@ s.resp.parse_template_info = function(info,template_info)
|
|
|
|
|
|
--内容
|
|
|
local content_video = {}
|
|
|
- local json_info = cjson.decode(info.template_info)
|
|
|
- -- skynet.error("json_info.subtitles_audio_duration",json_info.subtitles_audio_duration)
|
|
|
- -- skynet.error("head_video[1]",head_video[1].duration)
|
|
|
- -- tools.dump(json_info.subtitles_audio_duration)
|
|
|
- -- skynet.error("head_video[1]",head_video[1].info)
|
|
|
- -- tools.dump(head_video[1].info)
|
|
|
- local need_num = math.floor((json_info.subtitles_audio_duration - head_video[1].duration) / (video_crop_time)) +1
|
|
|
- if template_info.content_video_data.is_random then --说明选择的是随机
|
|
|
- local folder_list = template_info.content_video_data.random_folder_list
|
|
|
- if folder_list ==nil or #folder_list ==0 then
|
|
|
- --说明选择的全部随机
|
|
|
- local isOk,list = s.resp.get_random_res_by_type(user_id,2,ratio,(video_crop_time+5))
|
|
|
- if not isOk then
|
|
|
- return skynet.error("缺少内容资源!")
|
|
|
- else
|
|
|
- skynet.error("need_num",need_num)
|
|
|
- if need_num>#list then
|
|
|
- skynet.error("缺少内容资源!")
|
|
|
- end
|
|
|
- local random_array = tools.getRandomArray(list)
|
|
|
- -- skynet.error("random_array")
|
|
|
- -- tools.dump(random_array)
|
|
|
- for i = 1, need_num, 1 do
|
|
|
- local random_index = random_array[i]
|
|
|
- table.insert(content_video,i,{video_id =list[random_index].id,path =cjson.decode( list[random_index].file_info).path,duration=list[random_index].duration,info = list[random_index].file_info })
|
|
|
- -- table.insert(content_video,i,list[random_index].file_info)
|
|
|
- end
|
|
|
- end
|
|
|
- else -- 说明选择了指定文件夹随机
|
|
|
- local isOk,list = s.resp.get_random_res_by_folder_list(2,ratio,folder_list,(video_crop_time+5),user_id)
|
|
|
- if not isOk then
|
|
|
- return skynet.error("缺少内容资源!")
|
|
|
- else
|
|
|
- if need_num>#list then
|
|
|
- skynet.error("缺少内容资源!")
|
|
|
- end
|
|
|
- local random_array = tools.getRandomArray(list)
|
|
|
- for i = 1, need_num, 1 do
|
|
|
- local random_index = random_array[i]
|
|
|
- table.insert(content_video,i,{video_id =list[random_index].id,path =cjson.decode( list[random_index].file_info).path,duration=list[random_index].duration ,info = list[random_index].file_info})
|
|
|
- -- table.insert(content_video,i,list[random_index].file_info)
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
- else
|
|
|
- if template_info.content_video_data.is_specified then --说明是指定了文件
|
|
|
- local specified_res_list = template_info.content_video_data.specified_res_list
|
|
|
- if #specified_res_list<need_num then
|
|
|
- skynet.error("指定文件缺少",need_num)
|
|
|
- else
|
|
|
- for i = 1, #specified_res_list, 1 do
|
|
|
- local isok,item = s.resp.get_res_file_by_id(specified_res_list[1].file_id)
|
|
|
- if isok then
|
|
|
- -- table.insert(content_video,i, item.file_info)
|
|
|
- table.insert(head_video,i,{video_id =item.id,path =cjson.decode( item.file_info).path,duration=item.duration,info = item.file_info})
|
|
|
+
|
|
|
+ if video_stype ==1 then
|
|
|
+ local json_info = cjson.decode(info.template_info)
|
|
|
+ json_info = tools.base64decode(json_info.data)
|
|
|
+ json_info = cjson.decode(json_info)
|
|
|
+ local need_num = math.floor((json_info.subtitles_audio_duration - head_video[1].duration) / (video_crop_time)) +1
|
|
|
+ if template_info.content_video_data.is_random then --说明选择的是随机
|
|
|
+ local folder_list = template_info.content_video_data.random_folder_list
|
|
|
+ if folder_list ==nil or #folder_list ==0 then
|
|
|
+ --说明选择的全部随机
|
|
|
+ local isOk,list = s.resp.get_random_res_by_type(user_id,2,ratio,(video_crop_time+5))
|
|
|
+ if not isOk then
|
|
|
+ return skynet.error("缺少内容资源!")
|
|
|
+ else
|
|
|
+ skynet.error("need_num",need_num)
|
|
|
+ if need_num>#list then
|
|
|
+ skynet.error("缺少内容资源!")
|
|
|
+ end
|
|
|
+ local random_array = tools.getRandomArray(list)
|
|
|
+ -- skynet.error("random_array")
|
|
|
+ -- tools.dump(random_array)
|
|
|
+ for i = 1, need_num, 1 do
|
|
|
+ local random_index = random_array[i]
|
|
|
+ table.insert(content_video,i,{video_id =list[random_index].id,path =cjson.decode( list[random_index].file_info).path,duration=list[random_index].duration,info = list[random_index].file_info })
|
|
|
+ -- table.insert(content_video,i,list[random_index].file_info)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ else -- 说明选择了指定文件夹随机
|
|
|
+ local isOk,list = s.resp.get_random_res_by_folder_list(2,ratio,folder_list,(video_crop_time+5),user_id)
|
|
|
+ if not isOk then
|
|
|
+ return skynet.error("缺少内容资源!")
|
|
|
+ else
|
|
|
+ if need_num>#list then
|
|
|
+ skynet.error("缺少内容资源!")
|
|
|
+ end
|
|
|
+ local random_array = tools.getRandomArray(list)
|
|
|
+ for i = 1, need_num, 1 do
|
|
|
+ local random_index = random_array[i]
|
|
|
+ table.insert(content_video,i,{video_id =list[random_index].id,path =cjson.decode( list[random_index].file_info).path,duration=list[random_index].duration ,info = list[random_index].file_info})
|
|
|
+ -- table.insert(content_video,i,list[random_index].file_info)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ else
|
|
|
+ if template_info.content_video_data.is_specified then --说明是指定了文件
|
|
|
+ local specified_res_list = template_info.content_video_data.specified_res_list
|
|
|
+ if #specified_res_list<need_num then
|
|
|
+ skynet.error("指定文件缺少",need_num)
|
|
|
+ else
|
|
|
+ for i = 1, #specified_res_list, 1 do
|
|
|
+ local isok,item = s.resp.get_res_file_by_id(specified_res_list[1].file_id)
|
|
|
+ if isok then
|
|
|
+ -- table.insert(content_video,i, item.file_info)
|
|
|
+ table.insert(head_video,i,{video_id =item.id,path =cjson.decode( item.file_info).path,duration=item.duration,info = item.file_info})
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
+ else
|
|
|
+ skynet.error("参数错误!没有指定随机也没指定固定文件")
|
|
|
end
|
|
|
- else
|
|
|
- skynet.error("参数错误!没有指定随机也没指定固定文件")
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
|
|
|
--片尾
|
|
|
local end_video = {}
|
|
@@ -225,7 +229,14 @@ s.resp.parse_template_info = function(info,template_info)
|
|
|
table.insert(corner,1,{info = data })
|
|
|
-- table.insert(bgm_audio,1,data)
|
|
|
end
|
|
|
- return head_video,content_video,end_video,bgm_audio,bottom,corner
|
|
|
+
|
|
|
+ local background_image = {}
|
|
|
+ if template_info.background_image_data.select_video_file~=nil then
|
|
|
+ local data = template_info.background_image_data.select_video_file
|
|
|
+ table.insert(background_image,1,{info = data })
|
|
|
+ -- table.insert(bgm_audio,1,data)
|
|
|
+ end
|
|
|
+ return head_video,content_video,end_video,bgm_audio,bottom,corner,background_image
|
|
|
end
|
|
|
|
|
|
--根据部门id获取部门列表
|
|
@@ -679,23 +690,10 @@ end
|
|
|
--保存/修改模板
|
|
|
s.resp.save_template = function(msg_body,fd)
|
|
|
local template_info = "{}"
|
|
|
+ -- tools.dump(msg_body)
|
|
|
if msg_body.template_info~="" and msg_body.template_info~=nil then
|
|
|
- template_info = cjson.decode(msg_body.template_info)
|
|
|
- if template_info.creat_video_list~=nil and template_info.creat_video_list~="" then
|
|
|
- if #template_info.creat_video_list >0 then
|
|
|
- for i = 1, #template_info.creat_video_list, 1 do
|
|
|
- if template_info.creat_video_list[i]~=nil then
|
|
|
- if template_info.creat_video_list[i].title_html~=nil then
|
|
|
- template_info.creat_video_list[i].title_html = tools.base64encode(template_info.creat_video_list[i].title_html)
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- template_info = cjson.encode(template_info)
|
|
|
+ template_info = msg_body.template_info
|
|
|
end
|
|
|
-
|
|
|
local sql = string.format("UPDATE template_list_tab SET project_name = '%s' , book_name = '%s' ,ratio = %d, video_stype = %d, subtitles = '%s', subtitles_audio = '%s' ,video_nums = %d, video_crop_time = %d, template_info = '%s' WHERE id = %d ",msg_body.project_name,msg_body.book_name,msg_body.ratio,msg_body.video_stype,msg_body.subtitles,msg_body.subtitles_audio,msg_body.video_nums,msg_body.video_crop_time,template_info,msg_body.template_id)
|
|
|
-- skynet.error("sql",sql)
|
|
|
db:query(sql)
|
|
@@ -851,7 +849,7 @@ s.resp.generate_video = function(msg_body,fd)
|
|
|
return tools.response(fd,200,error_info)
|
|
|
end
|
|
|
else
|
|
|
- isOk,error_info = s.resp.generate_scroll_video(tab,fd)
|
|
|
+ isOk,error_info = s.resp.check_template_scroll_isRight(tab)
|
|
|
if not isOk then
|
|
|
return tools.response(fd,200,error_info)
|
|
|
end
|
|
@@ -869,6 +867,11 @@ s.resp.generate_video = function(msg_body,fd)
|
|
|
local write_video_db = function(folder_id)
|
|
|
skynet.error("开始生成",folder_id)
|
|
|
local template_info = cjson.decode(tab.template_info)
|
|
|
+ if template_info.data~=nil and template_info.data~="" then
|
|
|
+ template_info = tools.base64decode(template_info.data)
|
|
|
+ template_info = cjson.decode(template_info)
|
|
|
+ end
|
|
|
+ -- tools.dump(template_info)
|
|
|
local gen_num = 0
|
|
|
if template_info.creat_video_list~=nil then
|
|
|
gen_num = #template_info.creat_video_list
|
|
@@ -877,11 +880,11 @@ s.resp.generate_video = function(msg_body,fd)
|
|
|
if template_info.custom~=nil and template_info.custom~="" then
|
|
|
custom = template_info.custom
|
|
|
end
|
|
|
- -- skynet.error("custom")
|
|
|
+ skynet.error("gen_num",gen_num)
|
|
|
-- tools.dump(custom)
|
|
|
for i = 1, gen_num, 1 do -- 模拟数据每次生成5条
|
|
|
local item_info = template_info.creat_video_list[i]
|
|
|
- local head_video,content_video,end_video,bgm_audio,bottom,corner = s.resp.parse_template_info(tab,item_info)
|
|
|
+ local head_video,content_video,end_video,bgm_audio,bottom,corner,background_image = s.resp.parse_template_info(tab,item_info)
|
|
|
-- tools.dump(head_video)
|
|
|
-- tools.dump(content_video)
|
|
|
-- tools.dump(end_video)
|
|
@@ -909,7 +912,7 @@ s.resp.generate_video = function(msg_body,fd)
|
|
|
ratio=tab.ratio,
|
|
|
video_stype=tab.video_stype,
|
|
|
crop_time=tab.video_crop_time,
|
|
|
- marketing_title_info={marketing_title_top_h = 0,stroke_h=0,marketing_title=tools.base64decode(item_info.title_html)},
|
|
|
+ marketing_title_info={marketing_title_top_h = 0,stroke_h=0,marketing_title=item_info.title_html},
|
|
|
video_list = content_video,
|
|
|
subtitles = {stype=0,subtitle_font="",subtitles_path=template_info.subtitles_path},
|
|
|
subtitles_audio={path = template_info.subtitles_audio_path,duration=template_info.subtitles_audio_duration },
|
|
@@ -918,6 +921,7 @@ s.resp.generate_video = function(msg_body,fd)
|
|
|
bgm_list = bgm_audio[1],
|
|
|
corner_mark_image = corner[1] or {},
|
|
|
bottom_text_image = bottom[1] or {},
|
|
|
+ background_image = background_image[1] or {},
|
|
|
hot_tag = {type=hot_tag_type,path=""}, --上边
|
|
|
fictitious_tag = {type=fictitious_tag_type,path=""}, --下边
|
|
|
custom = custom,
|
|
@@ -944,7 +948,7 @@ s.resp.generate_video = function(msg_body,fd)
|
|
|
book_name,
|
|
|
ratio,
|
|
|
video_stype,
|
|
|
- video_url,video_state,generate_video_info)
|
|
|
+ video_url,video_state,cjson.encode({data=tools.base64encode(generate_video_info)}))
|
|
|
-- skynet.error("123sss")
|
|
|
-- tools.dump(gen_info)
|
|
|
db:query(sql)
|
|
@@ -1351,7 +1355,9 @@ s.resp.check_template_isRight = function(info)
|
|
|
local subtitles_audio_duration = 0
|
|
|
|
|
|
if info.template_info ~=nil and info.template_info~="" then
|
|
|
- local template_info = cjson.decode(info.template_info)
|
|
|
+ local template_info = cjson.decode(info.template_info)
|
|
|
+ template_info = tools.base64decode(template_info.data)
|
|
|
+ template_info = cjson.decode(template_info)
|
|
|
if template_info.subtitles_audio_duration~=nil then
|
|
|
subtitles_audio_duration = tonumber(template_info.subtitles_audio_duration)
|
|
|
end
|
|
@@ -1575,7 +1581,9 @@ s.resp.check_file_name_list_is_repeat_by_folder_id = function(msg_body,fd,call_b
|
|
|
if #res == 1 then
|
|
|
tab[1] = tools.getDbResData(res)
|
|
|
else
|
|
|
- tab = tools.getDbResData(res)
|
|
|
+ if #res>0 then
|
|
|
+ tab = tools.getDbResData(res)
|
|
|
+ end
|
|
|
end
|
|
|
-- tools.dump(tab)
|
|
|
local normal_file_name_list ={}
|