|
@@ -28,13 +28,34 @@ POOL_SIZE = int(config.getConfigValue("video_extract_pool_size"))
|
|
|
# batch_size
|
|
|
BATCH_SIZE = int(config.getConfigValue("video_extract_batch_size"))
|
|
|
|
|
|
+def generate_transforming_prompt(title):
|
|
|
+ video_transforming_prompt = f"""
|
|
|
+ 视频的标题是: {title}
|
|
|
+ 你是一名视频分析专家,你非常精通视频的内容的总结,我会给出你视频及视频的标题,现在请你进行仔细的视频分析,并按照以下要求进行回答
|
|
|
+ #要求
|
|
|
+ 1.30个以下的中文字符输出视频的选题,选题应该要达到使人能从选题中理解到视频主要想表达的内容,要包含这个视频的关键性内容和亮点内容,并针对你的选题进行关键信息和亮点的详细描述
|
|
|
+ 2.用200个以内的中文字符精简的结构性输出视频的主要内容,需要包含该视频描述的核心事件或观点
|
|
|
+ 3.请严格控制输出的内容能够被正确解析为JSON;
|
|
|
+ output in JSON format with keys:
|
|
|
+ "theme": 选题
|
|
|
+ "summary": 主要内容
|
|
|
+ 你需要注意
|
|
|
+ 1.关注我给出的视频中的主要内容,生成的描述主要面向的是50岁以上的老年人,语言风格要适配用户群体;
|
|
|
+ 2.请针对视频的内容本身输出客观、具象的回答,你的分析必须基于视频内容,不能凭空想象;
|
|
|
+ 2.信息缺失和无法分析理解的部分请你忽略,不能自行编造回答
|
|
|
+ 3.请只描述客观事实,不要加入任何主观评价性语言;请使用专业语言进行回答。不要出现概括性描述、主观猜测,抽象表述
|
|
|
+ 4.语言表达上注意不要使用倒装句、长句、复杂句,尽量使用陈述句、简单句;
|
|
|
+ 直接用json格式直接输出结论,不要做任何其他的解释或说明
|
|
|
+ """
|
|
|
+ return video_transforming_prompt
|
|
|
+
|
|
|
|
|
|
-def download_file(pq_vid, oss_path):
|
|
|
+def download_file(task_id, oss_path):
|
|
|
"""
|
|
|
下载视频文件
|
|
|
"""
|
|
|
video_url = "https://rescdn.yishihui.com/" + oss_path
|
|
|
- file_name = "static/{}.mp4".format(pq_vid)
|
|
|
+ file_name = "static/{}.mp4".format(task_id)
|
|
|
if os.path.exists(file_name):
|
|
|
return file_name
|
|
|
|
|
@@ -185,7 +206,7 @@ class GenerateTextFromVideo(object):
|
|
|
获取处理视频转文本任务
|
|
|
"""
|
|
|
sql = f"""
|
|
|
- select id, file_name
|
|
|
+ select id, file_name, video_ori_title
|
|
|
from video_content_understanding
|
|
|
where upload_status = {const.SUCCESS_STATUS} and understanding_status = {const.INIT_STATUS}
|
|
|
order by file_expire_time
|
|
@@ -201,7 +222,6 @@ class GenerateTextFromVideo(object):
|
|
|
task_list = self.get_task_list()
|
|
|
while task_list:
|
|
|
for task in tqdm(task_list, desc="convert video to text"):
|
|
|
- print(task['pq_vid'], task['file_name'])
|
|
|
# LOCK TASK
|
|
|
lock_row = self.update_task_status(
|
|
|
task_id=task['id'],
|
|
@@ -220,7 +240,7 @@ class GenerateTextFromVideo(object):
|
|
|
case 'ACTIVE':
|
|
|
try:
|
|
|
video_text = self.google_ai_api.get_video_text(
|
|
|
- prompt="分析我上传的视频的画面和音频,用叙述故事的风格将视频所描述的事件进行总结,需要保证视频内容的完整性,并且用中文进行输出,直接返回生成的文本。",
|
|
|
+ prompt=generate_transforming_prompt(task['video_ori_title']),
|
|
|
video_file=google_file
|
|
|
)
|
|
|
if video_text:
|