优化进度回调的逻辑

This commit is contained in:
puke
2025-10-31 14:01:41 +08:00
parent fc63856f9c
commit 7c3a49f55b
4 changed files with 35 additions and 31 deletions

View File

@@ -58,52 +58,52 @@ class FrameProcessor:
try: try:
# Step 1: Generate audio (TTS) # Step 1: Generate audio (TTS)
if progress_callback:
progress_callback(ProgressEvent(
event_type="frame_step",
progress=0.0,
frame_current=frame_num,
frame_total=total_frames,
step=1,
action="audio"
))
await self._step_generate_audio(frame, config) await self._step_generate_audio(frame, config)
# Step 2: Generate image (ComfyKit)
if progress_callback: if progress_callback:
progress_callback(ProgressEvent( progress_callback(ProgressEvent(
event_type="frame_step", event_type="frame_step",
progress=0.25, progress=0.25,
frame_current=frame_num, frame_current=frame_num,
frame_total=total_frames, frame_total=total_frames,
step=1, step=2,
action="audio" action="image"
)) ))
# Step 2: Generate image (ComfyKit)
await self._step_generate_image(frame, config) await self._step_generate_image(frame, config)
# Step 3: Compose frame (add subtitle)
if progress_callback: if progress_callback:
progress_callback(ProgressEvent( progress_callback(ProgressEvent(
event_type="frame_step", event_type="frame_step",
progress=0.50, progress=0.50,
frame_current=frame_num, frame_current=frame_num,
frame_total=total_frames, frame_total=total_frames,
step=2, step=3,
action="image" action="compose"
)) ))
# Step 3: Compose frame (add subtitle)
await self._step_compose_frame(frame, storyboard, config) await self._step_compose_frame(frame, storyboard, config)
# Step 4: Create video segment
if progress_callback: if progress_callback:
progress_callback(ProgressEvent( progress_callback(ProgressEvent(
event_type="frame_step", event_type="frame_step",
progress=0.75, progress=0.75,
frame_current=frame_num, frame_current=frame_num,
frame_total=total_frames, frame_total=total_frames,
step=3,
action="compose"
))
# Step 4: Create video segment
await self._step_create_video_segment(frame, config)
if progress_callback:
progress_callback(ProgressEvent(
event_type="frame_step",
progress=1.0,
frame_current=frame_num,
frame_total=total_frames,
step=4, step=4,
action="video" action="video"
)) ))
await self._step_create_video_segment(frame, config)
logger.info(f"✅ Frame {frame.index} completed") logger.info(f"✅ Frame {frame.index} completed")
return frame return frame

View File

@@ -379,7 +379,7 @@ class VideoGeneratorService:
logger.success(f"🎬 Video generation completed: {final_video_path}") logger.success(f"🎬 Video generation completed: {final_video_path}")
# Step 6: Create result # Step 6: Create result
self._report_progress(progress_callback, "finalizing", 1.0) self._report_progress(progress_callback, "completed", 1.0)
video_path_obj = Path(final_video_path) video_path_obj = Path(final_video_path)
file_size = video_path_obj.stat().st_size file_size = video_path_obj.stat().st_size

View File

@@ -116,17 +116,19 @@
"status.connection_success": "✅ Connected", "status.connection_success": "✅ Connected",
"status.connection_failed": "❌ Connection failed", "status.connection_failed": "❌ Connection failed",
"progress.generating_title": "Generating title...",
"progress.generating_narrations": "Generating narrations...", "progress.generating_narrations": "Generating narrations...",
"progress.splitting_script": "Splitting script...", "progress.splitting_script": "Splitting script...",
"progress.generating_image_prompts": "Generating image prompts...", "progress.generating_image_prompts": "Generating image prompts...",
"progress.frame": "Frame {current}/{total}", "progress.frame": "Frame {current}/{total}",
"progress.frame_step": "Frame {current}/{total} - Step {step}/4: {action}", "progress.frame_step": "Frame {current}/{total} - Step {step}/4: {action}",
"progress.step_audio": "Generating audio", "progress.step_audio": "Generating audio...",
"progress.step_image": "Generating image", "progress.step_image": "Generating image...",
"progress.step_compose": "Composing frame", "progress.step_compose": "Composing frame...",
"progress.step_video": "Creating video segment", "progress.step_video": "Creating video segment...",
"progress.concatenating": "Concatenating video segments...", "progress.concatenating": "Concatenating video...",
"progress.finalizing": "Finalizing...", "progress.finalizing": "Finalizing...",
"progress.completed": "✅ Completed",
"error.input_required": "❌ Please provide topic or content", "error.input_required": "❌ Please provide topic or content",
"error.api_key_required": "❌ Please enter API Key", "error.api_key_required": "❌ Please enter API Key",

View File

@@ -116,17 +116,19 @@
"status.connection_success": "✅ 连接成功", "status.connection_success": "✅ 连接成功",
"status.connection_failed": "❌ 连接失败", "status.connection_failed": "❌ 连接失败",
"progress.generating_title": "生成标题...",
"progress.generating_narrations": "生成旁白...", "progress.generating_narrations": "生成旁白...",
"progress.splitting_script": "切分脚本...", "progress.splitting_script": "切分脚本...",
"progress.generating_image_prompts": "生成图片提示词...", "progress.generating_image_prompts": "生成图片提示词...",
"progress.frame": "分镜 {current}/{total}", "progress.frame": "分镜 {current}/{total}",
"progress.frame_step": "分镜 {current}/{total} - 步骤 {step}/4: {action}", "progress.frame_step": "分镜 {current}/{total} - 步骤 {step}/4: {action}",
"progress.step_audio": "生成语音", "progress.step_audio": "生成语音...",
"progress.step_image": "生成插图", "progress.step_image": "生成插图...",
"progress.step_compose": "合成画面", "progress.step_compose": "合成画面...",
"progress.step_video": "创建视频片段", "progress.step_video": "创建视频片段...",
"progress.concatenating": "拼接视频片段...", "progress.concatenating": "正在拼接视频...",
"progress.finalizing": "完成中...", "progress.finalizing": "完成中...",
"progress.completed": "✅ 生成完成",
"error.input_required": "❌ 请提供主题或内容", "error.input_required": "❌ 请提供主题或内容",
"error.api_key_required": "❌ 请填写 API Key", "error.api_key_required": "❌ 请填写 API Key",