fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -130,10 +130,10 @@ class MultimodalProcessor:
|
||||
if FFMPEG_AVAILABLE:
|
||||
probe = ffmpeg.probe(video_path)
|
||||
video_stream = next(
|
||||
(s for s in probe["streams"] if s["codec_type"] == "video"), None
|
||||
(s for s in probe["streams"] if s["codec_type"] == "video"), None,
|
||||
)
|
||||
audio_stream = next(
|
||||
(s for s in probe["streams"] if s["codec_type"] == "audio"), None
|
||||
(s for s in probe["streams"] if s["codec_type"] == "audio"), None,
|
||||
)
|
||||
|
||||
if video_stream:
|
||||
@@ -260,7 +260,7 @@ class MultimodalProcessor:
|
||||
if frame_number % frame_interval_frames == 0:
|
||||
timestamp = frame_number / fps
|
||||
frame_path = os.path.join(
|
||||
video_frames_dir, f"frame_{frame_number:06d}_{timestamp:.2f}.jpg"
|
||||
video_frames_dir, f"frame_{frame_number:06d}_{timestamp:.2f}.jpg",
|
||||
)
|
||||
cv2.imwrite(frame_path, frame)
|
||||
frame_paths.append(frame_path)
|
||||
@@ -292,7 +292,7 @@ class MultimodalProcessor:
|
||||
os.path.join(video_frames_dir, f)
|
||||
for f in os.listdir(video_frames_dir)
|
||||
if f.startswith("frame_")
|
||||
]
|
||||
],
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error extracting keyframes: {e}")
|
||||
@@ -333,7 +333,7 @@ class MultimodalProcessor:
|
||||
return "", 0.0
|
||||
|
||||
def process_video(
|
||||
self, video_data: bytes, filename: str, project_id: str, video_id: str = None
|
||||
self, video_data: bytes, filename: str, project_id: str, video_id: str = None,
|
||||
) -> VideoProcessingResult:
|
||||
"""
|
||||
处理视频文件:提取音频、关键帧、OCR
|
||||
@@ -399,7 +399,7 @@ class MultimodalProcessor:
|
||||
"timestamp": timestamp,
|
||||
"text": ocr_text,
|
||||
"confidence": confidence,
|
||||
}
|
||||
},
|
||||
)
|
||||
all_ocr_text.append(ocr_text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user