|
@@ -839,159 +839,161 @@ s.resp.generate_scroll_video = function(template_tab,fd)
|
|
|
return isOk,error_info
|
|
|
end
|
|
|
--生成解压视频数据库
|
|
|
-s.resp.generate_video = function(msg_body,fd)
|
|
|
- s.resp.get_template_info_by_id(msg_body,nil,function(tab)
|
|
|
- -- tools.dump(tab)
|
|
|
- if tab ~=nil then
|
|
|
- local isOk,error_info = s.resp.check_template_isRight(tab)
|
|
|
- if tab.video_stype == 1 then --解压
|
|
|
- if not isOk then
|
|
|
- return tools.response(fd,200,error_info)
|
|
|
- end
|
|
|
- else
|
|
|
- isOk,error_info = s.resp.check_template_scroll_isRight(tab)
|
|
|
- if not isOk then
|
|
|
- return tools.response(fd,200,error_info)
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
+s.resp.generate_video = function(_msg_body,_fd)
|
|
|
+ skynet.fork(function(msg_body,fd)
|
|
|
+ s.resp.get_template_info_by_id(msg_body,nil,function(tab)
|
|
|
-- tools.dump(tab)
|
|
|
- local user_id = msg_body.user_id
|
|
|
- local template_id = msg_body.template_id
|
|
|
- local file_name = tab.book_name
|
|
|
- local video_stype = tab.video_stype
|
|
|
- --先查找是否有这个名的文件夹
|
|
|
- local sql = string.format("SELECT * FROM generate_video_folder_list_tab WHERE user_id = %d AND book_name = '%s' AND video_stype = %d ",user_id,file_name,video_stype)
|
|
|
- local res = db:query(sql)
|
|
|
- local info = tools.getDbResData(res)
|
|
|
- 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
|
|
|
- end
|
|
|
- local custom = {}
|
|
|
- if template_info.custom~=nil and template_info.custom~="" then
|
|
|
- custom = template_info.custom
|
|
|
+ if tab ~=nil then
|
|
|
+ local isOk,error_info = s.resp.check_template_isRight(tab)
|
|
|
+ if tab.video_stype == 1 then --解压
|
|
|
+ if not isOk then
|
|
|
+ return tools.response(fd,200,error_info)
|
|
|
+ end
|
|
|
+ else
|
|
|
+ isOk,error_info = s.resp.check_template_scroll_isRight(tab)
|
|
|
+ if not isOk then
|
|
|
+ return tools.response(fd,200,error_info)
|
|
|
+ end
|
|
|
end
|
|
|
- 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,background_image = s.resp.parse_template_info(tab,item_info)
|
|
|
- -- tools.dump(head_video)
|
|
|
- -- tools.dump(content_video)
|
|
|
- -- tools.dump(end_video)
|
|
|
- -- tools.dump(bgm_audio)
|
|
|
- local is_corner_mark = item_info.is_corner_mark
|
|
|
- local is_video_bottom_text = item_info.is_video_bottom_text
|
|
|
- local hot_tag_type = 0
|
|
|
- local item_custom = {}
|
|
|
-
|
|
|
- if item_info.custom~=nil and item_info.custom~="" then
|
|
|
- item_custom = item_info.custom
|
|
|
+
|
|
|
+ -- tools.dump(tab)
|
|
|
+ local user_id = msg_body.user_id
|
|
|
+ local template_id = msg_body.template_id
|
|
|
+ local file_name = tab.book_name
|
|
|
+ local video_stype = tab.video_stype
|
|
|
+ --先查找是否有这个名的文件夹
|
|
|
+ local sql = string.format("SELECT * FROM generate_video_folder_list_tab WHERE user_id = %d AND book_name = '%s' AND video_stype = %d ",user_id,file_name,video_stype)
|
|
|
+ local res = db:query(sql)
|
|
|
+ local info = tools.getDbResData(res)
|
|
|
+ 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
|
|
|
-
|
|
|
-
|
|
|
- if is_corner_mark then
|
|
|
- hot_tag_type = 1
|
|
|
+ -- tools.dump(template_info)
|
|
|
+ local gen_num = 0
|
|
|
+ if template_info.creat_video_list~=nil then
|
|
|
+ gen_num = #template_info.creat_video_list
|
|
|
end
|
|
|
-
|
|
|
- local fictitious_tag_type = 0
|
|
|
- if is_video_bottom_text then
|
|
|
- fictitious_tag_type = 1
|
|
|
+ local custom = {}
|
|
|
+ if template_info.custom~=nil and template_info.custom~="" then
|
|
|
+ custom = template_info.custom
|
|
|
end
|
|
|
- local gen_info = {user_id=0,id=0,project_name=tab.project_name,
|
|
|
- book_name=tab.book_name,
|
|
|
- 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=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 },
|
|
|
- video_last_frame =end_video[1] or {},
|
|
|
- video_first_frame = head_video[1] or {},
|
|
|
- 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,
|
|
|
- video_custom = item_custom,
|
|
|
- }
|
|
|
-
|
|
|
- local video_name = gen_info.book_name.."__视频"..i
|
|
|
- local book_name = gen_info.book_name
|
|
|
- local ratio = gen_info.ratio
|
|
|
- local video_stype = gen_info.video_stype
|
|
|
- local video_url = ""
|
|
|
- local generate_video_info = {}
|
|
|
- generate_video_info =item_info
|
|
|
- generate_video_info.book_name = tab.book_name
|
|
|
- generate_video_info.project_name = tab.project_name
|
|
|
- generate_video_info.ratio = tab.ratio
|
|
|
- generate_video_info.video_stype = tab.video_stype
|
|
|
- generate_video_info = cjson.encode(generate_video_info)
|
|
|
- local video_state = 0
|
|
|
- sql = string.format("INSERT INTO generate_video_list_tab (user_id,template_id, folder_id,video_name,book_name,ratio,video_stype,video_url,video_state,generate_video_info) VALUES (%d,%d,%d,'%s','%s',%d,%d,'%s',%d,'%s')",user_id,
|
|
|
- template_id,
|
|
|
- folder_id,
|
|
|
- video_name,
|
|
|
- book_name,
|
|
|
- ratio,
|
|
|
- video_stype,
|
|
|
- video_url,video_state,cjson.encode({data=tools.base64encode(generate_video_info)}))
|
|
|
- -- skynet.error("123sss")
|
|
|
- -- tools.dump(gen_info)
|
|
|
- db:query(sql)
|
|
|
- -- skynet.error(sql)
|
|
|
- sql = string.format("SELECT * FROM generate_video_list_tab WHERE user_id = %d and folder_id = %d and is_use = 0 LIMIT 1",user_id,folder_id)
|
|
|
- res = db:query(sql)
|
|
|
- if res and #res > 0 then
|
|
|
- local tab = {}
|
|
|
- if #res > 0 then
|
|
|
- tab = tools.getDbResData(res)
|
|
|
- gen_info.id = tab.id
|
|
|
- gen_info.user_id = user_id
|
|
|
- sql = string.format("UPDATE generate_video_list_tab SET is_use = %d WHERE id =%d",1,gen_info.id)
|
|
|
- db:query(sql)
|
|
|
- skynet.send("tools_work","lua","generate_video",gen_info)
|
|
|
+ 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,background_image = s.resp.parse_template_info(tab,item_info)
|
|
|
+ -- tools.dump(head_video)
|
|
|
+ -- tools.dump(content_video)
|
|
|
+ -- tools.dump(end_video)
|
|
|
+ -- tools.dump(bgm_audio)
|
|
|
+ local is_corner_mark = item_info.is_corner_mark
|
|
|
+ local is_video_bottom_text = item_info.is_video_bottom_text
|
|
|
+ local hot_tag_type = 0
|
|
|
+ local item_custom = {}
|
|
|
+
|
|
|
+ if item_info.custom~=nil and item_info.custom~="" then
|
|
|
+ item_custom = item_info.custom
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ if is_corner_mark then
|
|
|
+ hot_tag_type = 1
|
|
|
end
|
|
|
- -- return true,tab
|
|
|
- else
|
|
|
- skynet.error("No data found.")
|
|
|
+
|
|
|
+ local fictitious_tag_type = 0
|
|
|
+ if is_video_bottom_text then
|
|
|
+ fictitious_tag_type = 1
|
|
|
+ end
|
|
|
+ local gen_info = {user_id=0,id=0,project_name=tab.project_name,
|
|
|
+ book_name=tab.book_name,
|
|
|
+ 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=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 },
|
|
|
+ video_last_frame =end_video[1] or {},
|
|
|
+ video_first_frame = head_video[1] or {},
|
|
|
+ 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,
|
|
|
+ video_custom = item_custom,
|
|
|
+ }
|
|
|
+
|
|
|
+ local video_name = gen_info.book_name.."__视频"..i
|
|
|
+ local book_name = gen_info.book_name
|
|
|
+ local ratio = gen_info.ratio
|
|
|
+ local video_stype = gen_info.video_stype
|
|
|
+ local video_url = ""
|
|
|
+ local generate_video_info = {}
|
|
|
+ generate_video_info =item_info
|
|
|
+ generate_video_info.book_name = tab.book_name
|
|
|
+ generate_video_info.project_name = tab.project_name
|
|
|
+ generate_video_info.ratio = tab.ratio
|
|
|
+ generate_video_info.video_stype = tab.video_stype
|
|
|
+ generate_video_info = cjson.encode(generate_video_info)
|
|
|
+ local video_state = 0
|
|
|
+ sql = string.format("INSERT INTO generate_video_list_tab (user_id,template_id, folder_id,video_name,book_name,ratio,video_stype,video_url,video_state,generate_video_info) VALUES (%d,%d,%d,'%s','%s',%d,%d,'%s',%d,'%s')",user_id,
|
|
|
+ template_id,
|
|
|
+ folder_id,
|
|
|
+ video_name,
|
|
|
+ book_name,
|
|
|
+ ratio,
|
|
|
+ video_stype,
|
|
|
+ video_url,video_state,cjson.encode({data=tools.base64encode(generate_video_info)}))
|
|
|
+ -- skynet.error("123sss")
|
|
|
+ -- tools.dump(gen_info)
|
|
|
+ db:query(sql)
|
|
|
+ -- skynet.error(sql)
|
|
|
+ sql = string.format("SELECT * FROM generate_video_list_tab WHERE user_id = %d and folder_id = %d and is_use = 0 LIMIT 1",user_id,folder_id)
|
|
|
+ res = db:query(sql)
|
|
|
+ if res and #res > 0 then
|
|
|
+ local tab = {}
|
|
|
+ if #res > 0 then
|
|
|
+ tab = tools.getDbResData(res)
|
|
|
+ gen_info.id = tab.id
|
|
|
+ gen_info.user_id = user_id
|
|
|
+ sql = string.format("UPDATE generate_video_list_tab SET is_use = %d WHERE id =%d",1,gen_info.id)
|
|
|
+ db:query(sql)
|
|
|
+ skynet.send("tools_work","lua","generate_video",gen_info)
|
|
|
+ end
|
|
|
+ -- return true,tab
|
|
|
+ else
|
|
|
+ skynet.error("No data found.")
|
|
|
+ end
|
|
|
+
|
|
|
end
|
|
|
-
|
|
|
+
|
|
|
+ --获取5个未使用的生成视频文件
|
|
|
+ tools.response_db_generate_video(fd,true)
|
|
|
end
|
|
|
-
|
|
|
- --获取5个未使用的生成视频文件
|
|
|
- tools.response_db_generate_video(fd,true)
|
|
|
- end
|
|
|
- if res and #res > 0 then --存在这个文件夹,直接写入到这个文件夹
|
|
|
- local folder_id = info.id
|
|
|
- write_video_db(folder_id)
|
|
|
- else -- 没有这个文件夹则创建一个
|
|
|
- sql = string.format("INSERT INTO generate_video_folder_list_tab (user_id,book_name, generate_video_info,video_stype) VALUES (%d, '%s','%s' ,%d)",user_id,file_name,"{}",video_stype)
|
|
|
- db:query(sql)
|
|
|
- --查找新建的文件夹id
|
|
|
- sql = string.format("SELECT * FROM generate_video_folder_list_tab WHERE user_id = %d AND book_name = '%s' AND video_stype = %d ",user_id,file_name,video_stype)
|
|
|
- res = db:query(sql)
|
|
|
-
|
|
|
- info = tools.getDbResData(res)
|
|
|
- local folder_id = info.id
|
|
|
- write_video_db(folder_id)
|
|
|
+ if res and #res > 0 then --存在这个文件夹,直接写入到这个文件夹
|
|
|
+ local folder_id = info.id
|
|
|
+ write_video_db(folder_id)
|
|
|
+ else -- 没有这个文件夹则创建一个
|
|
|
+ sql = string.format("INSERT INTO generate_video_folder_list_tab (user_id,book_name, generate_video_info,video_stype) VALUES (%d, '%s','%s' ,%d)",user_id,file_name,"{}",video_stype)
|
|
|
+ db:query(sql)
|
|
|
+ --查找新建的文件夹id
|
|
|
+ sql = string.format("SELECT * FROM generate_video_folder_list_tab WHERE user_id = %d AND book_name = '%s' AND video_stype = %d ",user_id,file_name,video_stype)
|
|
|
+ res = db:query(sql)
|
|
|
+
|
|
|
+ info = tools.getDbResData(res)
|
|
|
+ local folder_id = info.id
|
|
|
+ write_video_db(folder_id)
|
|
|
+ end
|
|
|
+
|
|
|
end
|
|
|
-
|
|
|
- end
|
|
|
- end)
|
|
|
+ end)
|
|
|
+ end,_msg_body,_fd)
|
|
|
return true
|
|
|
end
|
|
|
|
|
@@ -1563,6 +1565,7 @@ s.resp.get_user_file_count_by_type = function(msg_body)
|
|
|
end
|
|
|
|
|
|
s.resp.check_file_name_list_is_repeat_by_folder_id = function(msg_body,fd,call_back)
|
|
|
+ -- tools.dump(msg_body)
|
|
|
skynet.fork(function()
|
|
|
local nameString = ""
|
|
|
for i = 1, #msg_body.file_name_list, 1 do
|