jihuaqiang 1 ay önce
ebeveyn
işleme
e4b731e738

+ 3 - 3
content_indentify/indentify.py

@@ -196,17 +196,17 @@ class ContentIdentifier:
             # 调用内容识别处理
             recognition_result = self.process_content_recognition(formatted_content)
 
-            # 判断识别是否成功:如果视频任一项的 asr_content 包含“视频上传失败”,则标记失败
+            # 判断识别是否成功:如果视频任一项的 asr_content 包含“视频上传失败”或者包含“ASR分析失败”,则标记失败
             video_analysis = recognition_result.get('video_analysis', {})
             video_upload_failed = False
             if isinstance(video_analysis, list):
                 for video_item in video_analysis:
                     if isinstance(video_item, dict) and 'asr_content' in video_item:
-                        if '视频上传失败' in (video_item.get('asr_content') or ''):
+                        if '视频上传失败' in (video_item.get('asr_content') or 'ASR分析失败' in (video_item.get('asr_content') or ''):
                             video_upload_failed = True
                             break
             elif isinstance(video_analysis, dict):
-                if 'asr_content' in video_analysis and '视频上传失败' in (video_analysis.get('asr_content') or ''):
+                if 'asr_content' in video_analysis and ('视频上传失败' in (video_analysis.get('asr_content') or '') or 'ASR分析失败' in (video_analysis.get('asr_content') or '')):
                     video_upload_failed = True
 
             if video_upload_failed:

+ 11 - 21
content_indentify/video_identifier.py

@@ -55,15 +55,13 @@ class VideoIdentifier:
    - 不要添加分析、解释或评论
 
 2. 关键帧提取与描述(包含OCR文字识别):
-   - 将视频分解为多个关键时间片段
+   - 将视频按照画面场景变化分解为多个关键时间片段
    - 对每个时间片段进行以下分析:
-     * 画面的主要视觉元素和内容
-     * 画面的构图和色彩特点
-     * 画面中的人物、物体、场景
-     * 画面中出现的所有文字内容(OCR识别)
+     * 画面的主要视觉元素和内容, 20个字以内
+     * 画面中出现的所有文字内容(OCR识别),**注意忽略语音的字幕**
    - 每个时间片段应包含:
-     * content: 画面内容的详细描述
-     * ocr_content: 该时间段画面中出现的文字内容,仅做文字提取,不要做任何解释或总结
+     * content: 画面内容的详细描述,15个字以内
+     * ocr_content: 该时间段画面中出现的文字内容,仅做画面内文字提取,不要提取字幕文字,不要做任何解释或总结
 
 请严格按照以下JSON格式输出,使用中文输出,不要添加任何其他文字:
 {
@@ -192,16 +190,6 @@ class VideoIdentifier:
                     print(f"    错误: 文件无法读取 - {e}")
                     return None
                 
-                # 3. 网络连接检查
-                try:
-                    print(f"    检查网络连接...")
-                    # 测试基本网络连接
-                    test_response = requests.get("https://generativelanguage.googleapis.com", timeout=10)
-                    print(f"    网络连接: 正常 (状态码: {test_response.status_code})")
-                except Exception as e:
-                    print(f"    警告: 网络连接测试失败 - {e}")
-                    print(f"    继续尝试上传...")
-                
                 # 4. 尝试上传文件
                 print(f"    开始上传文件...")
                 try:
@@ -342,11 +330,11 @@ class VideoIdentifier:
         try:
             # 创建Gemini模型
             model = genai.GenerativeModel(
-                model_name='gemini-2.0-flash',
+                model_name='gemini-2.5-flash',
                 generation_config=genai.GenerationConfig(
                     response_mime_type='application/json',
                     temperature=0.3,
-                    max_output_tokens=20480
+                    max_output_tokens=40960
                 ),
                 safety_settings={
                     HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
@@ -357,8 +345,10 @@ class VideoIdentifier:
             # 生成内容
             response = model.generate_content(
                 contents=[video_file, self.unified_system_prompt],
-                request_options={'timeout': 300}
+                request_options={'timeout': 240}
             )
+
+            print(f"response: {response.text}")
             
             # 检查错误
             if hasattr(response, '_error') and response._error:
@@ -580,7 +570,7 @@ def main():
     test_content = {
         "video_url_list": [
             {
-                "video_url": "https://vd9.bdstatic.com/mda-rf03dz9qrusbwrrb/mb/720p/mv_cae264_backtrack_720p_normal/1748751326307005666/mda-rf03dz9qrusbwrrb.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1755078490-0-0-94814ae256d196c133940bc5fa7054ea&bcevod_channel=searchbox_feed&cr=2&cd=0&pd=1&pt=3&logid=2890204804&vid=12887026108358975692&klogid=2890204804&abtest=",
+                "video_url": "http://rescdn.yishihui.com/pipeline/video/6ab92036-a166-491d-935e-eeeb7c0f2779.mp4",
                 "video_duration": 187
             }
         ]